Skip to content

haskellPackages.entropy: build with js backend#336209

Merged
maralorn merged 1 commit intoNixOS:haskell-updatesfrom
alexfmpe:ghc-js-entropy
Aug 21, 2024
Merged

haskellPackages.entropy: build with js backend#336209
maralorn merged 1 commit intoNixOS:haskell-updatesfrom
alexfmpe:ghc-js-entropy

Conversation

@alexfmpe
Copy link
Member

Description of changes

@doyougnu

nix-build -A pkgsCross.ghcjs.haskell.packages.ghc98.entropy actually builds but the logs show

/nix/store/k11rxbj9mvpgfk15rriqjn97by18r2xk-gnutar-1.35/bin/tar
No uhc found
Running phase: buildPhase

testRDRAND-302/testRDRAND.c:6:24: error:
     error: invalid output constraint '=qm' in asm
        6 |      : "=r" (therand), "=qm" (err));
          |                        ^
  |
6 |      : "=r" (therand), "=qm" (err));
  |                        ^
1 error generated.
`emcc' failed in phase `C Compiler'. (Exit code: 1)
Result of RDRAND Test: False
Result of libc getrandom() Test: True
Result of getentropy() Test: True
Preprocessing library for entropy-0.4.1.10..
Building library for entropy-0.4.1.10..
[1 of 2] Compiling System.EntropyGhcjs ( System/EntropyGhcjs.hs, dist/build/System/EntropyGhcjs.o )

It seems #ifdef arch_x86_64 is wrongly being evaluated as true in https://github.com/haskell/entropy/blob/5d0c71ef2b95b2f6314fbb6a24be7bb39dba99bb/cbits/rdrand.c#L14C1-L15C1

I don't see this test error on a project where I use ghcjs 8.10, even though that file had no changes in 9 years so I suspect it's something specific to the js backend.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: haskell General-purpose, statically typed, purely functional programming language label Aug 21, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 21, 2024
@maralorn maralorn merged commit a64b64f into NixOS:haskell-updates Aug 21, 2024
@doyougnu
Copy link

so I suspect it's something specific to the js backend.

Oh yea this would not be surprising to me. Especially because there has been a lot of churn of these ifdef predicates. Is there an issue open to track this?

@doyougnu
Copy link

doyougnu commented Aug 21, 2024

ideally, for cross-compiling, entropy would provide a jsbits for its cbits. This would also be more performant than the js code that emscripten will produce because it'll avoid all the glue code that is generated. Although I'm not sure how feasible that is for this package.

@alexfmpe alexfmpe deleted the ghc-js-entropy branch June 14, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: haskell General-purpose, statically typed, purely functional programming language 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants