[PATCH] D71393: Default to -fno-use-init-array

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 11 22:43:48 PST 2019


MaskRay created this revision.
MaskRay added reviewers: brad, kamleshbhalui, lenary, phosek, rnk.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, pzheng, s.egerton, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, atanasyan, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, fedor.sergeev, aheejin, kristof.beyls, jgravelle-google, krytarowski, sbc100, emaste, dschuff.
Herald added a project: clang.

Very few ELF platforms still use .ctors/.dtors now.  Linux (glibc: 1999-07),
DragonFlyBSD, FreeBSD (2012-03) and Solaris have supported .init_array
for many years. Some architectures like AArch64/RISC-V default to
.init_array . GNU ld and gold can even convert .ctors to .init_array .

It makes more sense to flip the CC1 default, and only uses
-fno-use-init-array on platforms that don't support .init_array .
For example, OpenBSD did not support DT_INIT_ARRAY before Aug 2016
(https://github.com/openbsd/src/commit/86fa57a2792c6374b0849dd7b818a11e676e60ba)

I may miss some ELF platforms that still use .ctors, but their
maintainers can easily diagnose such problems.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71393

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.h
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenObjC/gnu-init.m
  clang/test/Driver/constructors.c
  clang/test/Driver/fembed-bitcode.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/fuchsia.cpp
  clang/test/Driver/mips-mti-linux.c
  clang/test/Driver/nacl-direct.c
  clang/test/Driver/netbsd.c
  clang/test/Driver/openbsd.c
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71393.233503.patch
Type: text/x-patch
Size: 33982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191212/84f479e8/attachment-0001.bin>


More information about the cfe-commits mailing list