nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

hare: enable cross-compilation

Open onemoresuza opened this issue 5 months ago • 6 comments

Description of changes

  • qbe: enable cross-compilation
  • harec: enable cross-compilation
  • hare: enable cross-compilation

Things done

  • Built on platform(s)
    • [X] x86_64-linux
    • [x] aarch64-linux
    • [ ] x86_64-darwin
    • [ ] aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • [ ] sandbox = relaxed
    • [ ] sandbox = true
  • [X] Tested, as applicable:
  • [x] 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
  • [X] Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 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
  • [X] Fits CONTRIBUTING.md.

Note for reviewers

To test this PR:

git clone --filter=blob:none --depth=1 -b hare-crosscomp https://github.com/onemoresuza/nixpkgs.git hare-crosscomp
cd hare-crosscomp
nix-build -E '
    let
        pkgs = import ./. {};
        x86_64 = builtins.attrValues {
            inherit (pkgs.pkgsCross.gnu64) qbe harec hare;
        };
        aarch64 = builtins.attrValues {
            inherit (pkgs.pkgsCross.aarch64-multiplatform) qbe harec hare;
        };
    in
        aarch64 ++ x86_64
'

Add a :+1: reaction to pull requests you find important.

onemoresuza avatar Mar 01 '24 16:03 onemoresuza

Result of nixpkgs-review pr 292608 run on x86_64-linux 1

1 package marked as broken and skipped:
  • himitsu-firefox
16 packages built:
  • bonsai
  • hare
  • hare.man
  • hareThirdParty.hare-compress
  • hareThirdParty.hare-ev
  • hareThirdParty.hare-json
  • hareThirdParty.hare-png
  • hareThirdParty.hare-ssh
  • hareThirdParty.hare-toml
  • harec
  • haredo
  • haredo.man
  • himitsu
  • qbe
  • treecat
  • treecat.man

onemoresuza avatar Mar 01 '24 18:03 onemoresuza

Result of nixpkgs-review pr 292608 run on aarch64-linux 1

1 package marked as broken and skipped:
  • himitsu-firefox
16 packages built:
  • bonsai
  • hare
  • hare.man
  • hareThirdParty.hare-compress
  • hareThirdParty.hare-ev
  • hareThirdParty.hare-json
  • hareThirdParty.hare-png
  • hareThirdParty.hare-ssh
  • hareThirdParty.hare-toml
  • harec
  • haredo
  • haredo.man
  • himitsu
  • qbe
  • treecat
  • treecat.man

onemoresuza avatar Mar 01 '24 18:03 onemoresuza

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3553

nixos-discourse avatar Mar 02 '24 11:03 nixos-discourse

error: builder for '/nix/store/ws7l12hv17i4197kh5wiq60v24bcz04z-hare-aarch64-unknown-linux-gnu-0.24.0.drv' failed with exit code 1;
       last 10 log lines:
       > LD      .bin/hare
       > HARE    .bin/haredoc
       > .bin/hare: line 1: can't open �!��!�!@��Ң�B�A���: no such file
       > .bin/hare: line 2: can't open ���G: no such file
       > .bin/hare: line 3: @���Ң��B�A��ҡ��!�: not found
       > .bin/hare: line 3: can't open ��5�y��*q᧟�!S?q�T: no such file
       > : no such filee 4: can't open ���
       > .bin/hare: line 4: syntax error: unterminated quoted string
       > make: *** [Makefile:58: .bin/haredoc] Error 2
       > rm .harecache/dirs.s .harecache/hare_unparse.s .harecache/hare_lex.s .harecache/hash.s .harecache/strconv.s .harecache/path.s .harecache/unix.s .harecache/crypto_math.s .harecache/encoding_hex.s .harecache/getopt.s .harecache/fmt.s .harecache/strings.s .harecache/time_chrono.s .harecache/os_exec.s .harecache/sort_cmp.s .harecache/hare_parse.s .harecache/linux_vdso.s .harecache/time_date.s .harecache/errors.s .harecache/io.s .harecache/fs.s .harecache/cmd_hare_build.s .harecache/unix_signal.s .harecache/bufio.s .harecache/os.s .harecache/bytes.s .harecache/types_c.s .harecache/hare_ast.s .harecache/shlex.s .harecache/endian.s .harecache/crypto_sha256.s .harecache/memio.s .harecache/encoding_utf8.s .harecache/hare_module.s .harecache/time.s .harecache/math.s .harecache/cmd_hare.s .harecache/types.s .harecache/unix_tty.s .harecache/format_elf.s .harecache/ascii.s .harecache/linux.s .harecache/sort.s

Was this error log produced by the nix-build -A pkgsCross.aarch64-multiplatform.hare?

onemoresuza avatar Mar 05 '24 18:03 onemoresuza

yes

pbsds avatar Mar 05 '24 19:03 pbsds

@ofborg build pkgsCross.aarch64-multiplatform.hare

SuperSandro2000 avatar Mar 05 '24 20:03 SuperSandro2000

@pbsds, I am unable to reproduce the error encountered by both you and ofborg: Running nix-build -A pkgsCross.aarch64-multiplatform.hare on my x86_64 machine does build the derivation with an aarch64 executable as it's shown by running the file command on it:

[user@hostname: ~/nixpkgs] $ file ./result/bin/.hare-wrapped
./result/bin/.hare-wrapped: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

onemoresuza avatar Mar 05 '24 23:03 onemoresuza

Do you have boot.binfmt.emulatedSystems configured? That can affect the build and is regarded as impure/unreproducible

pbsds avatar Mar 06 '24 00:03 pbsds

Do you have boot.binfmt.emulatedSystems configured? That can affect the build and is regarded as impure/unreproducible

That was it!

I was guessing it was something related to it since both you and ofborg only failed on hare, which means that the cross compilation of qbe and harec had succeeded --- I've also tested building them individually after disabling binfmt.

Regarding the error itself, it occurs because haredoc, Hare's documentation tool, is being built with the cross-compiled hare binary instead of the one from the buildPlatform. Going to take a look at Void Linux's package, since they mentioned that they had to patch the Makefile in regards to haredoc to make cross-compilation work.

onemoresuza avatar Mar 06 '24 13:03 onemoresuza

I've patched hare so that it does not build haredoc, since the latter relies on the freshly build $(BINOUT)/hare, which makes cross-compilation not possible.

Now, haredoc is has its own package.

onemoresuza avatar Mar 06 '24 14:03 onemoresuza

@ofborg build pkgsCross.aarch64-multiplatform.hare

onemoresuza avatar Mar 06 '24 14:03 onemoresuza

Now both aarch64-linux and x86_64-linux succeed when building pkgsCross.aarch64-multiplatform.

onemoresuza avatar Mar 06 '24 14:03 onemoresuza

Great work!

pbsds avatar Mar 06 '24 18:03 pbsds

Thanks!

onemoresuza avatar Mar 06 '24 19:03 onemoresuza