Add GCC example with scoped configs and assembly support#6
Add GCC example with scoped configs and assembly support#6
Conversation
95d15db to
55673fb
Compare
Build GCC's three prerequisite libraries using putup with a 3-tree layout (-C/-S/-B) against a read-only GCC source tree. Each library is self-contained with ?= defaults for standalone builds. Per-component tup.config files use prefix-free entries — the directory scope provides the namespace via scoped config merging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55673fb to
cede70f
Compare
Add libiberty, libdecnumber, libbacktrace, libcpp libraries and the full gcc/ build pipeline (config headers, ~25 generator programs, ~500 backend objects, cc1 link) to the GCC example. The generator bootstrap chain builds genmodes first, then BUILD_RTL support objects, then all RTL generators that produce insn-*.h and insn-*.cc from machine description files. Pre-generated files from gengtype and genmatch are expected in gcc/pre-generated/. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
genmatch reads match.pd and generates optimized C++ for GIMPLE and GENERIC IR simplification. It was previously requiring users to run ./configure && make on the GCC source tree to produce its outputs. Now genmatch is compiled and linked against libcpp (for tokenization) and run as part of the normal build. Only gengtype outputs remain in pre-generated/. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GCC Example Build — Handoff NoteCurrent StateBuild reaches ~1088/1740 commands before failing. The build command: cd /home/mural/src/pup/examples/gcc && \
PUP_IMPLICIT_DEPS=0 /home/mural/src/pup/build/putup \
-C . -S /home/mural/src/gcc-15.2.0 -B ../../build-gcc -j$(nproc)You need a GCC 15.2.0 source tree at Next Issue to Fix4 generators with file-output flags write relative to CWD (read-only in 3-tree mode) These generators use flags like Affected rules in
Fix: Use the same Key Discoveries (This Build Effort)
WorkflowBuild → read first error → diagnose → fix Tupfile/config → rebuild. Repeat until cc1 links. Separate Issue: 3-Tree Groups BugOrder-only groups produce "has no members" warnings in 3-tree mode. Plan exists at |
…ee mode Build reaches ~1088/1740. Fixes applied: - genmatch: SRCDIR=$PWD pattern for cfn-operators.pd in 3-tree mode - tm_p.h: add missing linux-protos.h and tm-preds.h includes - tup.config: remove incorrect HAVE_UCHAR, fix library configs - gencondmd: fix display text placement (must be on same line as |>) - Tuprules.tup: use ?= defaults for self-contained library builds Next: fix genattrtab/genopinit/genemit/genrecog file-output flags (write relative to CWD which is read-only source dir in 3-tree mode). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
genattrtab, genopinit, genemit, and genrecog write output files relative to CWD via flags (-A/-D/-L, -h/-c, -O, -H/-O). In 3-tree mode CWD is the read-only source directory, so cd to the build directory first using the same SRCDIR=$PWD pattern established by genmatch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lchain Extends the GCC example from cc1-only to a complete cross-compiler toolchain (aarch64-apple-darwin host → x86_64-pc-linux-gnu target). 3517 commands, ~133s on M4 Mac. Five verified binaries: cc1 (40MB), cc1plus (42MB), xgcc (2.4MB), xg++ (2.4MB), collect2 (2.3MB). New components: - cc1plus: C++ compiler backend (40 cp/ source files, gengtype [cp] support) - xgcc/xg++: C/C++ compiler drivers with specs.h for language dispatch - collect2: linker wrapper for C++ constructor/destructor collection - libcody: C++ modules protocol library (required by cc1plus) Architecture improvements: - Extract LIBCOMMON_OBJS/DRIVER_LIBS to DRY up xgcc/collect2/xg++ link commands - Move target-specific config (tm.h, tm_p.h, MD files) to targets/*.tup - Add macOS host configs (configs/host-darwin/) for cross-compilation - Add darwin-x86_64-linux.config variant for macOS→Linux cross builds Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Four more tools built from existing GCC source, bringing the total to 9 binaries: cc1, cc1plus, xgcc, xg++, collect2, cpp, lto-wrapper, gcov, gcov-dump. All follow established patterns (LIBCOMMON_OBJS + DRIVER_LIBS). Only 6 new object compilations — rest reuses existing objects from cc1/xgcc/collect2 builds via $(D)/ path references. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add $$ → $ de-escaping in the evaluator so shell variable references survive Tupfile expansion (e.g., for f in $(names); do ... $$f). In 3-tree builds (-C/-S/-B), the scheduler now creates source subdirs that exist in the config tree but not the source tree, enabling packages whose actual source lives in a separate tree (referenced via config variables rather than the -S tree). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Build GNU binutils 2.44 cross-assembler and cross-archiver targeting x86_64-linux from a separate source tree via @(BINUTILS_SRC). This is the first package to use an explicit source variable rather than the implicit -S tree, establishing the pattern for future packages. Single Tupfile builds BFD (38 files), libsframe (2), opcodes (4), gas (39), and ar (11) — producing working as and ar binaries that integrate with the existing xgcc/cc1 toolchain. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The pattern required at least one token between the compiler name and -c, so commands like `gcc -c foo.c -o foo.o` never matched. Also add \s as an anchor alternative so compiler wrappers like `ccache gcc` are recognized. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mode The scheduler auto-created source-tree directories when a config-tree directory had no counterpart. This papered over a user setup issue rather than honoring the 3-tree model: config tree mirrors source tree. Makefile.pup now creates the binutils/ directory in the source tree as an explicit setup step. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The examples/ directory becomes the BSP root (-C tree). Infrastructure (Tupfile.ini, Tuprules.tup, Makefile.pup, configs/, scripts/) moves up from examples/gcc/. Binutils moves to examples/binutils/ as a peer tarball group. GCC-internal packages stay under examples/gcc/ with a new group Tuprules.tup providing ?= defaults for standalone use. Key changes: - Root Tuprules.tup uses gcc/ prefix for all GCC-tarball DIR variables - Binutils uses $(S)/$(BINUTILS_DIR) instead of @(BINUTILS_SRC) - Nested Tupfile.ini markers removed from busybox/ and helloworld/ - Source assembly model: one source-root/ subdir per extracted tarball Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…symbol The foreach *.c glob picks up both hello.c and main.c, so hello.c must not define main() — use hello() instead to avoid duplicate symbol errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
examples/gcc/demonstrating a real-world multi-directory build: GMP + MPFR + MPC from GCC's bundled sourcesputup configureto copy subdirtup.configfiles for scoped config mergingBuild Features Demonstrated
.asm → m4 → assemblerpipeline with config-driven source selectionifeq-Bdirectories with different toolchain configstup.config, merged with root via scoped config merging-C), GCC sources (-S), and build output (-B) in separate directories../<objs>into parent archiveFiles
Makefile.pup,scripts/resolve-mpn.shTuprules.tup,Tupfile,configs/*.configgmp/{Tupfile,Tuprules.tup,tup.config},gmp/{mpn,mpz,mpq,mpf,printf,scanf,rand}/Tupfilempfr/{Tupfile,Tuprules.tup,tup.config,src/Tupfile}mpc/{Tupfile,Tuprules.tup,tup.config,src/Tupfile}src/cli/cmd_configure.cppTest plan
make -f Makefile.pup SRCDIR=../gcc-15.2.0builds all three libraries in generic C modemake -f Makefile.pup MPN_CPU=x86_64 SRCDIR=../gcc-15.2.0builds with x86-64 assemblymake -f Makefile.pup multi SRCDIR=../gcc-15.2.0builds x86_64-linux + aarch64-linux variantscd gmp && putup configure && putupworks with?=defaultsmake testpasses (no regressions in existing tests)🤖 Generated with Claude Code