www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - wasm/baremetal lit tests failing on NixOS

reply Thomas Mader <thomas.mader gmail.com> writes:
Hello,

I try to update the ldc package on NixOS to 1.13.0 but get the 
following errors when running the wasm lit tests:

$ "/build/ldc-1.13.0-src/build/bin/ldc2" 
"-mtriple=wasm32-unknown-unknown-wasm" "-link-internally" 
"/build/ldc-1.13.0-src/tests/baremetal/wasm.d" "-conf=" 
"-I/build/ldc-1.13.0-src/tests/baremetal/inputs"

ldc2: Unknown command line argument '-link-internally'.

and

$ "/build/ldc-1.13.0-src/build/bin/ldc2" 
"-mtriple=wasm32-unknown-unknown-wasm" "-betterC" 
"/build/ldc-1.13.0-src/tests/baremetal/wasm2.d"

wasm2.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
Error: 
/nix/store/klci955kxil7q32ggran6lnhpnkk8yjz-gcc-wrapper-7.3.0/bin/gcc failed
with status: 1

I thought that the missing -link-internally argument is caused by 
the -DLDC_WITH_LLD=OFF option but removing it doesn't solve the 
problem.
I think the main problem is that gcc is the build compiler in the 
environment and I haven't found a way to change that to clang.
Could this be the problem? It seems that LLD is not used for 
linking and that's also the reason why -link-internally isn't 
available.

The baremetal directory didn't change since 1.11.0 and 1.11.0 was 
working on NixOS with llvm 5.
The strange thing is that gcc was used for building with 1.11.0 
too.
I build with llvm 6 now and wasm on NixOS seems to be enabled:

https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/llvm/6/llvm.nix#L15

Any ideas?

Thomas
Dec 22 2018
parent reply kinke <noone nowhere.com> writes:
First of all, these errors are not crucial.

Issue 1: tests/baremetal/wasm.d shouldn't explicitly use 
`-link-internally`, as that requires LDC to be built with CMake 
LDC_WITH_LLD != OFF *and* installed LLD dev files *and* that LLD 
to be patched (https://github.com/ldc-developers/lld) to work 
correctly.

Issue 2: both wasm.d and wasm2.d expect linking to WebAssembly to 
work, and that is currently only achievable via an integrated 
patched LLD. For this to work with an external linker (e.g., 
LLD's `wasm-ld`), LDC needs to be fixed by invoking the linker 
directly for WebAssembly targets, instead of issuing a gcc/clang 
command line as it currently does.
Dec 22 2018
parent reply Thomas Mader <thomas.mader gmail.com> writes:
On Saturday, 22 December 2018 at 16:06:37 UTC, kinke wrote:
 First of all, these errors are not crucial.
Thank you for the detailed explanation. I switched to llvm 5 and the errors are gone. Why is that?
Dec 22 2018
parent kinke <noone nowhere.com> writes:
On Saturday, 22 December 2018 at 16:24:01 UTC, Thomas Mader wrote:
 I switched to llvm 5 and the errors are gone. Why is that?
IIRC, WebAssembly support for LLD was added with LLD v6.
Dec 22 2018