From: Alexey Volkov Date: Tue, 29 Apr 2014 10:25:20 +0000 (+0000) Subject: Pass -pie to linker when generating executable on Android X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab5d05bc91d7c3675d4abe0a139a4337d29cb616;p=clang Pass -pie to linker when generating executable on Android This fixes problem with LTO on Android. Differential Revision: http://reviews.llvm.org/D2668 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207520 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index a8d3f010bd..bda4edfd07 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -6917,7 +6917,10 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA, ToolChain.getTriple().getEnvironment() == llvm::Triple::Android; const bool IsPIE = !Args.hasArg(options::OPT_shared) && - (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault()); + !Args.hasArg(options::OPT_static) && + (Args.hasArg(options::OPT_pie) || ToolChain.isPIEDefault() || + // On Android every code is PIC so every executable is PIE + isAndroid); ArgStringList CmdArgs; diff --git a/test/Driver/gold-lto.c b/test/Driver/gold-lto.c index c2e8bdfbc7..18a293b696 100644 --- a/test/Driver/gold-lto.c +++ b/test/Driver/gold-lto.c @@ -19,3 +19,8 @@ // CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so" // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8" // CHECK-ARM-V7A: "-plugin-opt=foo" +// +// RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID +// CHECK-X86-ANDROID: "-pie" +// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"