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

kamlesh kumar via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 11 21:48:25 PST 2019


Fangrui,
All of the OSes/Targets which uses ELF Binary Format  go for default
-fuse-init-array except NetBSD.
Please see here
https://reviews.llvm.org/D71360

kamlesh

On Thu, Dec 12, 2019 at 11:02 AM Fangrui Song <maskray at google.com> wrote:

> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191212/1f164c46/attachment.html>


More information about the llvm-dev mailing list