Skip to content

Conversation

siraben
Copy link
Member

@siraben siraben commented May 15, 2025

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.

@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label May 15, 2025
@siraben
Copy link
Member Author

siraben commented May 15, 2025

@FliegendeWurst would you be able to take a peek? Would be greatly appreciated, since you seem to have familiarity with cross-compilation issues.

@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 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels May 15, 2025
@nix-owners nix-owners bot requested review from prusnak and stigtsp May 15, 2025 04:02
@FliegendeWurst
Copy link
Member

Found a few things, but they won't fix this issue yet.

https://github.com/micropython/micropython/blob/master/ports/unix/Makefile#L34

uname -s needs to be replaced, see pkgs/by-name/ke/kew/package.nix for an example.

https://github.com/micropython/micropython/blob/master/ports/unix/Makefile#L154

pkg-config needs to be prefixed as ${stdenv.cc.targetPrefix}pkg-config (multiple instances in that file)

@FliegendeWurst
Copy link
Member

The rather more annoying issue is that this project vendors dozens of third-party libraries. All of them at an outdated version, of course.

@FliegendeWurst
Copy link
Member

FliegendeWurst commented May 15, 2025

In fact you got "lucky" by cross-compiling for riscv, when I try to build for aarch64 I get a false-positive notification about a logic bug in mbedtls...

@FliegendeWurst
Copy link
Member

Anyway, let's get to the real issue. The project contains "mpy-cross", used to turn scripts into precompiled bytecode. This compiler runs as part of the build process. I imagine package users also use it. So, to perform a cross build, we must get mpy-cross from the native build.
To do so, it would be easiest to patch https://github.com/micropython/micropython/blob/master/mpy-cross/mpy_cross/__init__.py#L64 to return a reference to ${lib.getExe' buildPackages.micropython "mpy-cross"}

@siraben siraben force-pushed the micropython-cross branch from 039eb06 to e000884 Compare July 31, 2025 07:51
@siraben siraben requested a review from FliegendeWurst July 31, 2025 07:54
@siraben
Copy link
Member Author

siraben commented Jul 31, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 407238 --package pkgsCross.aarch64-multiplatform.micropython --package pkgsCross.riscv64.micropython
Commit: e0008848a138e7ed784052591c945568317ac816


x86_64-linux

✅ 2 packages built:
  • pkgsCross.aarch64-multiplatform.micropython
  • pkgsCross.riscv64.micropython

@siraben siraben force-pushed the micropython-cross branch from e000884 to 5eb42e1 Compare August 2, 2025 22:28
@prusnak
Copy link
Member

prusnak commented Aug 3, 2025

I will merge if @FliegendeWurst gives an ACK

@siraben siraben changed the title Start work on cross-compiling fixes for micropython micropython: fix cross Aug 3, 2025
@siraben
Copy link
Member Author

siraben commented Aug 12, 2025

@FliegendeWurst ping

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 15, 2025
@siraben siraben force-pushed the micropython-cross branch from 5eb42e1 to 86856d1 Compare August 20, 2025 20:12
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 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. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants