]> granicus.if.org Git - clang/commitdiff
Request init/fini array on FreeBSD 12 and later
authorDimitry Andric <dimitry@andric.com>
Fri, 29 Jun 2018 19:18:17 +0000 (19:18 +0000)
committerDimitry Andric <dimitry@andric.com>
Fri, 29 Jun 2018 19:18:17 +0000 (19:18 +0000)
Summary:
It seems a bad idea to change the default in the middle of a release
branch due to possible changes in global ctor / dtor ordering between
.ctors and .init_array. With FreeBSD 11.0's release imminent lets change
the default now for FreeBSD 12 (the current development stream) and
later.

FreeBSD rtld has supported .init_array / .fini_array for many years. As
of Jan 1 2017 all supported FreeBSD releases and branches will have
support.

Reviewers: dim, brooks, arichardson

Reviewed By: dim, brooks, arichardson

Subscribers: bsdjhb, krytarowski, emaste, cfe-commits

Differential Revision: https://reviews.llvm.org/D24867

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336008 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Gnu.cpp
test/Driver/constructors.c

index 2f632e2b5aa21432ca5338a27a213150f010ac9c..1ecf127c4b9cabfaecfe0317c22aeeada68a2f5a 100644 (file)
@@ -2543,6 +2543,8 @@ void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs,
   bool UseInitArrayDefault =
       getTriple().getArch() == llvm::Triple::aarch64 ||
       getTriple().getArch() == llvm::Triple::aarch64_be ||
+      (getTriple().getOS() == llvm::Triple::FreeBSD &&
+       getTriple().getOSMajorVersion() >= 12) ||
       (getTriple().getOS() == llvm::Triple::Linux &&
        ((!GCCInstallation.isValid() || !V.isOlderThan(4, 7, 0)) ||
         getTriple().isAndroid())) ||
index 884fbe8466cb6093e6aeb275d00b17c854ecb757..a3443a3321ad58bf33e494cc0e92c30ab055a0b1 100644 (file)
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1       \
 // RUN:     -target arm64-none-none-eabi \
 // RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1       \
+// RUN:     -target i386-unknown-freebsd11 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-INIT-ARRAY %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1       \
+// RUN:     -target i386-unknown-freebsd12 \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1        \
 // RUN:     -target sparc-sun-solaris2.11 \