Pull request #6564 (indicated by digger) definitively causes a regression besides the one solved in issue 17338. This regression is valid for DMD releases since 2.075.0 thru 2.077.0 (at the time of this writing).
I have a project split in dub configuration into three subpackages. When I try to build it monolithic (all source files at once) the build succeeds.
But when I let the subpackages be built as libraries and linked into the final binary I get linker errors:
---
Linking...
/usr/bin/ld: .dub/build/library-debug-linux.posix-x86_64-dmd_2075-6DE222CFD88EDD0D48F9BB14A21E15BC/libars-engine.a(log_840_28d9.o): unknown [0] section `' in group [.group]
/usr/bin/ld: .dub/build/library-debug-linux.posix-x86_64-dmd_2075-6DE222CFD88EDD0D48F9BB14A21E15BC/libars-engine.a(log_840_28d9.o): unknown [0] section `' in group [.group]
.dub/build/library-debug-linux.posix-x86_64-dmd_2075-6DE222CFD88EDD0D48F9BB14A21E15BC/libars-engine.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
dmd failed with exit code 1.
---
Content of the library that is built from one of the subpackages (ars-engine) is corrupt. Utility 'nm' reports for some object files within the library the same error (see the issue title) as the linker in the later phase when building the application.
The project is built on top of vibe.d, what may be somehow connected with https://ci.dlang.io/blue/organizations/jenkins/dlang-org%2Fdmd/detail/PR-6564/17/pipeline/
Will this error message be enough or do I need to provide more information on the issue?
Comment #1 by slavo5150 — 2017-11-26T23:57:39Z
> Will this error message be enough or do I need to provide more information on the issue?
A reduced test case would be most helpful.
Comment #2 by llucenic — 2017-11-27T20:54:35Z
I assume it won't be trivial but I'll do my best to provide one soon.
Comment #3 by llucenic — 2017-12-14T10:12:12Z
Created attachment 1667
Test case for #18015
I managed to eliminate the minimum code and it is surprising how small it is. To reproduce the corrupt output of DMD starting 2.075 run following commands:
> dub fetch vibe.d --version=0.7.32
> dmd -lib -debug -g -w -I~/.dub/packages/vibe-d-0.7.32/vibe-d/source configuration.d -vcolumns
To check the result of compilation I used:
> [[ $(nm configuration.a 2>&1 > /dev/null | grep "not recognized" | wc -l) -gt 0 ]] && echo "Compilation FAILS" || echo "Compilation OK"
Or, just using nm on the generated static library outputs to stderr that's something wrong. Running the test on 2.077 fails, on 2.074.1 succeeds.
Comment #4 by bugzilla — 2017-12-28T05:12:20Z
The attachment is just:
module arinas.platform.configuration;
import vibe.data.json;
static:
Json defaultConfig;
The suspected PR:
https://github.com/dlang/dmd/pull/6564
Comment #5 by llucenic — 2017-12-29T14:37:35Z
Walter, the PR 6564 is definitively the cause, not just suspect.
Comment #6 by llucenic — 2018-09-20T06:31:18Z
May I ask, if this would be addressed any time soon, guys? I am really willing to help - if needed, however, the touched code in this PR is quite complex.
I cannot upgrade my platform built in D from version 2.074.1 to any of the more recent compiler versions because of this bug.
Comment #7 by llucenic — 2018-10-10T13:07:45Z
Hello guys,
if this is of any help, I found out, that commenting out
> align(8)
from before the definition of
> struct Json
in vibe.d's vibe.data.json module fixes the linkage.
Anyway, value of align(1,2,4) will just work; values from 8 through 128 break the linkage.
---
Correction to above comments (dash instead of dot):
`> dub fetch vibe-d --version=0.7.32`
Comment #8 by robert.schadek — 2024-12-13T18:55:09Z