This is an archive of the discontinued LLVM Phabricator instance.

Remove -lower-global-dtors-via-cxa-atexit flag
ClosedPublic

Authored by yln on Mar 9 2023, 11:32 AM.

Details

Summary

Remove the -lower-global-dtors-via-cxa-atexit escape hatch introduced
in D121736 [1], which switched the default lowering of global
destructors on MachO to use __cxa_atexit() to avoid emitting
deprecated __mod_term_func sections.

I added this flag as an escape hatch in case the switch causes any
problems. We didn't discover any problems so now we can remove it.

[1] https://reviews.llvm.org/D121736

rdar://90277838

Diff Detail

Event Timeline

yln created this revision.Mar 9 2023, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2023, 11:32 AM
yln requested review of this revision.Mar 9 2023, 11:32 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 9 2023, 11:32 AM
yln retitled this revision from Remove -lower-global-dtors-via-cxa-atexit to Remove -lower-global-dtors-via-cxa-atexit flag.Mar 9 2023, 11:34 AM
yln added reviewers: RKSimon, thetruestblue, rsundahl, wrotki.
rsundahl added inline comments.Mar 9 2023, 12:31 PM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
1205

So the new assertion will be that it's a fatal error to get here at all. Currently, it's a fatal error only if you get here with the flag set. Are we sure that someone isn't getting here w/o the flag set and so they don't get an error but now will? Provided we don't mind surfacing any users of the flag with an explicit fatal error, then this LGTM.

yln added inline comments.Mar 9 2023, 1:41 PM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
1205

Currently, it's a fatal error only if you get here with the flag set. Are we sure that someone isn't getting here w/o the flag set and so they don't get an error but now will?

In the previous revision, I switched the default behavior for destructor lowering for MachO, but added this flag as an escape hatch to request the old behavior. The switch in behavior is encoded as follows. Note: the default of this flag (and resulting Options.LowerGlobalDtorsViaCxaAtExit) is true.

if (TM->getTargetTriple().isOSBinFormatMachO() && TM->Options.LowerGlobalDtorsViaCxaAtExit)
  addPass(createLowerGlobalDtorsLegacyPass())

So the intention was/is that no end user should/will be able to reach this fatal error, it's more of an internal assert for us.

Previously, one could have supplied -lower-global-dtors-via-cxa-atexit=false to set LowerGlobalDtorsViaCxaAtExit to false. I am not aware that anyone ever used the flag / escape hatch.

The error that users get if they had previously supplied the flag will be the following after this change:

Unknown command line argument '-lower-global-dtors-via-cxa-atexit=false'.

It might be worth adding something to the release notes explaining that removal of the flag

thetruestblue accepted this revision.Mar 10 2023, 8:49 AM

This looks good to me. I'm not sure the policy on what should be added to the release notes. But this was a temporary flag only added to slowly deprecate this, and was noted when it was added that it would be removed.

This revision is now accepted and ready to land.Mar 10 2023, 8:49 AM

LGTM, perhaps with addressing @RKSimon remark about release notes

This looks good to me. I'm not sure the policy on what should be added to the release notes. But this was a temporary flag only added to slowly deprecate this, and was noted when it was added that it would be removed.

If it made its way into an actual release of the compiler then we should try to document its removal.

yln updated this revision to Diff 504890.Mar 13 2023, 4:41 PM
yln marked an inline comment as done.
yln added a comment.Mar 13 2023, 4:58 PM

Mentioned removal of flag in release notes.

yln added a comment.Mar 14 2023, 1:41 PM

I will land this later today.

This revision was landed with ongoing or failed builds.Mar 14 2023, 2:18 PM
This revision was automatically updated to reflect the committed changes.