Bug 21294 – [REG 2.095]: DMD fails to link since PR11743

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-10-05T22:55:07Z
Last change time
2020-10-08T13:35:24Z
Keywords
pull
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2020-10-05T22:55:07Z
Comment #1 by ibuclaw — 2020-10-05T22:59:50Z
ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.findSlot(ulong, const(char)[]) const': dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: /build/gcc/d/dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: /build/gcc/d/dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.allocValue(const(char)[], dmd.mtype.Type)': dmd/root/stringtable.d:261: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: /build/gcc/d/dmd/root/stringtable.d:262: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.grow()': dmd/root/stringtable.d:303: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toString() inout' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.findSlot(ulong, const(char)[]) const': dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: /build/gcc/d/dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.grow()': dmd/root/stringtable.d:303: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toString() inout' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.allocValue(const(char)[], dmd.mtype.Type)': dmd/root/stringtable.d:261: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: /build/gcc/d/dmd/root/stringtable.d:262: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.findSlot(ulong, const(char)[]) const': dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.allocValue(const(char)[], dmd.mtype.Type)': dmd/root/stringtable.d:261: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: /build/gcc/d/dmd/root/stringtable.d:262: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.grow()': dmd/root/stringtable.d:303: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toString() inout' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.findSlot(ulong, const(char)[]) const': dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: /build/gcc/d/dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.allocValue(const(char)[], dmd.mtype.Type)': dmd/root/stringtable.d:261: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: /build/gcc/d/dmd/root/stringtable.d:262: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.grow()': dmd/root/stringtable.d:303: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toString() inout' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.findSlot(ulong, const(char)[]) const': dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: /build/gcc/d/dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.allocValue(const(char)[], dmd.mtype.Type)': dmd/root/stringtable.d:261: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: /build/gcc/d/dmd/root/stringtable.d:262: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.lstring()' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.grow()': dmd/root/stringtable.d:303: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toString() inout' ld: d/func.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.findSlot(ulong, const(char)[]) const': dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: d/mtype.o: in function `dmd.root.stringtable.StringTable!(dmd.mtype.Type).StringTable.findSlot(ulong, const(char)[]) const': dmd/root/stringtable.d:285: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' ld: d/typesem.o: in function `dmd.typesem.merge(dmd.mtype.Type)': dmd/gcc/../../gcc/d/dmd/typesem.d:2122: undefined reference to `dmd.root.stringtable.StringValue!(dmd.mtype.Type).StringValue.toDchars() const' collect2: error: ld returned 1 exit status
Comment #2 by ibuclaw — 2020-10-05T23:01:06Z
Reverting the removal of imports in https://github.com/dlang/dmd/pull/11743 fixes the link error.
Comment #3 by razvan.nitu1305 — 2020-10-06T03:04:19Z
Which imports exactly are you referring to? Also, how can we reproduce this?
Comment #4 by ibuclaw — 2020-10-06T08:52:54Z
(In reply to RazvanN from comment #3) > Which imports exactly are you referring to? It looks like a single import is the trigger over whether StringValue!Type is emitted or not. import dmd.dscope; Adding this back to dmd/aliasthis.d fixes the stage1 bootstrap. Currently running stage2 bootstrap. Without the import, this outputs nothing, and leaves undefined symbol references to StringValue!(Type).toDchars and others. $ gdc -fno-PIE -c -g -O2 -fversion=IN_GCC -frelease -fPIC -Wall -Wdeprecated -o d/mtype.o -MT d/mtype.o -MMD -MP -MF d/.deps/mtype.TPo -I../../gcc/d -J../../gcc/d/dmd -J../../gcc/d/dmd/res ../../gcc/d/dmd/mtype.d -v 2>&1 | grep StringValue $ nm d/mtype.o | grep StringValue8toDchars U _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue8toDcharsMxFNaNbNiNjZPxa With the import however. $ gdc -fno-PIE -c -g -O2 -fversion=IN_GCC -frelease -fPIC -Wall -Wdeprecated -o d/mtype.o -MT d/mtype.o -MMD -MP -MF d/.deps/mtype.TPo -I../../gcc/d -J../../gcc/d/dmd -J../../gcc/d/dmd/res ../../gcc/d/dmd/mtype.d -v 2>&1 | grep StringValue function dmd.root.stringtable.StringValue!(Type).StringValue.lstring function dmd.root.stringtable.StringValue!(Type).StringValue.len function dmd.root.stringtable.StringValue!(Type).StringValue.toDchars function dmd.root.stringtable.StringValue!(Type).StringValue.toString function dmd.root.stringtable.StringValue!(Type).StringValue.__xopEquals function dmd.root.stringtable.StringValue!(Type).StringValue.__xtoHash $ nm d/mtype.o | grep StringValue8toDchars 0000000000000000 W _D3dmd4root11stringtable34__T11StringValueTC3dmd5mtype4TypeZ11StringValue8toDcharsMxFNaNbNiNjZPxa
Comment #5 by ibuclaw — 2020-10-06T09:02:18Z
(In reply to RazvanN from comment #3) > Also, how can we reproduce this? It looks like DMD is in a worse state, a simple reproducer script shows that reverting the PR doesn't help DMD at all (using v2.091.1 as host compiler). ``` #!/bin/bash mkdir -p build echo "/etc" > build/SYSCONFDIR.imp echo "v2.094.0" > build/VERSION for dir in . root backend; do mkdir -p build/${dir} for src in src/dmd/${dir}/*.d; do echo dmd -version=MARS -I=src -J=src/dmd/res -J=build -c -od=build/${dir} ${src} dmd -version=MARS -I=src -J=src/dmd/res -J=build -c -od=build/${dir} ${src} done done echo dmd build/*.o build/root/*.o build/backend/*.o -of=build/dmd dmd build/*.o build/root/*.o build/backend/*.o -of=build/dmd echo =================== dmd --version ```
Comment #6 by ibuclaw — 2020-10-06T09:07:57Z
Slightly tweaked for some added parallelism for bisecting dmd. I'll see if there's a first good commit with dmd. ``` #!/bin/bash if [ -d build ]; then rm -r build; fi mkdir build echo "/etc" > build/SYSCONFDIR.imp echo "v2.000.0" > build/VERSION for dir in . root backend; do mkdir -p build/${dir} for src in src/dmd/${dir}/*.d; do echo dmd -version=MARS -I=src -J=src/dmd/res -J=build \ -c -od=build/${dir} ${src} dmd -version=MARS -I=src -J=src/dmd/res -J=build \ -c -od=build/${dir} ${src} & sleep 0.05 done done echo dmd build/*.o build/root/*.o build/backend/*.o -of=build/dmd dmd build/*.o build/root/*.o build/backend/*.o -of=build/dmd echo ========================= dmd --version
Comment #7 by ibuclaw — 2020-10-06T09:18:51Z
When building 2.092.1 using dmd as host compiler, it still fails to link due to missing StringValue!(Symbol).toDchars, but the missing StringValue!(Type) is now gone. ((v2.092.1)|BISECTING) $ nm build/mtype.o | grep _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa 0000000000000000 W _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa ((v2.092.1)|BISECTING) $ nm build/typesem.o | grep _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa U _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa
Comment #8 by ibuclaw — 2020-10-06T09:28:49Z
The first bad commit for dmd was https://github.com/dlang/dmd/pull/11083 Adding the import of stringtable in that PR now means that all modules think it's OK to omit generating code for StringValue!(Type). ((9fa18aa20...)|BISECTING) $ nm build/func.o | grep _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa U _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa ((9fa18aa20...)|BISECTING) $ nm build/typesem.o | grep _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa U _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa ((9fa18aa20...)|BISECTING) $ nm build/mtype.o | grep _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa U _D3dmd4root11stringtable__T11StringValueTCQBo5mtype4TypeZQBe8toDcharsMxFNaNbNiNjZPxa
Comment #9 by ibuclaw — 2020-10-06T09:42:01Z
(In reply to Iain Buclaw from comment #8) > The first bad commit for dmd was https://github.com/dlang/dmd/pull/11083 > > Adding the import of stringtable in that PR now means that all modules think > it's OK to omit generating code for StringValue!(Type). > Adding -allinst does not help either. ``` #!/bin/bash # Toggle testing using -allinst dflags="-allinst" if [ -d build ]; then rm -r build; fi mkdir build echo "/etc" > build/SYSCONFDIR.imp echo "v2.000.0" > build/VERSION echo "" > build/default_ddoc_theme.ddoc for dir in . root backend; do mkdir -p build/${dir} for src in src/dmd/${dir}/*.d; do echo dmd ${dflags} -version=MARS -I=src -J=src/dmd/res -J=build \ -c -od=build/${dir} ${src} dmd ${dflags} -version=MARS -I=src -J=src/dmd/res -J=build \ -c -od=build/${dir} ${src} & sleep 0.05 done done wait echo dmd build/backend/*.o build/root/*.o build/*.o -of=build/dmd dmd build/backend/*.o build/root/*.o build/*.o -of=build/dmd echo ========================= dmd --version ```
Comment #10 by ibuclaw — 2020-10-06T12:39:29Z
Although re-adding the dscope import fixes the bootstrap and build for gdc. Counter-intuitively, removing *more* imports appears to fix the issue for dmd. I see StringValue!Type being generated after removing unused imports from access.d, aggregate.d, arrayop.d, canthrow.d, compiler.d, and cond.d. $ dmd -version=MARS -I=src -J=src/dmd/res -J=build -c -od=build/. src/dmd/./mtype.d -v | grep StringV function dmd.root.stringtable.StringValue!(Type).StringValue.lstring function dmd.root.stringtable.StringValue!(Type).StringValue.len function dmd.root.stringtable.StringValue!(Type).StringValue.toDchars function dmd.root.stringtable.StringValue!(Type).StringValue.toString function dmd.root.stringtable.StringValue!(Type).StringValue.__xopEquals function dmd.root.stringtable.StringValue!(Type).StringValue.__xtoHash
Comment #11 by dlang-bot — 2020-10-06T14:47:38Z
@ibuclaw created dlang/dmd pull request #11827 "Issue21294" fixing this issue: - Fix Issue 21294: Workaround missing references to template StringValue!(Type) https://github.com/dlang/dmd/pull/11827
Comment #12 by dlang-bot — 2020-10-08T13:35:24Z
dlang/dmd pull request #11827 "[REG 2.095] Fix build regression when compiling dmd using separate compilation" was merged into master: - 19959df3dda0d65c0cecb5a191de7733b7a66f9b by Iain Buclaw: Fix Issue 21294: Workaround missing references to template StringValue!(Type) https://github.com/dlang/dmd/pull/11827