Bug 24314 – Linker flag `-L-dead_strip`strips `static this()` and `static ~this()`

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2024-01-01T16:07:55Z
Last change time
2024-12-13T19:32:20Z
Assigned to
No Owner
Creator
Danilo
Moved to GitHub: dmd#18203 →

Comments

Comment #0 by codedan — 2024-01-01T16:07:55Z
// file: test.d // // Problem description: // // When using the additional linker flag `-L-dead_strip` // on macOS, executables produced by DMD strip // static constructors + destructors. // The program runs fine, but static init is silently removed. // // It does not happen with LDC - only with DMD on macOS (x64). // // The online compiler at run.dlang.org does not have the issue. // The compiler option for the online compiler is: `-L-strip-all` // // // [OK] output: // // Hi! // Hello D // Bye! // // [FAIL] output (static constructor/destructor not running): // // Hello D // // Results using DMD: // // [OK] dmd -run test.d // [OK] dmd -release -run test.d // [OK] dmd -debug -run test.d // // [FAIL] dmd -L-dead_strip -run test.d // [FAIL] dmd -L-dead_strip -release -run test.d // [FAIL] dmd -L-dead_strip -debug -run test.d // // Results using LDC: // // [OK] ldc2 --run test.d // [OK] ldc2 --release --run test.d // [OK] ldc2 --d-debug --run test.d // [OK] ldc2 --d --run test.d // // [OK] ldc2 -L-dead_strip --run test.d // [OK] ldc2 -L-dead_strip --release --run test.d // [OK] ldc2 -L-dead_strip --d-debug --run test.d // [OK] ldc2 -L-dead_strip --d --run test.d // import std.stdio : writeln; void main() => writeln(" Hello D"); static this() => writeln("Hi!"); static ~this() => writeln("Bye!");
Comment #1 by robert.schadek — 2024-12-13T19:32:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18203 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB