build_config: give the cosmopolitan config a name of its own - #7245
Conversation
build_config/cosmopolitan.rb opened an anonymous `MRuby::Build`, and an
unnamed build is called 'host' (lib/mruby/build.rb:114). The build tree
is keyed by that name (:127), so MRUBY_CONFIG=cosmopolitan aimed a
cosmocc build at build/host, on top of whatever a default build had left
there. No build/cosmopolitan was ever created.
Run after a default build, it does not get as far as a library. The
`.flags` record beside each object notices the compiler changed and
rebuilds what the rules own, but the Prism objects are built by a `file`
task of their own (mrbgems/mruby-compiler/mrbgem.rake:105), which the
record does not cover, so the gcc objects stay and cosmocc refuses them
at the first link:
$ rake -j16 # exit 0, default build
$ COSMO_ROOT=~/cosmo MRUBY_CONFIG=cosmopolitan rake -j16
build/host: output here was built by another configuration, rebuilding it
command added: /home/.../cosmo/bin/cosmocc
command removed: gcc
...
LD build/host/mrbc/bin/mrbc.com
cosmocc: fatal error: build/host/mrbc/mrbgems/mruby-compiler/lib/diagnostic.o:
linker input missing concomitant
build/host/mrbc/mrbgems/mruby-compiler/lib/.aarch64/diagnostic.o file
rake aborted!
Tasks: TOP => default => all => gensym => build/host/presym => ...
=> build/host/mrbc/bin/mrbc.com
By then it has preprocessed the core sources with cosmocc, so the next
default build finds its own tree foreign and does it over again. It
exits 0 and what it links is byte for byte what it linked before, but
it preprocesses 198 sources and compiles 165 objects to get there:
$ rake -j16 2>&1 | tee rake.log # exit 0
build/host/mrbc: output here was built by another configuration, rebuilding it
build/host: output here was built by another configuration, rebuilding it
...
$ grep -c '^CPP ' rake.log
198
$ grep -c '^CC ' rake.log
165
Name the build after its config, which is what build_config/mrbc.rb,
build_config/clang-asan.rb and build_config/gctest.rb already do. The
rename is all this config needs: it carries `mruby-bin-mrbc` itself, so
its internal mrbc build is created either way (:174). It now builds
into a directory of its own and leaves an existing host build
byte-identical, through the same sequence that broke it:
$ rake -j16 # exit 0, default build
$ md5sum build/host/bin/mruby build/host/lib/libmruby.a
7a52da8807433dc3812c042d46e633fd build/host/bin/mruby
7492434aab8a47f72c1cbd48d1f7d093 build/host/lib/libmruby.a
$ COSMO_ROOT=~/cosmo MRUBY_CONFIG=cosmopolitan rake -j16 # exit 0
...
Config Name: cosmopolitan
Output Directory: build/cosmopolitan
$ ls build/
cosmopolitan host
$ md5sum build/host/bin/mruby build/host/lib/libmruby.a
7a52da8807433dc3812c042d46e633fd build/host/bin/mruby
7492434aab8a47f72c1cbd48d1f7d093 build/host/lib/libmruby.a
$ rake -j16 | grep -c '^CC ' # exit 0
0
The binaries it produces are the APE ones it was producing before:
$ ls build/cosmopolitan/bin/*.com
build/cosmopolitan/bin/mirb.com build/cosmopolitan/bin/mrbc.com
build/cosmopolitan/bin/mrdb.com build/cosmopolitan/bin/mruby-strip.com
build/cosmopolitan/bin/mruby.com
$ build/cosmopolitan/bin/mruby.com -e 'p [1,2,3].map { |x| x.to_s }'
["1", "2", "3"]
and the command CI runs for this config passes from a clean tree,
touching nothing else:
$ COSMO_ROOT=~/cosmo rake -m test:run:serial MRUBY_CONFIG=cosmopolitan
$ ls build/
cosmopolitan
One thing changes for whoever runs this config. bin/ symlinks are
installed for a `host?` build (:482), so on master this config also
pointed bin/mruby and the rest at the .com files it built. A named
build does not, and they are under build/cosmopolitan/bin/ instead; the
header comment that said bin/ now says so.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe Cosmopolitan build configuration now uses the ChangesCosmopolitan build configuration
Estimated code review effort: 1 (Trivial) | ~3 minutes Merge Risk: ⚪ Minimal · up to This change gives the Cosmopolitan build its own output directory, preventing it from overwriting or rebuilding the default host build; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
build_config/cosmopolitan.rbopens an anonymousMRuby::Build, and an unnamed build is calledhost(lib/mruby/build.rb:114). The build tree is keyed by that name (:127), soMRUBY_CONFIG=cosmopolitanaims a cosmocc build atbuild/host, on top of whatever a default build has left there, and never creates a directory of its own. This is the same shape as #7195, #7197, #7199 and #7200, on a config none of them touches.All of the transcripts below are from today's master (76bf448), gcc 13.3.0 for the default build and cosmocc 14.1.0 for this one, each sequence starting from one clean default build.
Run after a default build, it does not get as far as a library
The
.flagsrecord beside each object notices the compiler changed and rebuilds what the rules own, but the Prism objects are built by afiletask of their own (mrbgems/mruby-compiler/mrbgem.rake:105), which the record does not cover. The gcc objects stay, and cosmocc refuses them at the first link:By then it has preprocessed the core sources with cosmocc, so the next default build finds its own tree foreign and does it over again. It exits 0 and what it links is byte for byte what it linked before, but it preprocesses 198 sources and compiles 165 objects to get there:
Naming it
The build is named after its config, which is what
build_config/mrbc.rb,build_config/clang-asan.rbandbuild_config/gctest.rbalready do. The rename is all this config needs: it carriesmruby-bin-mrbcitself, so its internal mrbc build is created either way (:174).Verified
Through the same sequence that broke it. An existing host build is left byte-identical, and the default build afterwards compiles nothing:
The binaries it produces are the APE ones it was producing before:
and the command
.github/workflows/build.ymlruns for this config passes from a clean tree, touching nothing else:One thing changes for whoever runs this config
bin/symlinks are installed for ahost?build (:482), so on master this config also pointedbin/mrubyand the rest at the.comfiles it built. A named build does not, and they are underbuild/cosmopolitan/bin/instead; the header comment that saidbin/now says so.Environment
Details
The line each build gives
src/string.c, read off the.flagsrecord beside the object, the-Ilist and-odropped. Neither build callsenable_debug; the default build takes the gcc toolchain's own-g -O3, and this config sets-Os -fno-omit-frame-pointeritself:Summary by CodeRabbit