Make the repo buildable from a clean checkout (9 fixes) - #1
Open
Largo wants to merge 9 commits into
Open
Conversation
1. local-includes.mk fatally errored when build/bootstrap/mtdeps was missing, even during the 'cosmo_configure.sh --bootstrap' invocation whose whole purpose is to build it (make is invoked with the mkdeps stub via MKDEPS= on the command line). Skip the check when MKDEPS comes from the command line so bootstrap can run on fresh checkouts. 2. ruby.deps.mk references 395 ruby_shims/*.h mkdeps shim files that were never committed (they lived only in the original developer's working tree, produced by the also-uncommitted bin/create_shims.sh). Without them, make's .DEFAULT rule endlessly deletes and regenerates o/$(MODE)/depend. Add gen_ruby_shims.sh which deterministically rebuilds the shim directory from the entries in ruby.deps.mk. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The bootstrap block hard-coded make -j1, which on a clean checkout means building a large part of cosmopolitan libc single-threaded. Use -j$(nproc) by default, overridable via BOOTSTRAP_JOBS for debugging. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Commit bd1ce47 reordered variable definitions in tool/build/lib/BUILD.mk and dropped the $(TOOL_BUILD_LIB_A): and $(TOOL_BUILD_LIB_A).pkg: rules in the process. Without prerequisites the generic archive rule packs an empty buildlib.a, and everything that links against it (automate_mkdeps, mtdeps, rubyobj, ...) fails with undefined references to getargs_* et al. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The committed lrama/bison-generated parse.c contained #include "/home/groobiest/Code/jart/cosmopolitan/o/third_party/ruby/generated/parse.h" i.e. an absolute path from the original developer's machine, which breaks compilation on any other checkout. Point it at the committed third_party/ruby/parse.h instead (same generated header). The ~900 remaining #line directives referencing that path are cosmetic only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CARGO was assigned with := from $(shell command -v cargo), which comes up empty under the cocmd build shell even when cargo is installed, and could not be overridden from the environment. Use ?= so callers can pass CARGO=/usr/bin/cargo. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both recipes invoke ruby_prepare_encdir, which rm -rf's and recopies the shared $(RUBY_ENC_TMPDIR). Under make -jN they can run concurrently, so one recipe deletes enc sources while the other is mid-scan, yielding nondeterministic failures like: x_emoji.h:18: ENC_REPLICATE: stateless-ISO-2022-JP is not defined yet. Make transdb.h order-only depend on encdb.h. This is likely the reason the docs recommend building Ruby with -j1. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The generated/config.h rule required docs/reference/_ext_config_ruby_orig_3_4_7.h, a file that exists only in the original developer's working tree (never committed on any branch), making the codegen phase fail on fresh checkouts. Substitute the committed third_party/ruby/include/ruby/config.h; the chain that consumes it (generated rbconfig.rb, enc.mk, configure-ext.mk, exts.mk) is comparison-only, so this merely produces empty reference diffs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- mtsh.o and mtsh_embed.o rules listed prerequisites but had no compile recipe; their sources live in the mtsh/ subdirectory so no pattern rule applies, and linking mtsh.com.dbg failed with 'cannot find mtsh.o'. Add the same OBJECTIFY.c recipe used by the sibling caboose rules. - ruby.codegen.mk recipes contained '@# comment' lines. Those are only harmless when SHELL is mtsh (which exists solely on machines where mtsh was previously built); under the default cocmd shell they abort with "unsupported syntax '#'". Turn them into make comments. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
assemble_stdlib.sh copies third_party/ruby/bin/gem into the packaged /zip/bin, but the bin/ directory was never committed. Restore the standard RubyGems launcher (identical to MRI's bin/gem). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Hi — thanks for CosmoRuby. I set out to build it from a fresh clone and hit a series of blockers; this PR is the minimal set of fixes that gets
feature/ruby-4.0.0-portbuilding end-to-end from a clean checkout. No Ruby version change, no new features, nothing restructured.Each commit is one blocker, in the order I hit them:
cosmo_configure.sh --bootstrapfails on the very file the bootstrap exists to produce:local-includes.mkfatally requires it before it can be built. Also,ruby_shims/(395 mkdeps headers) isn't in the repo, which sendso//dependinto an infinite delete/regen loop (1300+ iterations). Addedgen_ruby_shims.sh, which regenerates them deterministically fromruby.deps.mk(394/395 resolve).cosmo_configure.sh --bootstrapmake invocations-j1was single-threading a large chunk of cosmopolitan libc.tool/build/lib/BUILD.mkwere dropped in commit bd1ce47, sobuildlib.aalways built empty →undefined reference to getargs_*.parse.c#includes an absolute path from your machine (/home/groobiest/...). Repointed at the committedparse.h.cocmdand couldn't be overridden;CARGO ?=letsCARGO=/usr/bin/cargothrough.rm -rfthe same temp dir, so they race under-j. An order-only dep fixes it — this is, I think, why the docs recommend-j1;-j8works after this.docs/reference/_ext_config_ruby_orig_3_4_7.hdoesn't exist on any branch; the chain is comparison-only, so it now uses the committedconfig.h.mtsh.o/mtsh_embed.ohad prerequisites but no compile recipe, and@#recipe comments crashcocmd.Verified by building from a clean checkout on Debian 13 (x86-64, cosmocc 3.9.2 as pinned) and running the produced
ruby.com: version/platform banner,requireof json/digest/zlib/yaml/stringio, TCP loopback, threads,--yjitreporting+YJIT,gem --version, andenv -i ./ruby.comfrom an empty directory.irb.comandminiruby.combuild and run too.Two gotchas I hit that aren't code problems, in case they're worth documenting: plain
cosmo_configure.sh(and--bootstrap) silently resets the tree to plugin mode, so--with-static-linked-exthas to be re-passed before building; andmakecan exit 0 having stopped halfway without linking, so it's worth checking the binary's mtime rather than$?.I have further work in follow-up branches if any of it is useful to you — a merge with current jart/cosmopolitan master (it was only 16 commits ahead and conflict-free), a Ruby 4.0.0 → 4.0.6 bump, and sqlite3 as a statically linked extension. It's all contained in the main branch. The main aim is to add cosmopolitan support to my OCRAN Project.