Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -6915,7 +6915,10 @@ 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; Index: test/Driver/gold-lto.c =================================================================== --- test/Driver/gold-lto.c +++ 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"