[cfe-commits] r155541 - in /cfe/trunk: lib/Driver/ test/Driver/ test/Driver/Inputs/basic_android_tree/ test/Driver/Inputs/basic_android_tree/usr/ test/Driver/Inputs/basic_android_tree/usr/lib/
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Apr 25 02:29:13 PDT 2012
On Wed, Apr 25, 2012 at 1:18 PM, James Molloy <james.molloy at arm.com> wrote:
> Hi Evgeniy,
>
> Looks like this broke the windows build:
> http://bb.pgr.jp/builders/cmake-clang-i686-msvc10/builds/2668/steps/test_cla
> ng/logs/Clang%20%3A%3A%20Driver___asan-ld.c
>
> E:\bb-win7\cmake-clang-i686-msvc10\llvm-project\clang\test\Driver\asan-ld.c:
> 9:17: error: expected string not found in input
> // CHECK-LINUX: lib/linux/libclang_rt.asan-i386.a"
>
> Probably should ensure that test is windows-safe.
Sorry. Should be fixed in r155543.
>
> Cheers,
>
> James
>
> -----Original Message-----
> From: cfe-commits-bounces at cs.uiuc.edu
> [mailto:cfe-commits-bounces at cs.uiuc.edu] On Behalf Of Evgeniy Stepanov
> Sent: 25 April 2012 09:59
> To: cfe-commits at cs.uiuc.edu
> Subject: [cfe-commits] r155541 - in /cfe/trunk: lib/Driver/ test/Driver/
> test/Driver/Inputs/basic_android_tree/
> test/Driver/Inputs/basic_android_tree/usr/
> test/Driver/Inputs/basic_android_tree/usr/lib/
>
> Author: eugenis
> Date: Wed Apr 25 03:59:22 2012
> New Revision: 155541
>
> URL: http://llvm.org/viewvc/llvm-project?rev=155541&view=rev
> Log:
> Clang driver support for linking on Android.
>
> Added:
> cfe/trunk/test/Driver/Inputs/basic_android_tree/
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/
>
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o
>
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o
> cfe/trunk/test/Driver/asan-ld.c
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/linux-ld.c
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=15554
> 1&r1=155540&r2=155541&view=diff
> ============================================================================
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Wed Apr 25 03:59:22 2012
> @@ -1269,22 +1269,33 @@
> /// This needs to be called before we add the C run-time (malloc, etc).
> static void addAsanRTLinux(const ToolChain &TC, const ArgList &Args,
> ArgStringList &CmdArgs) {
> - // Add asan linker flags when linking an executable, but not a shared
> object.
> - if (Args.hasArg(options::OPT_shared) ||
> - !Args.hasFlag(options::OPT_faddress_sanitizer,
> + if (!Args.hasFlag(options::OPT_faddress_sanitizer,
> options::OPT_fno_address_sanitizer, false))
> return;
> + if(TC.getTriple().getEnvironment() == llvm::Triple::ANDROIDEABI) {
> + if (!Args.hasArg(options::OPT_shared)) {
> + // For an executable, we add a .preinit_array stub.
> + CmdArgs.push_back("-u");
> + CmdArgs.push_back("__asan_preinit");
> + CmdArgs.push_back("-lasan");
> + }
>
> - // LibAsan is "libclang_rt.asan-<ArchName>.a" in the Linux library
> resource
> - // directory.
> - SmallString<128> LibAsan(TC.getDriver().ResourceDir);
> - llvm::sys::path::append(LibAsan, "lib", "linux",
> - (Twine("libclang_rt.asan-") +
> - TC.getArchName() + ".a"));
> - CmdArgs.push_back(Args.MakeArgString(LibAsan));
> - CmdArgs.push_back("-lpthread");
> - CmdArgs.push_back("-ldl");
> - CmdArgs.push_back("-export-dynamic");
> + CmdArgs.push_back("-lasan_preload");
> + CmdArgs.push_back("-ldl");
> + } else {
> + if (!Args.hasArg(options::OPT_shared)) {
> + // LibAsan is "libclang_rt.asan-<ArchName>.a" in the Linux library
> + // resource directory.
> + SmallString<128> LibAsan(TC.getDriver().ResourceDir);
> + llvm::sys::path::append(LibAsan, "lib", "linux",
> + (Twine("libclang_rt.asan-") +
> + TC.getArchName() + ".a"));
> + CmdArgs.push_back(Args.MakeArgString(LibAsan));
> + CmdArgs.push_back("-lpthread");
> + CmdArgs.push_back("-ldl");
> + CmdArgs.push_back("-export-dynamic");
> + }
> + }
> }
>
> static bool shouldUseFramePointer(const ArgList &Args,
> @@ -5116,9 +5127,10 @@
> C.addCommand(new Command(JA, *this, Exec, CmdArgs));
> }
>
> -static void AddLibgcc(const Driver &D, ArgStringList &CmdArgs,
> - const ArgList &Args) {
> - bool StaticLibgcc = Args.hasArg(options::OPT_static) ||
> +static void AddLibgcc(llvm::Triple Triple, const Driver &D,
> + ArgStringList &CmdArgs, const ArgList &Args) {
> + bool isAndroid = Triple.getEnvironment() == llvm::Triple::ANDROIDEABI;
> + bool StaticLibgcc = isAndroid || Args.hasArg(options::OPT_static) ||
> Args.hasArg(options::OPT_static_libgcc);
> if (!D.CCCIsCXX)
> CmdArgs.push_back("-lgcc");
> @@ -5134,7 +5146,7 @@
> CmdArgs.push_back("--no-as-needed");
> }
>
> - if (StaticLibgcc)
> + if (StaticLibgcc && !isAndroid)
> CmdArgs.push_back("-lgcc_eh");
> else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX)
> CmdArgs.push_back("-lgcc");
> @@ -5148,6 +5160,9 @@
> const toolchains::Linux& ToolChain =
> static_cast<const toolchains::Linux&>(getToolChain());
> const Driver &D = ToolChain.getDriver();
> + const bool isAndroid = ToolChain.getTriple().getEnvironment() ==
> + llvm::Triple::ANDROIDEABI;
> +
> ArgStringList CmdArgs;
>
> // Silence warning for "clang -g foo.o -o foo"
> @@ -5208,6 +5223,10 @@
> CmdArgs.push_back("-static");
> } else if (Args.hasArg(options::OPT_shared)) {
> CmdArgs.push_back("-shared");
> + if ((ToolChain.getArch() == llvm::Triple::arm
> + || ToolChain.getArch() == llvm::Triple::thumb) && isAndroid) {
> + CmdArgs.push_back("-Bsymbolic");
> + }
> }
>
> if (ToolChain.getArch() == llvm::Triple::arm ||
> @@ -5215,7 +5234,9 @@
> (!Args.hasArg(options::OPT_static) &&
> !Args.hasArg(options::OPT_shared))) {
> CmdArgs.push_back("-dynamic-linker");
> - if (ToolChain.getArch() == llvm::Triple::x86)
> + if (isAndroid)
> + CmdArgs.push_back("/system/bin/linker");
> + else if (ToolChain.getArch() == llvm::Triple::x86)
> CmdArgs.push_back("/lib/ld-linux.so.2");
> else if (ToolChain.getArch() == llvm::Triple::arm ||
> ToolChain.getArch() == llvm::Triple::thumb)
> @@ -5239,25 +5260,27 @@
>
> if (!Args.hasArg(options::OPT_nostdlib) &&
> !Args.hasArg(options::OPT_nostartfiles)) {
> - const char *crt1 = NULL;
> - if (!Args.hasArg(options::OPT_shared)){
> - if (Args.hasArg(options::OPT_pie))
> - crt1 = "Scrt1.o";
> - else
> - crt1 = "crt1.o";
> - }
> - if (crt1)
> - CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1)));
> + if (!isAndroid) {
> + const char *crt1 = NULL;
> + if (!Args.hasArg(options::OPT_shared)){
> + if (Args.hasArg(options::OPT_pie))
> + crt1 = "Scrt1.o";
> + else
> + crt1 = "crt1.o";
> + }
> + if (crt1)
> + CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1)));
>
> - CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
> +
> CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
> + }
>
> const char *crtbegin;
> if (Args.hasArg(options::OPT_static))
> - crtbegin = "crtbeginT.o";
> + crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
> else if (Args.hasArg(options::OPT_shared) ||
> Args.hasArg(options::OPT_pie))
> - crtbegin = "crtbeginS.o";
> + crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
> else
> - crtbegin = "crtbegin.o";
> + crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
> CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
> }
>
> @@ -5298,7 +5321,7 @@
> if (Args.hasArg(options::OPT_static))
> CmdArgs.push_back("--start-group");
>
> - AddLibgcc(D, CmdArgs, Args);
> + AddLibgcc(ToolChain.getTriple(), D, CmdArgs, Args);
>
> if (Args.hasArg(options::OPT_pthread) ||
> Args.hasArg(options::OPT_pthreads))
> @@ -5309,18 +5332,19 @@
> if (Args.hasArg(options::OPT_static))
> CmdArgs.push_back("--end-group");
> else
> - AddLibgcc(D, CmdArgs, Args);
> + AddLibgcc(ToolChain.getTriple(), D, CmdArgs, Args);
>
>
> if (!Args.hasArg(options::OPT_nostartfiles)) {
> const char *crtend;
> if (Args.hasArg(options::OPT_shared) ||
> Args.hasArg(options::OPT_pie))
> - crtend = "crtendS.o";
> + crtend = isAndroid ? "crtend_so.o" : "crtendS.o";
> else
> - crtend = "crtend.o";
> + crtend = isAndroid ? "crtend_android.o" : "crtend.o";
>
> CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
> -
> CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
> + if (!isAndroid)
> +
> CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
> }
> }
>
>
> Added:
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_andro
> id_tree/usr/lib/crtbegin_dynamic.o?rev=155541&view=auto
> ============================================================================
> ==
> (empty)
>
> Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_andro
> id_tree/usr/lib/crtbegin_so.o?rev=155541&view=auto
> ============================================================================
> ==
> (empty)
>
> Added:
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_andro
> id_tree/usr/lib/crtbegin_static.o?rev=155541&view=auto
> ============================================================================
> ==
> (empty)
>
> Added:
> cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_andro
> id_tree/usr/lib/crtend_android.o?rev=155541&view=auto
> ============================================================================
> ==
> (empty)
>
> Added: cfe/trunk/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_andro
> id_tree/usr/lib/crtend_so.o?rev=155541&view=auto
> ============================================================================
> ==
> (empty)
>
> Added: cfe/trunk/test/Driver/asan-ld.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/asan-ld.c?rev=1555
> 41&view=auto
> ============================================================================
> ==
> --- cfe/trunk/test/Driver/asan-ld.c (added)
> +++ cfe/trunk/test/Driver/asan-ld.c Wed Apr 25 03:59:22 2012
> @@ -0,0 +1,31 @@
> +// Test AddressSanitizer ld flags.
> +
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN: -target i386-unknown-linux -faddress-sanitizer \
> +// RUN: --sysroot=%S/Inputs/basic_linux_tree \
> +// RUN: | FileCheck --check-prefix=CHECK-LINUX %s
> +// CHECK-LINUX: "{{.*}}ld{{(.exe)?}}"
> +// CHECK-LINUX-NOT: "-lc"
> +// CHECK-LINUX: lib/linux/libclang_rt.asan-i386.a"
> +// CHECK-LINUX: "-lpthread"
> +// CHECK-LINUX: "-ldl"
> +// CHECK-LINUX: "-export-dynamic"
> +
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN: -target arm-linux-androideabi -faddress-sanitizer \
> +// RUN: --sysroot=%S/Inputs/basic_android_tree \
> +// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
> +// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}"
> +// CHECK-ANDROID-NOT: "-lc"
> +// CHECK-ANDROID: "-u" "__asan_preinit" "-lasan"
> +// CHECK-ANDROID: "-lasan_preload" "-ldl"
> +
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN: -target arm-linux-androideabi -faddress-sanitizer \
> +// RUN: --sysroot=%S/Inputs/basic_android_tree \
> +// RUN: -shared \
> +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SHARED %s
> +// CHECK-ANDROID-SHARED: "{{.*}}ld{{(.exe)?}}"
> +// CHECK-ANDROID-SHARED-NOT: "-lc"
> +// CHECK-ANDROID-SHARED-NOT: "-lasan"
> +// CHECK-ANDROID-SHARED: "-lasan_preload" "-ldl"
>
> Modified: cfe/trunk/test/Driver/linux-ld.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=155
> 541&r1=155540&r2=155541&view=diff
> ============================================================================
> ==
> --- cfe/trunk/test/Driver/linux-ld.c (original)
> +++ cfe/trunk/test/Driver/linux-ld.c Wed Apr 25 03:59:22 2012
> @@ -268,3 +268,39 @@
> // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/lib"
> // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib"
> //
> +// Test linker invocation on Android.
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN: -target arm-linux-androideabi \
> +// RUN: --sysroot=%S/Inputs/basic_android_tree \
> +// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
> +// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
> +// CHECK-ANDROID: "{{.*}}/crtbegin_dynamic.o"
> +// CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
> +// CHECK-ANDROID-NOT: "gcc_s"
> +// CHECK-ANDROID: "-lgcc"
> +// CHECK-ANDROID-NOT: "gcc_s"
> +// CHECK-ANDROID: "{{.*}}/crtend_android.o"
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN: -target arm-linux-androideabi \
> +// RUN: --sysroot=%S/Inputs/basic_android_tree \
> +// RUN: -shared \
> +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s
> +// CHECK-ANDROID-SO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
> +// CHECK-ANDROID-SO: "{{.*}}/crtbegin_so.o"
> +// CHECK-ANDROID-SO: "-L[[SYSROOT]]/usr/lib"
> +// CHECK-ANDROID-SO-NOT: "gcc_s"
> +// CHECK-ANDROID-SO: "-lgcc"
> +// CHECK-ANDROID-SO-NOT: "gcc_s"
> +// CHECK-ANDROID-SO: "{{.*}}/crtend_so.o"
> +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
> +// RUN: -target arm-linux-androideabi \
> +// RUN: --sysroot=%S/Inputs/basic_android_tree \
> +// RUN: -static \
> +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s
> +// CHECK-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}"
> "--sysroot=[[SYSROOT:[^"]+]]"
> +// CHECK-ANDROID-STATIC: "{{.*}}/crtbegin_static.o"
> +// CHECK-ANDROID-STATIC: "-L[[SYSROOT]]/usr/lib"
> +// CHECK-ANDROID-STATIC-NOT: "gcc_s"
> +// CHECK-ANDROID-STATIC: "-lgcc"
> +// CHECK-ANDROID-STATIC-NOT: "gcc_s"
> +// CHECK-ANDROID-STATIC: "{{.*}}/crtend_android.o"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
>
>
More information about the cfe-commits
mailing list