Skip to content

mojo: init at unstable-2026-08-21 - #557600

Open
hnkNkm wants to merge 4 commits into
NixOS:masterfrom
hnkNkm:mojo-init
Open

hnkNkm wants to merge 4 commits into
NixOS:masterfrom
hnkNkm:mojo-init

Conversation

@hnkNkm

@hnkNkm hnkNkm commented Aug 29, 2026

Copy link
Copy Markdown

Summary

Changes

  • pkgs/by-name/mo/mojo/package.nix
    • Builds the compiler and stdlib with --config=build-mojo --compilation_mode=opt.
    • C/C++ toolchain is nixpkgs LLVM 22 and glibc (not Modular's S3 clang / Ubuntu jammy sysroot). llvm-ifs is nixpkgs LLVM as well.
    • Host Bazel is nixpkgs bazel_9. Host Python is nixpkgs CPython (local_runtime plus install_only-style tarballs for python.toolchain()).
    • Public mojo is a normal makeWrapper (no buildFHSEnv). mojo-full uses the Nix glibc PT_INTERP.
    • passthru.tests.hello and passthru.tests.interpreter (Nix glibc PT_INTERP, stripped, no llvm-ifs runfiles).
    • Follow-on unwrapped derivation strips DWARF, hardlinks duplicate Bazel runfiles, and sets disallowedReferences on the fat compile output.
  • pkgs/by-name/mo/mojo/{clang-linux,llvm-ifs-nix,sysroot-nix,python-standalone-nix}.nix
    • Layout adapters so Modular's Bazel repos resolve against nixpkgs.
  • maintainers/maintainer-list.nix
    • Add hnknkm.

Testing

Verified on x86_64-linux (staging flake using this derivation):

nix build .#checks.x86_64-linux.hello
nix build .#checks.x86_64-linux.interpreter
  • mojo --version → Mojo 1.1.0.dev0 (deadbeef)

  • hello.mojo prints Hello, Mojo

  • mojo-full PT_INTERP is Nix glibc (/nix/store/...-glibc-.../lib/ld-linux-x86-64.so.2), not /lib64

  • mojo-full is stripped; link-time llvm-ifs is not in runfiles

  • Compile of //KGEN:mojo was ~3h38m (11189 actions) on x86_64-linux. The public unwrapped output is a follow-on derivation that strips DWARF and hardlinks duplicate Bazel runfiles (about 631 MiB on disk, ~1.0 GiB closure). The compile derivation uses requiredSystemFeatures = [ "big-parallel" ]. ofBorg may not finish a full compile.

Notes

  • x86_64-linux only. GPU/MAX/CUDA is out of scope.
  • Release tag max/v26.5.0 predates compiler OSS, so this pins post-OSS commit 577b6b839efa11d750cdf264f1094954cc7d5b25 as unstable-2026-08-21.
  • meta.sourceProvenance includes binaryNativeCode because the Bazel vendor tarball still contains host tools used during analysis (crashpad, buildifier, Go/Node/uv). The compiler C/C++ toolchain itself is nixpkgs LLVM/glibc; GPU blobs such as nvshmem are not vendored for //KGEN:mojo.
  • clang 22 needs ulimit -s unlimited on the driver wrappers and -O0 for NativePDB (SIGSEGV at -O2).

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • aarch64-darwin
  • Tested, as applicable:
    • NixOS tests in nixos/tests.
    • Package tests at passthru.tests.
    • Tests in lib/tests or pkgs/test for functions and "core" functionality.
  • Ran nixpkgs-review on this PR.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.
  • Follows the automation/AI policy.

Assisted by Cursor Grok 4.6 when drafting the derivation and this summary. I built the package and ran the tests above.

hnkNkm added 2 commits August 29, 2026 13:09
Assisted-by: Cursor Grok 4.6
Assisted-by: Cursor Grok 4.6
@nixpkgs-ci nixpkgs-ci Bot added 8.has: package (new) This PR adds a new package 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 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. 12.first-time contribution This PR is the author's first one; please be gentle! 9.needs: reviewer This PR currently has no reviewers requested and needs attention. llm-assisted Contributions that include code generation with LLMs labels Aug 29, 2026
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` and removed 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. labels Aug 29, 2026
@hnkNkm
hnkNkm marked this pull request as draft August 31, 2026 02:00
@nixpkgs-ci nixpkgs-ci Bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Aug 31, 2026
Assisted-by: Cursor Grok 4.6
@hnkNkm
hnkNkm marked this pull request as ready for review August 31, 2026 05:30
@nixpkgs-ci nixpkgs-ci Bot added the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Aug 31, 2026
@samuela samuela mentioned this pull request Sep 2, 2026
13 tasks
@hnkNkm

hnkNkm commented Sep 4, 2026

Copy link
Copy Markdown
Author

@samuela I looked into the question you raised on #559250 — whether GPU/MAX could be added to this source build.

It cannot, at least not from the public Modular tree. The MAX C++ runtime (MLRT / DeviceContext) is not published, and the public Bazel API forces accelerator support off. On the compiler this PR produces, --print-supported-accelerators is empty, --target-accelerator nvidia:sm_75 --emit asm does not emit PTX, and from max.gpu.host import DeviceContext fails.

So I think #559250 is the better first pkgs.mojo: it is the 1.0.0 release, covers both Linux architectures, and actually ships CUDA/MAX. I am fine with this PR not taking the mojo attribute. Happy to leave it open as a free CPU-only compiler if that is useful, or close it if reviewers would rather have a single package.

@samuela

samuela commented Sep 6, 2026

Copy link
Copy Markdown
Member

It cannot, at least not from the public Modular tree. The MAX C++ runtime (MLRT / DeviceContext) is not published, and the public Bazel API forces accelerator support off. On the compiler this PR produces, --print-supported-accelerators is empty, --target-accelerator nvidia:sm_75 --emit asm does not emit PTX, and from max.gpu.host import DeviceContext fails.

Ah, that's a bummer esp considering the press around the open source release. I was not aware of this.

So I think #559250 is the better first pkgs.mojo: it is the 1.0.0 release, covers both Linux architectures, and actually ships CUDA/MAX. I am fine with this PR not taking the mojo attribute. Happy to leave it open as a free CPU-only compiler if that is useful, or close it if reviewers would rather have a single package.

Another option would be to do a mojo and mojo-bin split. We previously did this (maybe still do?) for jaxlib and tensorflow and it worked smoothly and encouraged the source builds to eventually reach parity with the binary builds. Would you be interested in such a setup?

@hnkNkm

hnkNkm commented Sep 9, 2026

Copy link
Copy Markdown
Author

@samuela Yes, a mojo / mojo-bin split works for me.

I would keep this PR as the source-built mojo: free, CPU-only, x86_64-linux. #559250 would be the better mojo-bin: the 1.0.0 wheels, both Linux architectures, and CUDA/MAX.

One caveat on the jaxlib/tensorflow analogy: source will not grow GPU/MAX until Modular publishes the closed pieces (MLRT / device codegen). That is an upstream availability gap, not something this derivation can close by packaging work. Until then the two packages would stay complementary rather than on a path to parity.

Happy to keep maintaining the source package on that basis.

@samuela

samuela commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

sg, enabled github actions on this pr and renamed derivation to mojo-bin in #559250

@nixpkgs-ci nixpkgs-ci Bot added the 7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! label Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: package (new) This PR adds a new package 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 10.rebuild-darwin: 0 This PR does not cause any packages 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. 12.first-time contribution This PR is the author's first one; please be gentle! llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants