Skip to content

Commit

Permalink
Implicitly apply @assumeUsed to rt_{options,envvars_enabled,cmdline…
Browse files Browse the repository at this point in the history
…_enabled} druntime symbol overrides

Required to fix lit-test `linking/rt_options.d` on Apple targets when
linking against *shared* druntime.
  • Loading branch information
kinke committed Feb 11, 2023
1 parent aa9eb33 commit df86c9f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ir/irvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ void IrGlobal::define() {
// If this global is used from a naked function, we need to create an
// artificial "use" for it, or it could be removed by the optimizer if
// the only reference to it is in inline asm.
if (nakedUse) {
// Also prevent linker-level dead-symbol-elimination from stripping
// special `rt_*` druntime symbol overrides (e.g., from executables linked
// against *shared* druntime; required at least for Apple's ld64 linker).
const auto name = gvar->getName();
if (nakedUse || name == "rt_options" || name == "rt_envvars_enabled" ||
name == "rt_cmdline_enabled") {
gIR->usedArray.push_back(gvar);
}

Expand Down

0 comments on commit df86c9f

Please sign in to comment.