Description
On NixOS building dmd 2.083.1 with LDC 1.13.0 doesn't work.
The link of the dmd backend fails with the following message:
../generated/linux/release/64/backend.a(evalu8.o):dmd/backend/evalu8.d:function evalu8(elem*, unsigned int): error: undefined reference to 'Z7_moduloeS'
../generated/linux/release/64/backend.a(evalu8.o):dmd/backend/evalu8.d:function evalu8(elem*, unsigned int): error: undefined reference to 'Z7_moduloeS'
../generated/linux/release/64/backend.a(evalu8.o):dmd/backend/evalu8.d:function evalu8(elem*, unsigned int): error: undefined reference to 'Z7_moduloeS'
collect2: error: ld returned 1 exit status
Error: /nix/store/klci955kxil7q32ggran6lnhpnkk8yjz-gcc-wrapper-7.3.0/bin/c++ failed with status: 1
The created symbol Z7_moduloeS is not a valid name mangled symbol and the corresponding correctly mangled name created by the g++ or clang compilers is _Z7_moduloee .
The problem is reproducible on Linux and Mac OSX, the platform environments are listed below.
Keeping the same environment but switching to LDC version 1.11.0 solves the problem.
To reproduce the problem it's sufficient to just compile evalu8.d and check for the generated "modulo" symbol name:
ldmd2 -c -of../generated/linux/release/64/evalu8.o -version=MARS -fPIC -J../generated/linux/release/64 -w -de -O -release -inline -m64 -mv=dmd.backend=dmd/backend -betterC dmd/backend/evalu8.d
I also tried with LLVM 7 but the unittests failed:
Test project /build/ldc-1.13.0-src/build
Start 1: build-ldc2-unittest
1/2 Test #1: build-ldc2-unittest .............. Passed 94.73 sec
Start 2: ldc2-unittest
2/2 Test #2: ldc2-unittest ....................***Exception: Child aborted 0.04 sec
Fatal error in EH code: DWARF header has unexpected format 2
It must be a bug in LDC 1.13.0 but what I don't understand is that Archlinux also uses LDC 1.13.0 to build DMD 2.083.1 at least according to their package repository. (https://www.archlinux.org/packages/community/x86_64/ldc/)
Platform environments:
LDC - the LLVM D compiler (1.13.0):
based on DMD v2.083.1 and LLVM 5.0.2 (also tried with LLVM 6)
built with LDC - the LLVM D compiler (0.17.6)
Linux:
Default target: x86_64-unknown-linux-gnu
Host CPU: ivybridge
C++ Compiler: g++ (GCC) 7.3.0
OSX:
Default target: x86_64-apple-darwin17.7.0
Host CPU: haswell
C++ Compiler: clang 5.0.2
See also the forum discussion at https://forum.dlang.org/post/dsrjmpnavxqsjqmlvotf@forum.dlang.org