[PATCH] D121327: Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO
Julian Lettner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 14 17:02:16 PDT 2022
yln marked an inline comment as done.
yln added inline comments.
================
Comment at: llvm/lib/CodeGen/TargetPassConfig.cpp:900
+ // __cxa_atexit calls to avoid emitting the deprecated __mod_term_func.
+ if (TM->getTargetTriple().isOSBinFormatMachO())
+ addPass(createLowerGlobalDtorsLegacyPass());
----------------
yln wrote:
> delcypher wrote:
> > Random thought. Do we want to support the legacy way of calling destructors, rather than removing it entirely? If we were to do such a thing I'd suspect we'd guard using the legacy way on the OS deployment target.
> >
> > Just to be clear. I'm happy with the patch the way it is. I'm just wondering if we should consider allowing the legacy way as well. I can't see an obvious use case for it because the new way should work on older OSs too but maybe there's a use case I haven't thought about?
> Having a way to explicitly request the old behavior sounds like a good idea. I will look into it.
I added an escape hatch to fallback to the old behavior:
* via Clang driver flag `-fregister-global-dtors-with-atexit`
* llc / code generation flag -lower-global-dtors-via-cxa-atexit.
This escape hatch will be removed in the future.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121327/new/
https://reviews.llvm.org/D121327
More information about the cfe-commits
mailing list