NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.33k stars 14.3k forks source link

Build failure: dmd #350898

Open kilianar opened 1 month ago

kilianar commented 1 month ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. build dmd

Build log

The error occurs during checkPhase:

 ... fail_compilation/needspkgmod.d -verrors=0 -Icompilable  -fPIC ()==============================
Test 'fail_compilation/needspkgmod.d' failed. The logged output:
/build/dmd/generated/linux/release/64/dmd -conf= -m64 -Ifail_compilation -verrors=0 -Icompilable  -fPIC  -od/build/dmd/compiler/test/test_results/fail_compilation/d -of/build/dmd/compiler/test/test_results/fail_compilation/d/needspkgmod_0 -i=, fail_compilation/needspkgmod.d 
/nix/store/vcvhwiilizhijk7ywyn58p9l005n9sbn-binutils-2.43.1/bin/ld: /build/dmd/compiler/test/test_results/fail_compilation/d/needspkgmod_0.o: in function `D main':
fail_compilation/needspkgmod.d:(.text._Dmain[_Dmain]+0x5): undefined reference to `imports.pkgmod313.mod.bar()'
collect2: error: ld returned 1 exit status
Error: undefined reference to `imports.pkgmod313.mod.bar()`
       referenced from `_Dmain`
       perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)`
Error: linker exited with status 1
       g++ /build/dmd/compiler/test/test_results/fail_compilation/d/needspkgmod_0.o -o /build/dmd/compiler/test/test_results/fail_compilation/d/needspkgmod_0 -m64 -Xlinker -rpath=/build/dmd/compiler/test/../../../phobos/generated/linux/release/64 -L/build/dmd/compiler/test/../../../phobos/generated/linux/release/64 -lphobos2 -lpthread -lm -lrt -ldl 

==============================
Test 'fail_compilation/needspkgmod.d' failed: 
expected:
----
$r:.+_D7imports9pkgmod3133mod3barFZv.*Error: linker exited with status.+$
----
actual:
----
/nix/store/vcvhwiilizhijk7ywyn58p9l005n9sbn-binutils-2.43.1/bin/ld: {{RESULTS_DIR}}/fail_compilation/d/needspkgmod_0.o: in function `D main':
fail_compilation/needspkgmod.d:(.text._Dmain[_Dmain]+0x5): undefined reference to `imports.pkgmod313.mod.bar()'
collect2: error: ld returned 1 exit status
Error: undefined reference to `imports.pkgmod313.mod.bar()`
       referenced from `_Dmain`
       perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)`
Error: linker exited with status 1
       g++ {{RESULTS_DIR}}/fail_compilation/d/needspkgmod_0.o -o {{RESULTS_DIR}}/fail_compilation/d/needspkgmod_0 -m64 -Xlinker -rpath=/build/dmd/compiler/test/../../../phobos/generated/linux/release/64 -L/build/dmd/compiler/test/../../../phobos/generated/linux/release/64 -lphobos2 -lpthread -lm -lrt -ldl
----
diff:
----
-$r:.+_D7imports9pkgmod3133mod3barFZv.*Error: linker exited with status.+$
+/nix/store/vcvhwiilizhijk7ywyn58p9l005n9sbn-binutils-2.43.1/bin/ld: {{RESULTS_DIR}}/fail_compilation/d/needspkgmod_0.o: in function `D main':
+fail_compilation/needspkgmod.d:(.text._Dmain[_Dmain]+0x5): undefined reference to `imports.pkgmod313.mod.bar()'
+collect2: error: ld returned 1 exit status
+Error: undefined reference to `imports.pkgmod313.mod.bar()`
+       referenced from `_Dmain`
+       perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)`
+Error: linker exited with status 1
+       g++ {{RESULTS_DIR}}/fail_compilation/d/needspkgmod_0.o -o {{RESULTS_DIR}}/fail_compilation/d/needspkgmod_0 -m64 -Xlinker -rpath=/build/dmd/compiler/test/../../../phobos/generated/linux/release/64 -L/build/dmd/compiler/test/../../../phobos/generated/linux/release/64 -lphobos2 -lpthread -lm -lrt -ldl
----

Full log: https://hydra.nixos.org/build/275023230/nixlog/1

Additional context

Build failure on hydra

Notify maintainers

@lionello @dukc @jtbx


Add a :+1: reaction to issues you find important.

matt1432 commented 1 month ago

First failure here: https://hydra.nixos.org/build/274876895

Temporarily fixed it with this overlay:

final: prev: {
  dmd = prev.dmd.overrideAttrs (o: {
    postPatch =
      o.postPatch
      + ''
        rm dmd/compiler/test/fail_compilation/needspkgmod.d
      '';
  });
}
jtbx commented 1 month ago

Very weird I wonder what caused this, the package hasn't been updated in months and the offending test has been in dmd for forever. I'm not sure exactly what the issue is so I've opened #351090 to remove the test permanently (as @matt1432 suggested).

ljmf00 commented 1 month ago

DMD and LLVM compiler contributor here. I started using nixos recently and also felt into this error. I recently added D demangling into LLVM. Idk if this is relying on the LLVM to do linking step, but nevertheless the error seems correct to me, although, not covered by DMD testsuite correctly (its expected to fail, but not demangled).

I think the PR you made is ok as a workaround but we need to fix this at upstream by instructing the linker in the testsuite mode to not demangle the symbols. CC @dkorpel @RazvanN7 can one of you take a look at this? :)

dkorpel commented 1 month ago

but we need to fix this at upstream by instructing the linker in the testsuite mode to not demangle the symbols.

That has been done already: https://github.com/dlang/dmd/pull/16833

Although honestly, I still think it's a bad test. DMD shouldn't be testing against linker output which depends on the environment.

antoniocorbi commented 6 days ago

Hi all, After updating to nixos 24.11 I'm trying to install dmd but I still get build errors. When is supposed for dmd to get these fixes and be installable again?

jtbx commented 5 days ago

DMD in nixpkgs must be updated to 2.110.0 to receive Andrei Horodniceanu's fix, which has for some reason not been released yet.

I've ported his fix to nixpkgs in #351090.