Skip to content

go: support FreeBSD#328477

Merged
zowoq merged 1 commit intoNixOS:masterfrom
rhelmot:go-freebsd
Jul 20, 2024
Merged

go: support FreeBSD#328477
zowoq merged 1 commit intoNixOS:masterfrom
rhelmot:go-freebsd

Conversation

@rhelmot
Copy link
Contributor

@rhelmot rhelmot commented Jul 19, 2024

Description of changes

Simply marking support and re-downloading the hashes is enough to get everything to work. Tests were done by compiling syncthing.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
    • x86_64-freebsd
  • 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: golang Go is a high-level general purpose programming language that is statically typed and compiled. label Jul 19, 2024
@rhelmot rhelmot added the 6.topic: bsd Running or building packages on BSD label Jul 19, 2024
@Mic92
Copy link
Member

Mic92 commented Jul 19, 2024

Does this only work with native compilation?

This fails for me so far:

nix-build -A pkgsCross.x86_64-freebsd.go
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'go-x86_64-unknown-freebsd-1.22.5'
         whose name attribute is located at /home/joerg/git/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:334:7

       … while evaluating attribute 'CC_FOR_TARGET' of derivation 'go-x86_64-unknown-freebsd-1.22.5'
         at /home/joerg/git/nixpkgs/pkgs/development/compilers/go/1.22.nix:104:3:
          103|   # to be different from CC/CXX
          104|   CC_FOR_TARGET =
             |   ^
          105|     if isCross then

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: infinite recursion encountered
       at /home/joerg/git/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix:85:27:
           84|     // lib.optionalAttrs stdenv'.isDarwin { MKRELRO = "no"; }
           85|     // lib.optionalAttrs (stdenv'.cc.isClang or false) {
             |                           ^
           86|       HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
┏━ 1 Errors:
┃ error:
┃        … while calling the 'derivationStrict' builtin
┃          at <nix/derivation-internal.nix>:9:12:
┃             8|
┃             9|   strict = derivationStrict drvAttrs;
┃              |            ^
┃            10|
┃
┃        … while evaluating derivation 'go-x86_64-unknown-freebsd-1.22.5'
┃          whose name attribute is located at /home/joerg/git/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:334:7
┃
┃        … while evaluating attribute 'CC_FOR_TARGET' of derivation 'go-x86_64-unknown-freebsd-1.22.5'
┃          at /home/joerg/git/nixpkgs/pkgs/development/compilers/go/1.22.nix:104:3:
┃           103|   # to be different from CC/CXX
┃           104|   CC_FOR_TARGET =
┃              |   ^
┃           105|     if isCross then
┃
┃        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
┃
┃        error: infinite recursion encountered
┃        at /home/joerg/git/nixpkgs/pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix:85:27:
┃            84|     // lib.optionalAttrs stdenv'.isDarwin { MKRELRO = "no"; }
┃            85|     // lib.optionalAttrs (stdenv'.cc.isClang or false) {
┃              |                           ^
┃            86|       HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
┣━━━
┗━ ∑ ⚠ Exited with 1 errors reported by nix at 19:06:55 after 0s

@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 Jul 19, 2024
@rhelmot
Copy link
Contributor Author

rhelmot commented Jul 19, 2024

All of FreeBSD cross is broken pending #327815 but on my staging branch with all my pending PRs merged, I can confirm that I can build go programs for FreeBSD cross successfully :)

@rhelmot
Copy link
Contributor Author

rhelmot commented Jul 19, 2024

But yes, it also works native.

@zowoq zowoq merged commit 8a6b616 into NixOS:master Jul 20, 2024
@rhelmot rhelmot deleted the go-freebsd branch July 20, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: bsd Running or building packages on BSD 6.topic: golang Go is a high-level general purpose programming language that is statically typed and compiled. 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.

4 participants