feat(build): support crosscompile - #166
Open
MeteorsLiu wants to merge 39 commits into
Open
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
MeteorsLiu
marked this pull request as ready for review
August 10, 2026 10:55
Collaborator
Author
|
/review |
Contributor
There was a problem hiding this comment.
Review: cross-compile target support
Solid, well-tested feature (strong error-path/darwin/linux/gnu-musl coverage, defensive slice copies in the toolchain accessors). One issue is a potential process deadlock and should be addressed before merge; the rest are correctness/robustness and maintainability notes. Non-blocking review.
Highlights
- Critical: the new target middleware
panics for recoverable errors, and the execbroker holds a non-deferredRLockacross the middleware call — a panic leaks the read lock and deadlocks the process. See inline comments oninternal/execbroker/execbroker.go,internal/crosscompile/c/target.go, andinternal/crosscompile/crosscompile.go. - Important: a partial
--os/--archmatrix is misclassified as cross-compile (cmd/llar/internal/make.go).
Minor / maintainability (not inlined)
internal/crosscompile/crosscompile.go(customTargetdoc comment, ~lines 33-35): "customTarget uses the bootstrap toolchain to build libc itself" is inaccurate —LoadreturnsbootstrapTargetwhenroot.Path == cSysroot.Path, socustomTargetactually builds a consumer against a Formula-supplied libc, not libc itself. Suggest rewording.internal/crosscompile/c/toolchain.go(lines 27-33): exported accessorsCC()/CXX()/Linker()/Archiver()/Ranlib()/NM()/Strip()lack doc comments while every other exported symbol in the package has one;revive/golintwill flag this.internal/crosscompile/c/target.go(autotoolsPatch): the--hostdetection re-reads and scans theconfigurescript on every autotools command. The result is deterministic per target and could be cached alongsidetempDir/toolchainFile. Low impact.- Latent concurrency: both
Usemethods lazily initialize shared fields (toolchainFile/tempDir,configured) without synchronization. Safe today because builds run sequentially, butbuild.gocarries a// TODO(MeteorsLiu): Parallel buildnote — worth a comment documenting the assumption or async.Onceguard.
Findings without inline locations
internal/execbroker/execbroker.go:149:scopeMu.RUnlock()here is not deferred, andscope.Middleware(req)(line 146) is called inside the locked region. The new C-target middleware canpanic(seecrosscompile.goandc/target.goUsemethods), and a panic unwinds past this line, leaking the read lock permanently and deadlocking the nextscopeMu.Lock(). Recommenddefer scopeMu.RUnlock()(or arecover) so the lock is always released, in addition to fixing the middleware to not panic.
MeteorsLiu
commented
Aug 11, 2026
|
|
||
| // Target applies language-specific target defaults to build commands. | ||
| type Target interface { | ||
| Use(Command) Patch |
Collaborator
Author
There was a problem hiding this comment.
TODO: change this signature to Use(Command) (Patch, error) to avoid panic, it requres #167
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Design: https://github.com/xgo-dev/llar/wiki/Cross-compile-Design