LDC master, built with itself, cannot compile druntime/Phobos (Error: template <foo> cannot deduce function...) #1774

Closed
ximion opened this Issue Sep 19, 2016 · 19 comments

Comments

Projects
None yet
3 participants
Contributor

ximion commented Sep 19, 2016

Hello!
Due to an error we currently have an LDC Git snapshot in Debian.
(see https://tracker.debian.org/pkg/ldc )
The current built copy in the archive was build using Git revision 216c112.
Unfortunately, building a newer LDC Git version fails with

[ 11%] Generating gccbuiltins_s390.di
cd /build/ldc-1.1.0git20160919.77fac2d/build-static/runtime && ../bin/gen_gccbuiltins /build/ldc-1.1.0git20160919.77fac2d/build-static/runtime/gccbuiltins_s390.di s390
[ 11%] Generating std/array-debug.o
cd /build/ldc-1.1.0git20160919.77fac2d && /build/ldc-1.1.0git20160919.77fac2d/build-static/bin/ldc2 --output-o -c -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src/gc /build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/array.d -of/build/ldc-1.1.0git20160919.77fac2d/build-static/runtime/std/array-debug.o -w -g -link-debuglib -I/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos
[ 11%] Generating std/ascii-debug.o
cd /build/ldc-1.1.0git20160919.77fac2d && /build/ldc-1.1.0git20160919.77fac2d/build-static/bin/ldc2 --output-o -c -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src/gc /build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/ascii.d -of/build/ldc-1.1.0git20160919.77fac2d/build-static/runtime/std/ascii-debug.o -w -g -link-debuglib -I/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos
[ 11%] Generating std/base64-debug.o
cd /build/ldc-1.1.0git20160919.77fac2d && /build/ldc-1.1.0git20160919.77fac2d/build-static/bin/ldc2 --output-o -c -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src/gc /build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/base64.d -of/build/ldc-1.1.0git20160919.77fac2d/build-static/runtime/std/base64-debug.o -w -g -link-debuglib -I/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos
[ 11%] Generating std/bigint-debug.o
cd /build/ldc-1.1.0git20160919.77fac2d && /build/ldc-1.1.0git20160919.77fac2d/build-static/bin/ldc2 --output-o -c -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src -I/build/ldc-1.1.0git20160919.77fac2d/runtime/druntime/src/gc /build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/bigint.d -of/build/ldc-1.1.0git20160919.77fac2d/build-static/runtime/std/bigint-debug.o -w -g -link-debuglib -I/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(298): Error: template std.conv.toImpl cannot deduce function from argument types !(string)(const(char)[]), candidates are:
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(364):        std.conv.toImpl(T, S)(S value) if (isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T))
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(478):        std.conv.toImpl(T, S)(ref S s) if (isRawStaticArray!S)
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(494):        std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(typeof(S.init.opCast!T()) : T) && !isExactSomeString!T && !is(typeof(T(value))))
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(545):        std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == struct) && is(typeof(T(value))))
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(594):        std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == class) && is(typeof(new T(value))))
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(298):        ... (9 more, -v to show) ...
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(3672): Error: template instance std.conv.to!string.to!(const(char)[]) error instantiating
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(3656):        instantiated from here: textImpl!(string, string, const(char)[])
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/format.d(913):        instantiated from here: text!(string, const(char)[])
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/bigint.d(803):        instantiated from here: FormatSpec!char
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/range/primitives.d(2238): Error: template std.utf.decode cannot deduce function from argument types !()(const(char)[], ulong), candidates are:
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/utf.d(1007):        std.utf.decode(Flag useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index) if (!isSomeString!S && isRandomAccessRange!S && hasSlicing!S && hasLength!S && isSomeChar!(ElementType!S))
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/utf.d(1026):        std.utf.decode(Flag useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index) if (isSomeString!S)
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(1950): Error: template instance std.range.primitives.front!(const(char)) error instantiating
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/format.d(978):        instantiated from here: parse!(int, const(char)[])
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/bigint.d(803):        instantiated from here: FormatSpec!char
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/range/primitives.d(2092): Error: static assert  "Bad template constraint."
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/conv.d(1964):        instantiated from here: popFront!(const(char))
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/format.d(978):        instantiated from here: parse!(int, const(char)[])
/build/ldc-1.1.0git20160919.77fac2d/runtime/phobos/std/bigint.d(803):        instantiated from here: FormatSpec!char
runtime/CMakeFiles/phobos2-ldc-debug.dir/build.make:105: recipe for target 'runtime/std/bigint-debug.o' failed
make[3]: *** [runtime/std/bigint-debug.o] Error 1

I think I have seen this before and it didn't happen when building with a released LDC.
It would be awesome if this problem could be fixed somehow...

@ximion ximion changed the title from Unatble to compile LDC with LDC Git to Unable to compile LDC with LDC Git (Error: template std.conv.toImpl cannot deduce function from argument types !(string)(const(char)[])) Sep 20, 2016

@ximion ximion referenced this issue in gnunn1/tilix Sep 22, 2016

Closed

Need package maintainers #25

Contributor

ximion commented Sep 23, 2016

I tried this again with the released LDC 1.1.0 beta 2: Build of LDC Git succeeds, but when I try to compile the compiler with the result of the first run, I run into the issue described above.

@kinke kinke changed the title from Unable to compile LDC with LDC Git (Error: template std.conv.toImpl cannot deduce function from argument types !(string)(const(char)[])) to LDC master cannot build itself Sep 23, 2016

Member

kinke commented Sep 23, 2016

I'll see if I can reproduce it here.

Contributor

ximion commented Sep 23, 2016

That would be awesome, since a large amount of stuff depends on LDC being ready, and we are running out of time to get LDC into shape to be in the next Debian release...

If you are on any Debian-based derivative, you could easily reproduce this with the packages.
(Sources here: https://anonscm.debian.org/git/pkg-d/ldc.git/ )

Member

kinke commented Sep 23, 2016

I can reproduce it here on Windows too, same errors. :(

Member

kinke commented Sep 23, 2016

As much as I'd like seeing 1.1 in the next Debian release (!), we shouldn't rush - i.e., 1.1 should be released first, maybe even with 1+ week out in the wild to check for serious issues. ;)

a large amount of stuff depends on LDC being ready

If so, we could really use some more manpower over here.

@kinke kinke changed the title from LDC master cannot build itself to LDC master, built with itself, cannot compile druntime/Phobos (Error: template <foo> cannot deduce function...) Sep 23, 2016

Member

kinke commented Sep 23, 2016

I find it hard to make sense of this. Why would the D host compiler used to compile LDC cause these template issues?

Contributor

ximion commented Sep 23, 2016

The main issue is that due to a mistake we have a Git snapshot of LDC in Debian, which is quite painful and should never have happened...

Member

kinke commented Sep 23, 2016

So if the previous 216c112 worked, it's the last DDMD merge that broke it (fails too, just verified, and there's only a LLVM 4.0 debuginfo fix inbetween).

Member

kinke commented Sep 23, 2016

4e495c5, the commit before the DDMD merge, can't build the merge either (or rather, the produced LDC fails to compile the stdlibs too). So my best guess is that the (few) changes in DDMD uncover an older LDC bug which hasn't shown up until now.

@kinke kinke added the A-blocker label Sep 26, 2016

@kinke kinke added this to the 1.1.0 milestone Sep 26, 2016

Member

kinke commented Sep 27, 2016

'Older' bug meaning something that crept in after 1.1.0-beta2, as that one's used by Travis for the LLVM 3.8 Linux job. Any git bisect volunteers? ;)

Edit: Erm, according to @ximion, beta2 should exhibit this bug too. Which LLVM version are you using? I misread it, beta2 was used to compile master, then that LDC produced another LDC master that failed to compile the stdlibs. It's sort of a brain-f*ck to me. ;)

Member

JohanEngelen commented Sep 28, 2016

bisecting...

For easy future reference, using this script with git bisect run:

git submodule update
cd build39release
ninja clean
ninja -j 2
if [ "$?" != "0" ]; then
    exit 125
fi

cd ..
cd build39self
ninja clean
ninja -j 2

if [ "$?" != "0" ]; then
    exit 1
fi
Member

JohanEngelen commented Sep 28, 2016

Commit e711dea works.

Commit caf5397 starts failing self-build with a few of these:

/Users/johan/ldc/johan/runtime/phobos/std/internal/test/dummyrange.d(188): Error: template instance std.internal.test.dummyrange.DummyRange!(cast(ReturnBy)0, cast(Length)0, cast(RangeType)1) does not match template declaration DummyRange(ReturnBy _r, Length _l, RangeType _rt, T = uint[]) if (isArray!T)
...

Note: it's a different error than the error in OP.

Member

kinke commented Sep 28, 2016

Thanks Johan! Too bad it's that huge commit. :(

Member

JohanEngelen commented Sep 28, 2016

I find it hard to make sense of this. Why would the D host compiler used to compile LDC cause these template issues?

This.
So apparently we miscompile something, and it manifests in funny template issues. But how does the exception handling stuff cause that??

Member

kinke commented Oct 1, 2016

I bet it's this nested scope(exit) change, in combination with 2 forward-referenced goto's for which it probably isn't applied anymore.

Member

kinke commented Oct 1, 2016

Well, by looking at the IR for the 5 touched modules in the front-end merge commit, only ddmd/expression.d is compiled differently between e711dea and caf5397. It does smell like a bug wrt. unresolved gotos and clean-ups, but it's not obvious after a first look.

kinke added a commit to kinke/ldc that referenced this issue Oct 2, 2016

Fix issue #1774
Running a cleanup with a dummy target BB and later replacing all uses of
that dummy with the actual BB is buggy, as the cleanup keeps track of its
exit targets (via pointers) which aren't updated.

kinke added a commit that referenced this issue Oct 2, 2016

Member

kinke commented Oct 2, 2016

Fixed by #1803 (no test yet).

@kinke kinke closed this Oct 2, 2016

Contributor

ximion commented Oct 2, 2016

Thanks a lot!
Let's see if this can help to unblock the package at Debian :-)

Contributor

ximion commented Oct 3, 2016

Maybe having the CI test whether LDC can compile itself would make some sense too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment