Skip to content

Build failure: nodejs cross compiling for raspberry pi armv6l #319036

Closed

Description

@jue89

Steps To Reproduce

Steps to reproduce the behavior on current master:

nix build github:NixOS/nixpkgs/14391a5980458824bbe541d48fb1e5c47f662bc4#legacyPackages.x86_64-linux.pkgsCross.raspberryPi.nodejs

Build log

error: builder for '/nix/store/7fswdflambmfdd759zvrjwrjkqpndlsy-nodejs-armv6l-unknown-linux-gnueabihf-20.12.2.drv' failed with exit code 2;
       last 10 log lines:
       >                  from /nix/store/14c6s4xzhy14i2b05s00rjns2j93gzz4-gcc-13.2.0/include/c++/13.2.0/atomic:41,
       >                  from ../deps/v8/src/libplatform/default-job.h:8,
       >                  from ../deps/v8/src/libplatform/default-job.cc:5:
       > /nix/store/fwh4fxd747m0py3ib3s5abamia9nrf90-glibc-2.39-52-dev/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-32.h: No such file or directory
       >     7 | # include <gnu/stubs-32.h>
       >       |           ^~~~~~~~~~~~~~~~
       > compilation terminated.
       > make[1]: *** [tools/v8_gypfiles/v8_libplatform.host.mk:165: /build/node-v20.12.2/out/Release/obj.host/v8_libplatform/deps/v8/src/libplatform/default-job.o] Error 1
       > rm fab9cb8c89b21d255a082353fbb474ab1680b6f2.intermediate fb66f3594c458ae33beb8e684d290a388f861f36.intermediate
       > make: *** [Makefile:134: node] Error 2
       For full logs, run 'nix log /nix/store/7fswdflambmfdd759zvrjwrjkqpndlsy-nodejs-armv6l-unknown-linux-gnueabihf-20.12.2.drv'.

Additional context

Notify maintainers

@cillianderoiste
@cko
@aduh95

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.91, NixOS, 23.11 (Tapir), 23.11.20240525.9d29cd2`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a 👍 reaction to issues you find important.

Activity

  1. jue89 commented on Jun 13, 2024

    @jue89
    ContributorAuthor

    I hacked around this problem:

        preBuild = lib.optionalString isCross ''
          mkdir deps/v8/gnu
          touch deps/v8/gnu/stubs-32.h
        '';

    This actually seems to work!

    But now I run into a new Problem:

    /nix/store/bgcaxhhxswzvmxjbbgvvaximm5hwghz1-binutils-2.41/bin/ld: /build/node-v20.12.2/out/Release/obj.host/deps/simdutf/libsimdutf.a: error adding symbols: archive has no index; run ranlib to add one
    collect2: error: ld returned 1 exit status
    

    Has anyone an idea how to fix this?

  2. tie commented on Jul 15, 2024

    @tie
    Member

    I think PR #220204 addresses this issue.

  3. tie commented on Jul 17, 2024

    @tie
    Member

    FWIW, for some reason raspberryPi is defined as gcc.fpu = "vfp" instead of vfpv2 in Nixpkgs.

    https://wiki.debian.org/RaspberryPi#:~:text=The%20CPU%20in%20the%20Raspberry%20Pi,VFP2%29

    I don’t think Node.js supports (armv6, vfp) combination (see nodejs/node#44357).

    I’m not familiar with Raspberry Pi hardware, but if it supports vfpv2, I think it makes sense to update the platform preset:

    fpu = "vfp";

  4. jue89 commented on Jul 18, 2024

    @jue89
    ContributorAuthor
  5. tie commented on Jul 18, 2024

    @tie
    Member

    I experimented with this a bit yesterday and I think setting gcc.arch = "armv6kz" alone should be enough for Node.js (though I also had gcc.fpu = "vfpv2" set so I can’t say that with 100% confidence). Note that Node.js needs yield instructions that are not available for armv6 and require at least armv6k (see https://redd.it/144sh53). According to Raspberry Pi specifications on the Wikipedia article, it is ARMv6Z (K implied as far as I understand). See also https://reviews.llvm.org/D14568 and nodejs/node#44357.

    W.r.t. your comment #327778 (comment) (i.e. building Node.js for pkgsCross.raspberryPi with updated gcc arch/fpu), use #327653. The current Node.js derivation always cross-compiles, but that doesn’t work well for platforms with different bitness (e.g. AArch64 to AArch32). The PR in question makes it so that we don’t cross-compile and instead use an emulator when we need to run a few tools built for the host platform.

  6. jue89 commented on Jul 18, 2024

    @jue89
    ContributorAuthor

    Sry - I'm not an expert ... so building directly for the RPi's architecture using qemu / binfmt should create a working binary, right? I'll give this a try but I'll take some hours (or maybe days?) ;-)

  7. tie commented on Jul 18, 2024

    @tie
    Member

    It should take a few hours or so on a modern multi-core computer (though the PR is targeting staging and there is a bit of bottlenecking in the bootstrap process). E.g. something like

    let
      system = builtins.currentSystem;
      lib = import ./lib;
      nixpkgsFun = import ./.;
      pkgs = nixpkgsFun {
        localSystem = { inherit system; };
        crossSystem = lib.systems.examples.raspberryPi // {
          gcc = {
            arch = "armv6kz";
            fpu = "vfpv2";
          };
        };
      };
    in
    pkgs.nodejs_22

    (at the root of Nixpkgs repository checkout with #327653 applied)

  8. jue89 commented on Jul 18, 2024

    @jue89
    ContributorAuthor

    Ah and it'll use qemu for compiling nodejs?

    Nice! Thank you a lot :)

  9. tie commented on Jul 18, 2024

    @tie
    Member

    Ah and it'll use qemu for compiling nodejs?

    Yes, stdenv.hostPlatform.emulator buildPackages to be exact (that happens to be user mode QEMU when building Linux → Linux).

  10. tie commented on Aug 13, 2024

    @tie
    Member

    Should be fixed in #327653, but I’ll keep the issue open until we get a decision on #327778.

  11. jue89 commented on Sep 19, 2024

    @jue89
    ContributorAuthor
    $ nix build github:NixOS/nixpkgs/99dc8785f6a0adac95f5e2ab05cc2e1bf666d172#pkgsCross.raspberryPi.nodejs
    $ file ./result/bin/node
    ./result/bin/node: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /nix/store/ba6dqdyljyj5hjny4z9dpxfbwmlhd2pn-glibc-armv6l-unknown-linux-gnueabihf-2.39-52/lib/ld-linux-armhf.so.3, for GNU/Linux 3.10.0, not stripped
    $ ./result/bin/node --version
    v20.17.0
    

    I'd say this issue has been solved! Thank you all for your effort to fix the build issue :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions