[llvm-dev] X86 does not follow -fuse-init-array

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 11 21:32:36 PST 2019


On 2019-12-10, Reid Kleckner via llvm-dev wrote:
>I bet if you use `-target i386-linux` it will work. You passed `-target -i386`,
>which is a triple with no OS, so Clang is doing something arbitrary. Grepping
>Clang sources shows that this flag is handled in an OS-specific manner:
>
>$ git grep -i fuse_init_array ../clang/lib/Driver/
>../clang/lib/Driver/ToolChains/Fuchsia.cpp:  if (DriverArgs.hasFlag
>(options::OPT_fuse_init_array,
>../clang/lib/Driver/ToolChains/Gnu.cpp:  if (DriverArgs.hasFlag
>(options::OPT_fuse_init_array,
>../clang/lib/Driver/ToolChains/NetBSD.cpp:  if (DriverArgs.hasFlag
>(options::OPT_fuse_init_array,
>../clang/lib/Driver/ToolChains/WebAssembly.cpp:  if (DriverArgs.hasFlag
>(clang::driver::options::OPT_fuse_init_array,
>
>The Gnu.cpp file most likely handles the case of Linux.
>
>This logic looks like it is ripe for refactoring. Patches very welcome. =(

We should probably make -fuse-init-array the CC1 default and the default
for Driver/ToolChains/Gnu.cpp. Very few platforms actually use
.ctors/.dtors nowadays. (This caused a bug this year which was fixed by https://reviews.llvm.org/D62509)

If my suggestion does not sound too stupid, I can create a patch.


More information about the llvm-dev mailing list