r316713 - Use -fuse-init-array if no gcc installation is found.
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 26 16:26:29 PDT 2017
Author: nico
Date: Thu Oct 26 16:26:29 2017
New Revision: 316713
URL: http://llvm.org/viewvc/llvm-project?rev=316713&view=rev
Log:
Use -fuse-init-array if no gcc installation is found.
clang currently uses .init_array instead of .ctors on Linux if it detects gcc
4.7+. Make it so that it also uses .init_array if no gcc installation is found
at all – if there's no old gcc, there's nothing we need to be compatible with.
icecc for example runs clang in a very small chroot, so before this change
clang would use .ctors if run under icecc. And lld currently silently mislinks
inputs with .ctors sections, so before this clang + icecc + lld would produce
broken binaries. (But this seems like a good change independent of that lld
bug.)
https://reviews.llvm.org/D39317
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/constructors.c
Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=316713&r1=316712&r2=316713&view=diff
==============================================================================
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Oct 26 16:26:29 2017
@@ -105,6 +105,10 @@ Non-comprehensive list of changes in thi
Users should generally expect this to be regularly raised to match the most
recently released version of the Visual C++ compiler.
+- clang now defaults to ``.init_array`` if no gcc installation can be found.
+ If a gcc installation is found, it still prefers ``.ctors`` if the found
+ gcc is older than 4.7.0.
+
New Compiler Flags
------------------
Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=316713&r1=316712&r2=316713&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Oct 26 16:26:29 2017
@@ -2366,7 +2366,8 @@ void Generic_ELF::addClangTargetOptions(
getTriple().getArch() == llvm::Triple::aarch64 ||
getTriple().getArch() == llvm::Triple::aarch64_be ||
(getTriple().getOS() == llvm::Triple::Linux &&
- (!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) ||
+ ((!GCCInstallation.isValid() || !V.isOlderThan(4, 7, 0)) ||
+ getTriple().isAndroid())) ||
getTriple().getOS() == llvm::Triple::NaCl ||
(getTriple().getVendor() == llvm::Triple::MipsTechnologies &&
!getTriple().hasEnvironment()) ||
Modified: cfe/trunk/test/Driver/constructors.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/constructors.c?rev=316713&r1=316712&r2=316713&view=diff
==============================================================================
--- cfe/trunk/test/Driver/constructors.c (original)
+++ cfe/trunk/test/Driver/constructors.c Thu Oct 26 16:26:29 2017
@@ -6,6 +6,12 @@
//
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/resource_dir \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i386-unknown-linux \
// RUN: --sysroot=%S/Inputs/fake_install_tree \
// RUN: --gcc-toolchain="" \
// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
More information about the cfe-commits
mailing list