Skip to content

Get julia working on aarch64-darwin #317900

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

Open
wants to merge 39 commits into
base: master
Choose a base branch
from

Conversation

MilesCranmer
Copy link
Contributor

@MilesCranmer MilesCranmer commented Jun 7, 2024

Description of changes

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/)
  • 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.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jun 7, 2024
@github-actions github-actions bot added the 6.topic: julia Julia is a high-level, high-performance dynamic language for technical computing. label Jun 7, 2024
@NixOSInfra NixOSInfra added the 12.first-time contribution This PR is the author's first one; please be gentle! label Jun 7, 2024
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Jun 7, 2024
@ofborg ofborg bot requested review from thomasjm and NickCao June 7, 2024 04:35
@ofborg ofborg bot added 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. labels Jun 7, 2024
@thomasjm
Copy link
Contributor

thomasjm commented Jun 7, 2024

This looks cool! Does julia.withPackages work?

@ofborg ofborg bot requested a review from thomasjm June 7, 2024 06:15
@MilesCranmer
Copy link
Contributor Author

MilesCranmer commented Jun 7, 2024

This looks cool! Does julia.withPackages work?

I'm new to nix (I'm learning it to make building Julia easier :)). How should I try this syntax with this version of the build files?

@ofborg ofborg bot added 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. and removed 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. 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 Jun 8, 2024
@NickCao
Copy link
Member

NickCao commented Jun 9, 2024

@ofborg build julia_19 julia_110

@MilesCranmer
Copy link
Contributor Author

I finally figured out where codesign is; it is in darwin.sigtool.

@MilesCranmer
Copy link
Contributor Author

@ofborg build julia_19 julia_110

@MilesCranmer
Copy link
Contributor Author

What is the default make target that nix runs? I think it's trying to build the mac app or something...

The only place the current error could come from is contrib/mac/app/Makefile within the Julia source, which is for building the dmg file.

 529    app:
 530   │     $(MAKE) -C contrib/mac/app
 531   │     @mv contrib/mac/app/$(JULIA_BINARYDIST_FILENAME).dmg $(BUILDROOT)

@NickCao
Copy link
Member

NickCao commented Jun 9, 2024

What is the default make target that nix runs?

Just the default target, as if running make with no arguments.

@MilesCranmer
Copy link
Contributor Author

Thanks. Very odd. This is the current error it's stuck at:

nix run --impure --expr 'with import ./. {}; ((julia_19.withPackages) ["Plots"])'
error: builder for '/nix/store/8pwim6gghwada1n3y84bnm1lip1admc2-julia-1.9.4.drv' failed with exit code 2;
       last 25 log lines:
       > rm -f /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/julia/stdlib/v`cut -d. -f1-2 < /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/VERSION`/*/build-configured
       > rm -f /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/julia/stdlib/v`cut -d. -f1-2 < /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/VERSION`/*/build-compiled
       > rm -f /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/julia/stdlib/v`cut -d. -f1-2 < /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/VERSION`/*/build-checked
       > # Copy in beautiful new man page
       > /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/contrib/install.sh 644 /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/usr/share/man/man1/julia.1 /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/man/man1/
       > # Copy .desktop file
       > mkdir -p /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/applications/
       > /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/contrib/install.sh 644 /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/contrib/julia.desktop /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/applications/
       > # Install appdata file
       > mkdir -p /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/appdata/
       > /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/contrib/install.sh 644 /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/contrib/julia.appdata.xml /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/share/appdata/
       > # Update RPATH entries and JL_SYSTEM_IMAGE_PATH if ../lib/julia != ../lib/julia
       > # Set rpath for libjulia-internal, which is moving from `../lib` to `../lib/julia`.
       > install_name_tool -add_rpath @loader_path/../ /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/lib/julia/libjulia-internal.dylib
       > install_name_tool -add_rpath @loader_path/../ /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/lib/julia/libjulia-codegen.dylib
       > # Fix rpaths for dependencies. This should be fixed in BinaryBuilder later.
       > # Next, overwrite relative path to libjulia-internal in our loader if $(LOADER_BUILD_DEP_LIBS) != $(LOADER_INSTALL_DEP_LIBS)
       > MSYS2_ARG_CONV_EXCL='*' /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/usr/tools/stringreplace $(strings -t x - '/nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/lib/libjulia.1.9.dylib' | grep "libgcc_s.1.1.dylib:libopenlibm.dylib:@:@libjulia-internal.1.dylib:@libjulia-codegen.1.dylib:$" | awk '{print $1;}') "julia/libgcc_s.1.1.dylib:julia/libopenlibm.dylib:@:@julia/libjulia-internal.1.dylib:@julia/libjulia-codegen.1.dylib:" 255 "/nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/lib/libjulia.1.9.dylib"
       > # Codesign the libjulia we just modified
       > /private/tmp/nix-build-julia-1.9.4.drv-0/julia-1.9.4/contrib/codesign.sh "" "/nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/lib/libjulia.1.9.dylib"
       > Codesigning with identity -
       > Codesigning /nix/store/i7yl2z44xy4dsnwxshhnamixizhd82j0-julia-1.9.4/lib/libjulia.1.9.dylib...
       > The following arguments were not expected: --deep --timestamp -vvv --option=runtime
       > Run with --help for more information.
       > make: *** [Makefile:292: install] Error 109
       For full logs, run 'nix log /nix/store/8pwim6gghwada1n3y84bnm1lip1admc2-julia-1.9.4.drv'.
error: 1 dependencies of derivation '/nix/store/x4cwrwrpbvdd00zbncs75fgdw4w7a7qf-julia-package-closure.yml.drv' failed to build
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'julia-1.9.4-env'
         whose name attribute is located at /Users/mcranmer/PermaDocuments/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:331:7

       … while evaluating attribute 'artifactsNix' of derivation 'julia-1.9.4-env'
         at /Users/mcranmer/PermaDocuments/nixpkgs/pkgs/development/julia-modules/default.nix:181:11:
          180|   inherit minimalRegistry;
          181|   inherit artifactsNix;
             |           ^
          182|   inherit overridesJson;

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

       error: 1 dependencies of derivation '/nix/store/q6zxqwi04vi67qcsjj6yh6jwzcbakwqg-julia-sources.nix.drv' failed to build

For that specific error, the only place it could come from is (via https://github.com/search?q=repo:JuliaLang/julia%20/codesign.*option%3Druntime/&type=code) here:

https://github.com/JuliaLang/julia/blob/8a7d8f444ace6156fb73ce5a23ade9ff692fb678/contrib/mac/app/Makefile#L61

Which means it's trying to build the dmg file. Is that expected/desired? I would have thought it would just build the binary?

@NickCao
Copy link
Member

NickCao commented Jun 9, 2024

What is the default make target that nix runs?

Just the default target, as if running make with no arguments.

The correct location is https://github.com/JuliaLang/julia/blob/v1.9.4/contrib/codesign.sh, github search only works with the master branch. Does this also affect 1.10?

@MilesCranmer
Copy link
Contributor Author

Oops, indeed that looks like the right one. Forgot I was testing the build on 1.9.4.

Alright I'll see if I can add a patch..

@MilesCranmer
Copy link
Contributor Author

@ofborg build julia_19 julia_110

@MilesCranmer
Copy link
Contributor Author

MilesCranmer commented Jun 9, 2024

Alright, now it gets all the way to building and installing which succeed. I can verify that Julia also downloads the whole of the package registry to the desired folder. However, the actual julia_19.withPackages fails due to a SIGKILL:

Resolving Julia packages with the following inputs
Julia: /nix/store/jh288dvjm6wwpchv1w424ylhzy6bq4iy-julia-1.9.4
Registry: /nix/store/gxv9wz6knd4a651ydnn98bilk76anl1d-source
/private/tmp/nix-build-julia-package-closure.yml.drv-0/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 124: 52453 Killed: 9               julia -e 'import Pkg
Pkg.Registry.add(Pkg.RegistrySpec(path="/nix/store/gxv9wz6knd4a651ydnn98bilk76anl1d-source"))
...

Is that an issue elsewhere or could it mean the codesigning is incorrect now (and so the OS kills it)? Not sure what else to try.

@thomasjm
Copy link
Contributor

I've never seen a SIGKILL issue before. Can you confirm basic Julia functionality works before trying .withPackages?

@MilesCranmer
Copy link
Contributor Author

MilesCranmer commented Jun 10, 2024

It's weird, it goes through all the Julia tests in make test. I can see the LinearAlgebra tests running fine.

Although I will note I can't actually start the Julia binary stored in ./result/bin/julia from my regular terminal – I get the SIGKILL issue there too. I assumed it was due to not understanding nix and maybe from there being missing things on my LD_PRELOAD or something (since the tests within the build run fine). But now I'm not sure.

@thomasjm
Copy link
Contributor

I don't have a Mac with Nix to test on, but some googling indicates that OS X may kill processes with improper code signing--it sounds like you might see something like EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid)).

To debug further maybe you want to use something like dtruss. Maybe you can also try turning off "System Integrity Protection"?

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 2, 2025
@samestep
Copy link
Contributor

@MilesCranmer what is the situation for this? I'm also interested in having aarch64-darwin-compatible Julia in Nixpkgs. I see the same behavior you described with ./result/bin/julia being immediately killed, though.

Judging from the lack of activity in this thread, I'm guessing you ended up giving up on Nix for Julia?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 16, 2025
@MilesCranmer
Copy link
Contributor Author

MilesCranmer commented May 16, 2025

@samestep the state is as it currently sits in the PR. Feel free to take over! I think it's certainly doable to fix the issues. I simply no longer needed this package for my particular use-case and then other time pressures took priority. i.e., I won't have a chance to make progress on this for the foreseeable future.

And yes I think the issue about ./result/bin/julia being killed is simply due to code signing. I have seen the same issue with installing with juliaup install pr{number} since those aren't signed. I think I fixed it with codesign --force --sign on mac

@nixpkgs-ci nixpkgs-ci bot removed the 12.first-time contribution This PR is the author's first one; please be gentle! label Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: darwin Running or building packages on Darwin 6.topic: julia Julia is a high-level, high-performance dynamic language for technical computing. 8.has: clean-up This PR removes packages or removes other cruft 8.has: package (new) This PR adds a new package 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants