Skip to content

lib.systems: Add arm-embedded-nano#392204

Merged
mkg20001 merged 1 commit intoNixOS:masterfrom
RossSmyth:ArmNano
Apr 5, 2025
Merged

lib.systems: Add arm-embedded-nano#392204
mkg20001 merged 1 commit intoNixOS:masterfrom
RossSmyth:ArmNano

Conversation

@RossSmyth
Copy link
Contributor

Newlib-nano variant of the arm-embedded stdenv.

Reasoning:

#385908 was denied because of pkgsCross. But the problem is that the arm-embedded pkgsCross toolchain does not use newlib nano. It would be nice to fill the gap and have a toolchain that is cached that has newlib-nano for embedded developers (like me).

I would prefer that it is a multilib, but it seems the multilib cross toolchains are broken, and an assert was added recently to ensure they aren't added in #380325.

#51907
#111321

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.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.

Newlib-nano variant of the arm-embedded stdenv.
@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label Mar 22, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Mar 22, 2025
Copy link
Member

@RossComputerGuy RossComputerGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkgsCross.arm-embedded-nano.stdenv builds fine on aarch64-linux. However, pkgsCross.arm-embedded-nano.hello fails:

hello> checking whether the C compiler works... no
hello> configure: error: in `/build/hello-2.12.1':
hello> configure: error: C compiler cannot create executables
hello> See `config.log' for more details

In config.log:

/nix/store/3v0cyab13cj668v1ywh2ywf9sxh82fzc-arm-none-eabi-binutils-2.43.1/bin/arm-none-eabi-ld: warning: -z relro ignored
/nix/store/3v0cyab13cj668v1ywh2ywf9sxh82fzc-arm-none-eabi-binutils-2.43.1/bin/arm-none-eabi-ld: /nix/store/hrxwq72pyk4pnyprgi4n9a94syh69wqw-newlib-arm-none-eabi-4.5.0.20241231
/arm-none-eabi/lib/libc.a(libc_a-exit.o): in function `exit':
/build/newlib-4.5.0.20241231/arm-none-eabi/newlib/../.././newlib/libc/stdlib/exit.c:65:(.text+0x3c): undefined reference to `_exit'
/nix/store/3v0cyab13cj668v1ywh2ywf9sxh82fzc-arm-none-eabi-binutils-2.43.1/bin/arm-none-eabi-ld: /nix/store/hrxwq72pyk4pnyprgi4n9a94syh69wqw-newlib-arm-none-eabi-4.5.0.20241231
/arm-none-eabi/lib/libc.a(libc_a-closer.o): in function `_close_r':
/build/newlib-4.5.0.20241231/arm-none-eabi/newlib/../.././newlib/libc/reent/closer.c:47:(.text+0x24): undefined reference to `_close'
/nix/store/3v0cyab13cj668v1ywh2ywf9sxh82fzc-arm-none-eabi-binutils-2.43.1/bin/arm-none-eabi-ld: /nix/store/hrxwq72pyk4pnyprgi4n9a94syh69wqw-newlib-arm-none-eabi-4.5.0.20241231
/arm-none-eabi/lib/libc.a(libc_a-lseekr.o): in function `_lseek_r':
/build/newlib-4.5.0.20241231/arm-none-eabi/newlib/../.././newlib/libc/reent/lseekr.c:49:(.text+0x30): undefined reference to `_lseek'
/nix/store/3v0cyab13cj668v1ywh2ywf9sxh82fzc-arm-none-eabi-binutils-2.43.1/bin/arm-none-eabi-ld: /nix/store/hrxwq72pyk4pnyprgi4n9a94syh69wqw-newlib-arm-none-eabi-4.5.0.20241231
/arm-none-eabi/lib/libc.a(libc_a-readr.o): in function `_read_r':
/build/newlib-4.5.0.20241231/arm-none-eabi/newlib/../.././newlib/libc/reent/readr.c:49:(.text+0x30): undefined reference to `_read'
/nix/store/3v0cyab13cj668v1ywh2ywf9sxh82fzc-arm-none-eabi-binutils-2.43.1/bin/arm-none-eabi-ld: /nix/store/hrxwq72pyk4pnyprgi4n9a94syh69wqw-newlib-arm-none-eabi-4.5.0.20241231
/arm-none-eabi/lib/libc.a(libc_a-writer.o): in function `_write_r':
/build/newlib-4.5.0.20241231/arm-none-eabi/newlib/../.././newlib/libc/reent/writer.c:49:(.text+0x30): undefined reference to `_write'
/nix/store/3v0cyab13cj668v1ywh2ywf9sxh82fzc-arm-none-eabi-binutils-2.43.1/bin/arm-none-eabi-ld: /nix/store/hrxwq72pyk4pnyprgi4n9a94syh69wqw-newlib-arm-none-eabi-4.5.0.20241231
/arm-none-eabi/lib/libc.a(libc_a-sbrkr.o): in function `_sbrk_r':
/build/newlib-4.5.0.20241231/arm-none-eabi/newlib/../.././newlib/libc/reent/sbrkr.c:51:(.text+0x24): undefined reference to `_sbrk'
collect2: error: ld returned 1 exit status

@RossSmyth
Copy link
Contributor Author

RossSmyth commented Mar 26, 2025

When using newlib-nano those symbols are not defined, and are meant to be user-defined (or not defined at all). The use case is generally something like defining them to output to a serial port when building a program for a microcontroller. So that is expected.

@RossSmyth
Copy link
Contributor Author

I double checked just to make sure, I tested it before with

crossPkgs = import nixpkgs {
    localSystem = pkgs.stdenv.buildPlatform;
    crossSystem = {
        config = "arm-none-eabi";
        libc = "newlib-nano";
    };
};

and pkgsCross.arm-embedded-nano from this PR is able to build the firmware I work on that uses newlib-nano.

@RossSmyth
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 392204


x86_64-linux

⏩ 2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
✅ 1 package built:
  • nixpkgs-manual

@wegank wegank added 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. 12.approvals: 1 This PR was reviewed and approved by one person. labels Mar 26, 2025
@mkg20001 mkg20001 merged commit 1000bcd into NixOS:master Apr 5, 2025
31 checks passed
@RossSmyth RossSmyth deleted the ArmNano branch April 9, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants