<div dir="auto">Hello,<div dir="auto">Sorry about my bad english and wrecked communications line. I meant 11944 bug from llvm database. As on our system, we had similar issue in sense on embedded project around lte and 5g base stations. Archs finally decided global compound constructors are forbidden due to startup overhead and call order unpredictability.</div><div dir="auto"><br></div><div dir="auto">Thank You for mentioning warning enabling flag. That should help me pinpoint all interesting uses of this construct.</div><div dir="auto"><br></div><div dir="auto">I will try to lookup how these global constructors are done in llvmlib. What i saw as general guideline along which commandline opts component is built i generally like. I dont see yet fully where is issue in moving it to runtime. Id think we could try to use some pattern like commandline opts tables from gcc but nit sure yet whether keep much in globals or store within specific apps/tools classes.</div><div dir="auto"><br></div><div dir="auto">In one of first phases id think of checking buildflags of clang what targets etc are enabled and register all supported commands and maybe prescan command line for further flags which enable or disable other flags.</div><div dir="auto"><br></div><div dir="auto">I will try to build llvm lib with this warning enabled to see all opts uses and learn the api etc. I need to understand furst completely based on what logic macros and flags which flags blocks should be registered and later kept or disabled if we need to scan commandline in multiple passes etc.</div><div dir="auto"><br></div><div dir="auto">Ill try to learn all i can first from code and gathered warnings and if questions arise ill ring back with them and if not ill try to propose some solution after fully testing it on current testsuite and all targets etc.</div><div dir="auto"><br></div><div dir="auto">Best regards,</div><div dir="auto">Pawel Kunio</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">pt., 23.04.2021, 02:30 użytkownik David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> napisał:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[It might be helpful if you used a few more words & fully explained<br>
what you're referring to - I'm having a hard time following your<br>
emails in this abbreviated writing style]<br>
<br>
You looked at an existing bug (do you have a link to it, or bug number<br>
on the <a href="http://bugs.llvm.org" rel="noreferrer noreferrer" target="_blank">bugs.llvm.org</a> database) related to the use of global<br>
constructors in the LLVM codebase? Or in another codebase using LLVM?<br>
<br>
You had similar issues on another codebase you worked on where you<br>
weren't allowed to use any non-trivial global constructors?<br>
<br>
& you're proposing creating a checker or other tool to help find these<br>
cases? Or proposing using an existing tool for finding such things?<br>
<br>
Clang does have a warning for this already, I believe:<br>
-Wglobal-constructors. But, yes, the LLVM codebase isn't remotely<br>
ready for that and it's not been a high enough priority for anyone to<br>
really clean it up - mostly because the main use of global<br>
constructors is in the LLVM command line argument handling code - so<br>
it's a non-trivial design/redesign/refactoring effort to figure out<br>
the right new design for that and make all the changes necessary to<br>
migrate to such a design. (after that there'd probably be a bunch of<br>
smaller more incremental changes to cleanup global constructors and<br>
get the codebase to have no -Wglobal-constructors warnings, then we<br>
could turn on the warning to ensure we didn't regress)<br>
<br>
 - Dave<br>
<br>
On Thu, Apr 22, 2021 at 4:50 PM pawel k. via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hello,<br>
> I took glimpse of PR llvm and or clang has ie lib cpp compound constructing global vars which makes objects get constructed in random order and with nonzero startup cpu/time overhead.<br>
><br>
> In one of rather mighty embedded projects for 4g enodeb and later 5g base stations we had similar issue. It was forbidden to complex construct global vars.<br>
><br>
> We could fancy clang syntax checker having option to early detect and track those so we could now how many are still left if any. I would disencourage running it on testsuite though as there were many false positives reported there.<br>
><br>
> Happy if that helps any.<br>
><br>
> Best regards,<br>
> Pawel Kunio<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>