Skip to content

Commit

Permalink
Restore clang_rt library name on i686-android.
Browse files Browse the repository at this point in the history
Summary:
Recent changes canonicalized clang_rt library names to refer to
"i386" on all x86 targets. Android historically uses i686.

This change adds a special case to keep i686 in all clang_rt
libraries when targeting Android.

Reviewers: hans, mgorny, beanz

Subscribers: srhines, cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D37278

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312048 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
eugenis committed Aug 29, 2017
1 parent ee6e926 commit d1cb214
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
? "armhf"
: "arm";

// For historic reasons, Android library is using i686 instead of i386.
if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid())
return "i686";

return llvm::Triple::getArchTypeName(TC.getArch());
}

Expand Down
12 changes: 12 additions & 0 deletions test/Driver/sanitizer-ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@
// CHECK-ASAN-ANDROID-NOT: "-lpthread"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target i686-linux-android -fuse-ld=ld -fsanitize=address \
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-X86 %s
//
// CHECK-ASAN-ANDROID-X86: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-ASAN-ANDROID-X86-NOT: "-lc"
// CHECK-ASAN-ANDROID-X86: "-pie"
// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread"
// CHECK-ASAN-ANDROID-X86: libclang_rt.asan-i686-android.so"
// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target arm-linux-androideabi -fsanitize=address \
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
// RUN: -shared-libasan \
Expand Down

0 comments on commit d1cb214

Please sign in to comment.