Open MingcongBai opened 7 years ago
My bad, did not see #1905.
Actually the issue in the original report is fixed. But there is now a new issue:
Wrong types for attribute: byval inalloca nest noalias nocapture nonnull readnone readonly signext sret zeroext dereferenceable(1) dereferenceable_or_null(1)
double (double)* @_D4core4math3cosFNaNbNiNfeZe
Wrong types for attribute: byval inalloca nest noalias nocapture nonnull readnone readonly signext sret zeroext dereferenceable(1) dereferenceable_or_null(1)
double (double)* @_D4core4math3cosFNaNbNiNfeZe
LLVM ERROR: Broken function found, compilation aborted!
make[2]: *** [runtime/CMakeFiles/druntime-ldc-debug.dir/build.make:154: runtime/src/core/math-debug.o] Error 1
make[2]: *** Waiting for unfinished jobs....
LDC was able to compile itself for the OP of #1904 with #1905 (ppc64 and ppc64le). The signature of double core.math.cos(double)
is trivial and none of the LLVM attributes seem to make sense there. Could you please produce the textual IR for core.math
via -output-ll -disable-verify
and show us the IR for the cosine functions?
Sorry but could you clarify on what I am supposed to do?
Never mind, I'll try it myself at home using your target triple.
So I did a ldc2 -mtriple=powerpc64-aosc-linux-gnu <path>/core/math.d -output-ll -g
on my Windows box using LDC master and then looked at the generated math.ll
file:
; [#uses = 0] [display name = core.math.cos]
define double @_D4core4math3cosFNaNbNiNfeZe(double %x_arg) #0 comdat !dbg !6 {
%x = alloca double, align 8 ; [#uses = 2, size/byte = 8]
store double %x_arg, double* %x, !dbg !12 ; [debug line = 50:10]
call void @llvm.dbg.declare(metadata double* %x, metadata !11, metadata !13), !dbg !12 ; [debug line = 50:10] [debug variable = x]
%1 = load double, double* %x, !dbg !14 ; [#uses = 1] [debug line = 50:43]
%2 = call double @llvm.cos.f64(double %1) #2, !dbg !14 ; [#uses = 1] [debug line = 50:43]
ret double %2, !dbg !14 ; [debug line = 50:43]
}
...
attributes #0 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "target-cpu" "target-features"="+64bit" "unsafe-fp-math"="false" }
So no LLVM attributes in the signature itself, and accordingly no error. Can you try to do the same (maybe add -disable-verify
if the error persists and no .ll file is generated)?
; [#uses = 0] [display name = core.math.cos]
define double @_D4core4math3cosFNaNbNiNfeZe(double %x_arg) #0 comdat !dbg !6 {
%x = alloca double, align 8 ; [#uses = 2, size/byte = 8]
store double %x_arg, double* %x, !dbg !12 ; [debug line = 50:10]
call void @llvm.dbg.declare(metadata double* %x, metadata !11, metadata !13), !dbg !12 ; [debug line = 50:10] [debug variable = x]
%1 = load double, double* %x, !dbg !14 ; [#uses = 1] [debug line = 50:43]
%2 = call double @llvm.cos.f64(double %1) #2, !dbg !14 ; [#uses = 1] [debug line = 50:43]
ret double %2, !dbg !14 ; [debug line = 50:43]
}
...
attributes #0 = { "unsafe-fp-math"="false" }
attributes #1 = { nounwind readnone }
attributes #2 = { nounwind readnone "unsafe-fp-math"="false" }
attributes #3 = { noinline }
And no error was reported. So how exactly did it fail during the build...
And using -c
instead of -output-ll
works too, i.e., generating the object file? Then you may want to look inside the Makefile and check which cmdline flags are actually used to compile core/math.d
to math-debug.o
.
root@ppc64 [ ldc-1.1.0-beta5-src@staging ] # ldc2 -mtriple=powerpc64-aosc-linux-gnu runtime/druntime/src/core/math.d -c
root@ppc64 [ ldc-1.1.0-beta5-src@staging ] # file math.o
math.o: ELF 64-bit MSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped
Yes the build does pass, generating an object file in correct format. And if I am not mistaken, this is where the flags to compile math-debug.o
are located: https://github.com/ldc-developers/ldc/blob/master/runtime/CMakeLists.txt#L15.
Those aren't the final ones, so checking the Makefile makes sense. You should also omit the -mtriple
, I just had to use it for cross-compilation from my Win64 box.
This definitely seems to be an ABI issue, so are you sure the LDC used to compile the runtime is the fixed final one? How did you bootstrap it, i.e., which D host compiler did you use?
This definitely seems to be an ABI issue, so are you sure the LDC used to compile the runtime is the fixed final one? How did you bootstrap it, i.e., which D host compiler did you use?
Ah ha, now that I would suspect that I should re-bootstrap then. I am currently using version 1.1.0b3. Do you think I should drop back down to 0.17 and restart again?
Oh yes. :)
Well then, I will be back in about half an hour.
Latest 0.17 has most ABI fixes, but not all, I just cherry-picked some fixes of #1905 into the ltsmaster
(0.17) branch, so using a fresh ltsmaster for bootstrapping would be even more ideal.
Got it.
Wasn't able to install with ltsmaster
...
-- Installing: /var/lib/abbs/build/tmp.onDmuy1395/ldc/abdist/usr/share/bash-completion/completions/ldc2
CMake Error at runtime/cmake_install.cmake:44 (file):
file INSTALL cannot find
"/var/lib/abbs/build/tmp.onDmuy1395/ldc/runtime/druntime/src/object.d".
Call Stack (most recent call first):
cmake_install.cmake:97 (include)
Did you do a git submodule update
and make sure your src tree is clean with git status
? Btw installing isn't necessary, the compiler in the working/build directory is fine too (and explicitly setting it for LDC master's CMake cmdline via -DD_COMPILER=<path to ltsmaster ldmd2>
).
I am currently building with 0.17.1, and no error so far - 39%.
Let me close this issue then, it's probably due to the fact that I am bootstrapping using a faulty compiler... Sorry for the trouble.
It would be awesome if you could run the library unittests for us, as we're currently completely in the dark wrt. PPC(64). It doesn't take that long if you have a few CPU cores; the debug ones only take an estimated 5 mins on my quadcore. You'd do that by invoking make -j<N> druntime-ldc-unittest-debug phobos2-ldc-unittest-debug && ctest -R "-debug" -E "dmd-testsuite|lit-tests"
in the build directory.
Sure thing, I will post the test log once I am done. Also you are welcome to pop me an email so I can provide you with SSH access if need be.
Thank you very much already. The tests in release mode would be make -j<N> druntime-ldc-unittest phobos2-ldc-unittest && ctest -E "-debug|dmd-testsuite|lit-tests"
;), but the compilation takes longer by something like a factor of 3 or so.
I am currently stuck on 249: std.random
, the test appears to take up 100/400% processor utilization. It's been about 10 minutes now. The others passed through quite quickly but a large number of them failed.
Also strace
attach did not return any output...
Hmm okay, not looking too good then. Just kill the hanging process (phobos-test-runner std.random
or so). The log is in Testing/Temporary/LastTest.log
IIRC; hopefully it'll spit out a fundamental druntime issue accounting for most failures.
Okay, and it goes on, hang on...
Here you are.
Renamed issue and re-opened.
Very nice, thanks. Unfortunately, it looks as if there's a multitude of issues in Phobos (although std/typecons.d(481): Assertion failure
occurs quite frequently). Are you on a big-endian platform?
Yes, a Power Mac G5 with POWER4 (I think) derived PowerPC 970FX.
The std.typecons:481
is a failing string/array comparison, so that should be a fundamental bug [edit: nope, there's a double formatted into the string, and floating point values seem to be garbage]. Can I persuade you to do one more test run, this time the LDC-flavored DMD testsuite, taking a few mins as well? ctest -R dmd-testsuite-debug
, LastTest.log
is the only needed file.
Right, give me a minute.
Here you go, https://pastebin.aosc.io/view/efb009ad.
And Phobos isn't big-endian aware (at least not everywhere), e.g., there's this test in std.outbuffer
:
OutBuffer buf = new OutBuffer();
"hello"w.copy(buf);
assert(buf.toBytes() == "h\x00e\x00l\x00l\x00o\x00");
toBytes()
returns the underlying raw ubyte[]
.
Thanks, but dmd-testsuite-debug
horribly failed, it wasn't even able to build (or execute?) the testrunner due to the std.typecons:481
assertion (although I don't know why that Tuple
unittest is even run).
Anyway, thanks for giving us a picture of where we're currently at on PPC64!
You are very welcome sir.
Multi-byte Unicode encoding also appears to be wrong (UTF-8 at least), this fails (from std.string
):
assert(lastIndexOfAny(to!string("ÖABCDEFCDEF"), to!string("ö"), 2, CaseSensitive.no) == 0);
Edit: Nope, the case-sensitive check works, so it must be the case-insensitiveness (toLower/Upper() failing for big-endian?).
I must admit I was largely ignorant to the state PPC64 altogether – did 1.0 work better (i.e. are these regressions)? In any case, it seems unlikely that we can get much further for this release. @redstar?
The ABI issues were there in 1.0 at least, that's for sure, making the more recent LDC 0.17 versions the only halfway-working ones for Power targets. It's quite astonishing that LDC can build itself, the runtimes and their unittests successfully, but that a lot of tests fails for a seemingly pretty small number of rudimentary issues. Stuff like this certainly doesn't help, and that's in there since forever.
1.1.0b5 could not be built on PPC64 (PowerMac G5) an "Invalid operand types for ICmp instruction" error.
CFLAGS as follows:
LLVM/Clang info:
Build error: