build_config: give the mrbc config a name of its own - #7199
Conversation
build_config/mrbc.rb opened an anonymous `MRuby::Build`, and an unnamed
build is called 'host' (lib/mruby/build.rb:94). The build tree is keyed
by that name (:107), so MRUBY_CONFIG=mrbc aimed a compiler only build,
carrying `mruby-bin-mrbc` and nothing else, at build/host, on top of
whatever a default build had left there. No build/mrbc was ever
created.
Whether that costs anything is decided by the timestamps in build/host.
Run straight after a default build, rake finds every object it wants up
to date, compiles nothing, and the tree is untouched:
$ md5sum build/host/bin/mrbc
c6b0d6d168918de337fa27a8d5d2a262 build/host/bin/mrbc
$ wc -l build/host/include/mruby/presym/table.h
3161 build/host/include/mruby/presym/table.h
$ MRUBY_CONFIG=mrbc rake -j8 # exit 0
$ md5sum build/host/bin/mrbc
c6b0d6d168918de337fa27a8d5d2a262 build/host/bin/mrbc
$ wc -l build/host/include/mruby/presym/table.h
3161 build/host/include/mruby/presym/table.h
With a core source edited since, it rebuilds, and what it rebuilds is
half the tree. It exits 0 while doing it:
$ touch include/mruby.h src/*.c
$ MRUBY_CONFIG=mrbc rake -j8 # exit 0
...
Config Name: host
Output Directory: build/host
$ md5sum build/host/bin/mrbc
498ad7e2f0c3b9fc72708e5341af055d build/host/bin/mrbc
$ wc -l build/host/include/mruby/presym/table.h
573 build/host/include/mruby/presym/table.h
$ md5sum build/host/bin/mruby build/host/lib/libmruby.a
9881d200e90c5a7df4a29a36b193fbab build/host/bin/mruby
8dbb8c26becf449f5871f9e090c8a4ff build/host/lib/libmruby.a
build/host/bin/mruby and libmruby.a are the default build's, holding the
3161 symbol table, while the presym headers beside them now describe 573
and bin/mrbc is a compiler built against those. `disable_libmruby`
keeps the archive out of the way, so nothing announces the change.
The next default build does not put it back. It aborts, before it links
anything, on a symbol the smaller table does not carry:
$ rake -j8
include/mruby/presym.h:42:23: error: 'MRB_SYM__Rational' undeclared
(first use in this function); did you mean 'MRB_SYM__generational'?
42 | #define MRB_SYM(name) MRB_SYM__##name
src/numeric.c:299:53: note: in expansion of macro 'MRB_SYM'
299 | if (mrb_integer_p(y) && mrb_class_defined_id(mrb,
| MRB_SYM(Rational))) {
rake aborted!
Tasks: TOP => build => ... => build/host/src/numeric.o
and it goes on aborting the same way on every later run, because the
presym list is what decides whether the headers get rewritten.
tasks/presym.rake declares it as `file presym.list_path => ppps`, and
the mrbc run rewrote build/host/presym along with the core .pi files it
scanned, leaving it newer than the gem .pi files a default build would
have to rescan to notice anything is missing:
$ ls -l --time-style=+%H:%M:%S build/host/presym
-rw-rw-r-- 1 ... 00:30:03 build/host/presym
$ ls -lt --time-style=+%H:%M:%S build/host/src/vm.pi
-rw-rw-r-- 1 ... 00:30:03 build/host/src/vm.pi
$ ls -lt --time-style=+%H:%M:%S build/host/mrbgems/mruby-rational/gem_init.pi
-rw-rw-r-- 1 ... 00:28:57 build/host/mrbgems/mruby-rational/gem_init.pi
The task is up to date, the 573 symbol headers stay, and every core
source naming a symbol outside them fails to compile. Recovery is
rm -rf build/host plus a full rebuild.
Name the build after its config, which is what build_config/asan.rb and
build_config/gctest.rb already do, and what 8b44a52 did for host-cxx.
The rename is all this config needs: `build_mrbc_exec` supplies
mruby-bin-mrbc itself (:345), and `disable_libmruby` means no internal
mrbc build is created for it either way (:152). It now builds into a
directory of its own and leaves an existing host build byte-identical,
through the same sequence that broke it:
$ touch include/mruby.h src/*.c
$ MRUBY_CONFIG=mrbc rake -j8 # exit 0
...
Config Name: mrbc
Output Directory: build/mrbc
$ ls build/
host mrbc
$ md5sum build/host/bin/mruby build/host/bin/mrbc build/host/lib/libmruby.a
9881d200e90c5a7df4a29a36b193fbab build/host/bin/mruby
c6b0d6d168918de337fa27a8d5d2a262 build/host/bin/mrbc
8dbb8c26becf449f5871f9e090c8a4ff build/host/lib/libmruby.a
$ wc -l build/host/include/mruby/presym/table.h
3161 build/host/include/mruby/presym/table.h
$ rake -j8 # exit 0
The compiler it produces is the one it was producing before, byte for
byte, and it still compiles for the host build's mruby:
$ md5sum build/mrbc/bin/mrbc
498ad7e2f0c3b9fc72708e5341af055d build/mrbc/bin/mrbc
$ wc -l build/mrbc/include/mruby/presym/table.h
573 build/mrbc/include/mruby/presym/table.h
$ build/mrbc/bin/mrbc -o /tmp/t.mrb /tmp/t.rb
$ build/host/bin/mruby -b /tmp/t.mrb
["1", "2", "3"]
[:a]
:sym
One thing changes for whoever runs this config. bin/ symlinks are
installed for a `host?` build (:452), so on master this config also
pointed bin/mrbc at what it built. A named build does not, and the
compiler is at build/mrbc/bin/mrbc instead. Run from a clean tree it
now touches nothing else:
$ MRUBY_CONFIG=mrbc rake -j8 # exit 0
$ ls build/
mrbc
|
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; 2 remain after this review. 📝 WalkthroughWalkthroughThe build configuration now names the build Changesmrbc build configuration
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to The change gives the mrbc build its own output directory without evidence of a remaining merge-blocking issue; it is merge-ready 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/ci/msvc.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=ci/msvc aimed a full-core build with `MRB_GC_FIXED_ARENA` at build/host, the directory a default build on the same machine uses. The Windows-VC job never sees that, since it builds a fresh checkout, but a developer who points MRUBY_CONFIG at this config on a tree the default config has built shares one directory between two gem sets, which is the shape mruby#7195, mruby#7197, mruby#7199 and mruby#7200 took out of the other configs that had it. 14d6e42 named the bintest build in ci/gcc-clang and left this one alone, on the ground that a single build has no sibling for a name to tell it apart from. That was a reason about telling builds apart; the build directory is decided by the name whether or not there is a sibling, and that is the reason here. Name it after its config, as build_config/mrbc.rb, clang-asan.rb and gctest.rb are. Nothing in the file needs the build to be called 'host'. It is an `MRuby::Build`, and it pulls `mruby-bin-mrbc` in through full-core, so it lends no mrbc to any cross target and creates its own internal one either way (:174). The name reaches three other places: `install_prefix` (:625), the `bin/*.bat` wrappers that `define_installer_if_needed` writes only when `host?` answers true (:461 and :482), and the mrbtest that `rake clean` removes from MRUBY_ROOT/bin (tasks/test.rake:82). The job runs `rake -m test:run:serial` (.github/workflows/build.yml:89), which installs nothing and cleans nothing, so none of the three fires. `enable_bintest` has not required the name 'host' since fd113da, and test/bintest.rb resolves every binary it runs from BUILD_DIR rather than from bin/; the `bintest` build in ci/gcc-clang is this same shape under a name, in the same workflow. There is no MSVC here to run the job with. What can be checked on Linux is that the config still loads and that the tree it names is its own; the job on this change is the run: $ MRUBY_CONFIG=ci/msvc rake -T | grep amalgam rake amalgam # Generate amalgamated mruby.h and mruby.c in .../build/msvc/amalgam
build_config/mrbc.rbopens an anonymousMRuby::Build, and an unnamed build is calledhost(lib/mruby/build.rb:94). The build tree is keyed by that name (:107), soMRUBY_CONFIG=mrbcaims a compiler only build, carryingmruby-bin-mrbcand nothing else, 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 and #7197, on a config neither touches.All of the transcripts below are from today's master, gcc 13.3.0, each starting from one clean default build.
What it costs is decided by the timestamps in
build/hostRun straight after a default build, rake finds every object it wants up to date, compiles nothing, and the tree is untouched:
With a core source edited since, it rebuilds, and what it rebuilds is half the tree. It exits 0 while doing it:
build/host/bin/mrubyandlibmruby.aare the default build's, holding the 3161 symbol table, while the presym headers beside them now describe 573, andbin/mrbcis a compiler built against those.disable_libmrubykeeps the archive out of the way, so nothing announces the change. The repobin/symlinks point into this tree as well, sincehost?builds install them (:452).The next default build does not put it back
It aborts, before it links anything, on a symbol the smaller table does not carry:
and it goes on aborting the same way on every later run, because the presym list is what decides whether the headers get rewritten.
tasks/presym.rakedeclares it asfile presym.list_path => ppps, and themrbcrun rewrotebuild/host/presymalong with the core.pifiles it scanned, leaving it newer than the gem.pifiles a default build would have to rescan to notice anything is missing:The task is up to date, the 573 symbol headers stay, and every core source naming a symbol outside them fails to compile. Recovery is
rm -rf build/hostplus a full rebuild.Naming it
The build is named after its config, which is what
build_config/asan.rbandbuild_config/gctest.rbalready do, and what 8b44a52 did forhost-cxx. The rename is all this config needs:build_mrbc_execsuppliesmruby-bin-mrbcitself (:345), anddisable_libmrubymeans no internal mrbc build is created for it either way (:152).Verified
Through the same sequence that broke it:
The compiler it produces is the one it was producing before, byte for byte, and it still compiles for the host build's mruby:
One thing changes for whoever runs this config
bin/symlinks are installed for ahost?build (:452), so on master this config also pointedbin/mrbcat what it built. A named build does not, and the compiler is atbuild/mrbc/bin/mrbcinstead. Run from a clean tree it now touches nothing else:Environment
Details
The line each build gives
mrbgems/mruby-compiler/src/codegen.c, read offrake --verbosewith-MMD -c, the-Ilist and-odropped. This file rather thansrc/string.c, because themrbcbuild compiles nosrc/*.cto an object at all: withdisable_libmrubynothing links them, andtasks/presym.rakeseeds the scan from the object list so only their.pifiles get built. Neither build callsenable_debug, so both take the gcc toolchain's own-g -O3:Summary by CodeRabbit
mrbcbuild name and output directory.