Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: tinygo #286566

Closed
marcofeltmann opened this issue Feb 5, 2024 · 8 comments
Closed

Build failure: tinygo #286566

marcofeltmann opened this issue Feb 5, 2024 · 8 comments
Labels
0.kind: build failure A package fails to build

Comments

@marcofeltmann
Copy link

If this is a dup I was unable to find it.

Steps To Reproduce

Steps to reproduce the behavior:

  • I did have the tinygo package in my home-manager configuration literally forever and simply ran nixos-rebuild switch --upgrade some day end of January 2024 to see it fail.

Build log

The interesting part before build ends with failure is:

src/device/sam/atsamv71q21.go
src/device/sam/atsamv71q21b.go
buildPhase completed in 42 seconds
Running phase: checkPhase
sh: line 1: node: command not found
make: which: No such file or directory
/build/source/build/tinygo version
tinygo version 0.30.0 linux/amd64 (using go version go1.21.6 and LLVM version 16.0.6)
/build/source/build/tinygo targets > /dev/null
# regression test for #2892
cd tests/testing/recurse && (/build/source/build/tinygo test ./... > recurse.log && cat recurse.log && test $(wc -l < recurse.log) = 2 && rm recurse.log)
error: could not find build ID in /build/source/build/tinygo
error: could not find build ID in /build/source/build/tinygo
make: *** [Makefile:454: smoketest] Error 1
error: builder for '/nix/store/jsr85p2ap80yqw20ix25nh5mihcf7jy9-tinygo-0.30.0.drv' failed with exit code 2
error: 1 dependencies of derivation '/nix/store/4vr45112172mcy8sxd833r3mck0xrr2s-user-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/5a5cpai6p7lbwgy29wn9wf41i5a9fslx-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/cw2fw2g37hlg8jkrbvic5x5b8dnv65rj-nixos-system-marco-framework-13-24.05pre579329.e92b60158819.drv' failed to build

So build itself worked, checkPhase did find neither node nor which and afterwards some build IDs went missing.

Additional context

It run until ~January 2024 or so, so I heavily guess it's not the package but something else.

If I simply try nix-build -E 'with import <nixpkgs> {}; callPackage /code/world/nixpkgs/pkgs/development/compilers/tinygo/d efault.nix {}' it fails with a complete different reason:

error:
       … while calling the 'abort' builtin

         at /nix/store/himbcd8dmkdwfd14vbnsasafhl3yxl5v-nixos/nixos/lib/customisation.nix:210:13:

          209|        # which is especially relevant with allowAliases = false
          210|        else abort "lib.customisation.callPackageWith: ${error}";
             |             ^
          211|

       error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "wasi-libc" at /code/world/nixpkgs/pkgs/development/compilers/tinygo/default.nix:15, did you mean "wasilibc"?'

It looks like wasilibc was updated to v21 for llvm17 support a few weeks ago.

I'm using "testing" Home Manager from https://github.com/nix-community/home-manager/archive/master.tar.gz, if that's of any interest.

Notify maintainers

@Madouura @muscaln

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.76, NixOS, 24.05 (Uakari), 24.05pre579329.e92b60158819`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@marcofeltmann marcofeltmann added the 0.kind: build failure A package fails to build label Feb 5, 2024
@marcofeltmann
Copy link
Author

Somewhat finished my own first private nixpkg and NixOS module today, so I'm stumbling around that issue on my own for a minute or two.

If I follow the suggestion about Did you mean "wasilibc"? it still won't build via nix-build, but for a different reason:

♥ nix-build -E 'with import <nixpkgs> {}; callPackage /code/world/nixpkgs/pkgs/development/compilers/tinygo/default.nix {}'
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'tinygo-0.30.0'
         whose name attribute is located at /nix/store/himbcd8dmkdwfd14vbnsasafhl3yxl5v-nixos/nixos/pkgs/stdenv/generic/make-derivation.nix:352:7

       … while evaluating attribute 'configurePhase' of derivation 'tinygo-0.30.0'

         at /nix/store/himbcd8dmkdwfd14vbnsasafhl3yxl5v-nixos/nixos/pkgs/build-support/go/module.nix:162:5:

          161|
          162|     configurePhase = args.configurePhase or (''
             |     ^
          163|       runHook preConfigure

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

       error: Package ‘wasilibc-21’ in /nix/store/himbcd8dmkdwfd14vbnsasafhl3yxl5v-nixos/nixos/pkgs/development/libraries/wasilibc/default.nix:62 is not available on the requested hostPlatform:
         hostPlatform.config = "x86_64-unknown-linux-gnu"
         package.meta.platforms = [
           "wasm64-wasi"
           "wasm32-wasi"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

Allowing unsupported system will lead to later assertion errors in the mentioned wasilibc package.

If you could give me a hint on how to reproducably build the tinygo pkg locally I'd love to investigate further. 😸

@Aleksanaa
Copy link
Member

nix-build -E 'with import <nixpkgs> {}; callPackage default.nix {}' is anti-pattern and not guaranteed to work.

@Aleksanaa
Copy link
Member

@marcofeltmann
Copy link
Author

@Aleksanaa I really appreciate hints on "you're doing it wrong", and it would be very helpful to have some additional "this is one way you can do it right".

If I just merge the referenced commit I still need some advice on verifying it locally.

@Aleksanaa
Copy link
Member

nix-build -A tinygo or nix build .#tinygo. The package is called from pkgs/top-level/all-packages.nix, and you can find callPackage arguments there. If arguments are not taken from pkgs without these renaming or modifications, you can not invoke callPackage directly.

The commit points to the problem, not fixing it. To include the package without needing to fix the test failure, you can use (tinygo.override { tinygoTests = []; }) or more generally (tinygo.overrideAttrs (prev: { doCheck = false; })).

However, it's also not advised to add a compiler to your home configuration. Instead, use tools like nix-direnv, devenv or devshell.

@marcofeltmann
Copy link
Author

Thank you for your enlightening insights.
I managed to achieve the same behavior via nix-build -A tinygo inside this repo and it feels like an issue in the Makefile.

I'll fork and fiddle on the TinyGo for this one, so it should be self-curing as far as nixpkgs is concerned.

@aykevl
Copy link
Contributor

aykevl commented Feb 7, 2024

The next TinyGo release should fix a lot of these issues because now we're actually testing Nix support in CI (through flakes, but still). Take a look at this PR for example which I'll make ready once the coming release happens:
#262346

These are the PRs that added Nix support to TinyGo, they might be worth backporting if you don't want to wait until the next release:
tinygo-org/tinygo#3948
tinygo-org/tinygo#3952

@muscaln
Copy link
Contributor

muscaln commented Mar 5, 2024

Fixed with #262346

@muscaln muscaln closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants