From: Dimitry Andric Date: Fri, 29 Jun 2018 19:18:17 +0000 (+0000) Subject: Request init/fini array on FreeBSD 12 and later X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=833ad29a88de7d88bd69234b5069bbfaea0235d1;p=clang Request init/fini array on FreeBSD 12 and later 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 --- diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp index 2f632e2b5a..1ecf127c4b 100644 --- a/lib/Driver/ToolChains/Gnu.cpp +++ b/lib/Driver/ToolChains/Gnu.cpp @@ -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())) || diff --git a/test/Driver/constructors.c b/test/Driver/constructors.c index 884fbe8466..a3443a3321 100644 --- a/test/Driver/constructors.c +++ b/test/Driver/constructors.c @@ -80,6 +80,14 @@ // 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 \