Wael Yehia via llvm-dev
2021-Jul-25 17:36 UTC
[llvm-dev] [libLTO] accessing llvm.global_ctors
An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210725/b71818ed/attachment.html>
Fangrui Song via llvm-dev
2021-Jul-25 19:29 UTC
[llvm-dev] [libLTO] accessing llvm.global_ctors
On 2021-07-25, Wael Yehia via llvm-dev wrote:>Hi, >Our linker uses the libLTO interface. Given an lto_module_t, we are trying to >check if it contains the @llvm.global_ctors or the @llvm.global_dtors global >variables. We need to know this information in order to decide whether to >include a bitcode archive member in the LTO step or not.This is strange. Constructors should be orthogonal to archive member extraction. If an archive member is unused, it is not extracted and its constructors are suppressed. C++ [basic.start.dynamic] makes the archive member extraction behavior more plausible: "It is implementation-defined whether the dynamic initialization of a non-block non-inline variable with static storage duration is sequenced before the first statement of main or is deferred.">Typically, symbols in a module are visited using the `lto_module_get_ >[num_symbols|symbol_name|symbol_attribute]` API, but it seems that symbols >starting with "llvm." are skipped.llvm.* symbols have the SF_FormatSpecific flag. Such symbols are in the module symbol table but skipped by readers.>Is there a way to check for the existence of these ctor/dtor variables in an >LTO module (through the libLTO API)?You may need LLVMGetNamedGlobal if you are using the C API.>If not, then I can think of two ways to solve it: > 1) add a new function to libLTO that returns true if either of the two >variables are present. Alternatively it can return a list of variable names >(essentially the contents of @llvm.global_ctors or @llvm.global_dtors) > 2) add a new attribute to `lto_symbol_attributes` denoting that the given >symbol is a constructor or a destructor (i.e. is present in either >@llvm.global_ctors or @llvm.global_dtors) > >Thank you for your feedback > >Wael Yehia >wyehia at ca.ibm.com >>_______________________________________________ >LLVM Developers mailing list >llvm-dev at lists.llvm.org >https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Wael Yehia via llvm-dev
2021-Jul-25 23:16 UTC
[llvm-dev] [libLTO] accessing llvm.global_ctors
An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210725/be9ca783/attachment.html>
Wael Yehia via llvm-dev
2021-Jul-25 23:39 UTC
[llvm-dev] [libLTO] accessing llvm.global_ctors
>>Hi, >>Our linker uses the libLTO interface. Given an lto_module_t, we are trying to >>check if it contains the @llvm.global_ctors or the @llvm.global_dtors global >>variables. We need to know this information in order to decide whether to >>include a bitcode archive member in the LTO step or not. > >This is strange. Constructors should be orthogonal to archive member extraction. >If an archive member is unused, it is not extracted and its constructors >are suppressed.Certain linker flag forces it to include all archive members that have a constructor or destructor. I agree it's strange.