Bug 18456 – crt_constructor/crt_destructor segfaults if -lib

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-02-18T06:27:28Z
Last change time
2019-01-02T05:51:02Z
Keywords
betterC, ice-on-valid-code, pull
Assigned to
No Owner
Creator
Илья Ярошенко

Comments

Comment #0 by ilyayaroshenko — 2018-02-18T06:27:28Z
pragma(crt_constructor) extern(C) void mir_cpuid_crt_init() { } dmd -lib -oflibmir-cpuid.a source.d Segmentation fault: 11
Comment #1 by aliloko — 2018-10-01T15:47:19Z
Same here, we also hit this: -------- main.d ---------- extern(C) pragma(crt_destructor) void deactivateDRuntime() { } -------------------------- dmd -lib main.d
Comment #2 by aliloko — 2018-10-01T15:53:15Z
Can be workarounded by using LDC. Can be workarounded by compiling in one bunch with --combined of course.
Comment #3 by r.sagitario — 2018-12-24T16:45:25Z
Comment #4 by github-bugzilla — 2019-01-02T05:51:02Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/20afb4363b236fdd006b43282973749c25049aae fix issue 18456 - crt_constructor/crt_destructor segfaults if -lib delay objmod.setModuleCtorDtor until the function is actually generated don't make them extra object files in a library, they will never be linked https://github.com/dlang/dmd/commit/2842e8bfe231775bda1683bf3fb82d4ffe47e87f Merge pull request #9132 from rainers/issue18456 fix issue 18456 - crt_constructor/crt_destructor segfaults if -lib merged-on-behalf-of: Nicholas Wilson <[email protected]>