NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.03k stars 14.03k forks source link

haskell: entropy package throws error building for GHCJS #337996

Open doyougnu opened 2 months ago

doyougnu commented 2 months ago

This commit adds the entropy package to the ghcjs package set in this PR. entropy finishes building, but the build log displays:

entropy> No uhc found
entropy> Running phase: buildPhase
entropy> testRDRAND-301/testRDRAND.c:6:24: error:
entropy>      error: invalid output constraint '=qm' in asm
entropy>         6 |      : "=r" (therand), "=qm" (err));
entropy>           |                        ^
entropy>   |
entropy> 6 |      : "=r" (therand), "=qm" (err));
entropy>   |                        ^
entropy> 1 error generated.
entropy> `emcc' failed in phase `C Compiler'. (Exit code: 1)
entropy> Result of RDRAND Test: False
entropy> Result of libc getrandom() Test: True

What's going on? Well emscripten has failed to compile this function in entropy's Setup.hs file. Why has emscripten failed here? Because emscripten does not support inline assembly only portable C/C++.

What to do? I believe this is an upstream issue. entropy needs to be patched to use a JS random number generator since rdrand is not portable. That is the correct fix, alternatively, the checkRDRAND function could be changed to trivially pass on unsupported targets such as JS and WASM.

doyougnu commented 2 months ago

This is a non-issue actually.

We see the error in the build logs because stderr is not captured here. That there is an error is actually expected. checkRDRAND is working properly, RDRAND is not supported on JS so it should induce this error. Then this result is passed to the next check checkGetRandom which is supported on JS and will properly set LocalBuildInfo for Cabal.

So the actually issue is simply that the error is not captured by the code and we are observing it in the logs even though its benign.