Enable -fuse-init-array for Android X86/MIPS.
The dynamic linker of Android does not support .ctors/.dtors. We should emit .init_array and .fini_array regardless the gcc version. NOTE: This patch does not affect the ARM backend, because it is required to generate .init_array and .fini_array for program targeting ARM AAPCS and AEABI. llvm-svn: 168309
This commit is contained in:
parent
27a22688b9
commit
1d8cc65a9b
|
@ -2230,7 +2230,8 @@ Tool &Linux::SelectTool(const Compilation &C, const JobAction &JA,
|
|||
|
||||
void Linux::addClangTargetOptions(ArgStringList &CC1Args) const {
|
||||
const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
|
||||
if (V >= Generic_GCC::GCCVersion::Parse("4.7.0"))
|
||||
if (V >= Generic_GCC::GCCVersion::Parse("4.7.0") ||
|
||||
getTriple().getEnvironment() == llvm::Triple::Android)
|
||||
CC1Args.push_back("-fuse-init-array");
|
||||
}
|
||||
|
||||
|
|
|
@ -10,5 +10,21 @@
|
|||
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-GCC-4-6 %s
|
||||
|
||||
|
||||
// CHECK-GCC-4-6-NOT: -fuse-init-array
|
||||
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
|
||||
// RUN: -target arm-unknown-linux-androideabi \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
|
||||
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
|
||||
// RUN: -target mipsel-unknown-linux-android \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
|
||||
|
||||
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
|
||||
// RUN: -target i386-unknown-linux-android \
|
||||
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
|
||||
// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
|
||||
|
||||
// CHECK-ANDROID: -fuse-init-array
|
||||
|
|
Loading…
Reference in New Issue