Skip to content

Add musl libc - #557

Closed
lrishi wants to merge 1 commit into
gominimal:mainfrom
lrishi:main
Closed

Add musl libc#557
lrishi wants to merge 1 commit into
gominimal:mainfrom
lrishi:main

Conversation

@lrishi

@lrishi lrishi commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds build of muslc to enable 'alpine' like rootfs

Related issues

Changes

While this PR contains basic muslc build, I don't know if/see how we support compiling rest of the packages without glibc. If this PR causes issues with base libc functionality, I can also rename this to musl-gcc.

Checklist

  • I've read CONTRIBUTING.md.
  • I've accepted the ICLA (and CCLA if contributing on my employer's time). CLA Assistant will prompt me on this PR if I haven't already.
  • min check passes for the affected packages/harnesses.
  • min patched-build <name> succeeds for any package I added or modified.
  • For new packages: source_provenance points to the canonical upstream and the source builds from source (not a prebuilt release binary) where the required toolchain is available.
  • For version bumps: I've verified the new sha256 against the upstream archive.

Notes for reviewers

Summary by CodeRabbit

  • New Features
    • Added musl libc version 1.2.6 as a buildable package.
    • Provides binaries, libraries, headers, and the musl compiler wrapper.
    • Supports both dynamic and static compilation with validation tests.
    • Uses reproducible build settings and preserves runtime loader links.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a musl 1.2.6 package definition and build script. The package builds and stages binaries, libraries, headers, and musl-gcc. Dynamic and static compilation tests validate the installation.

Changes

musl package

Layer / File(s) Summary
Package contract and validation
packages/musl/build.ncl
Defines the musl 1.2.6 source, dependencies, outputs, metadata, and dynamic and static compile tests.
Build and staged installation
packages/musl/build.sh
Configures and builds musl, installs it under $OUTPUT_DIR, converts loader links to relative links, and exposes musl-gcc in /usr/bin.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a musl libc build.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/musl/build.sh (1)

1-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the package build-shell convention.

packages/musl/build.sh only uses POSIX shell syntax, so the Bash shebang and option flags should use #!/bin/sh and set -e.

Proposed change
-#!/bin/bash
-set -euo pipefail
+#!/bin/sh
+set -e
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/musl/build.sh` around lines 1 - 2, Update the package build script
header to use the POSIX shell convention: replace the Bash shebang and
pipefail-enabled options with #!/bin/sh and set -e, preserving the script’s
existing behavior.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/musl/build.sh`:
- Around line 1-2: Update the package build script header to use the POSIX shell
convention: replace the Bash shebang and pipefail-enabled options with #!/bin/sh
and set -e, preserving the script’s existing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 63b3b38e-6396-49cd-bc07-c8c7f032f629

📥 Commits

Reviewing files that changed from the base of the PR and between 6798bfc and 4afb280.

📒 Files selected for processing (2)
  • packages/musl/build.ncl
  • packages/musl/build.sh

@msample

msample commented Aug 3, 2026

Copy link
Copy Markdown
Member

The contract for the build outputs from a package is that they don't overlap with those of any other package.

The tools in the Minimal Public Registry are based on glibc. Coexistence with musl C is not something we have planned for.

What is your use case for having musl C? If it's producing an Alpine-like rootfs as a package output, see https://github.com/gominimal/pkgs/tree/main/packages/microvm-rootfs

@twitchyliquid64

Copy link
Copy Markdown
Member

/build

@twitchyliquid64

Copy link
Copy Markdown
Member

(I'm curious to see the artifacts on the other side but agree with Mike that its not likely to gel well with the other packages)

@lrishi

lrishi commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Cool, I understand. I'll close this PR.
My use case was specifically that we ship a few apps which have to be statically compiled, and we have to use MIT licensed libs.

@lrishi lrishi closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants