bootcc — Log #
Each line records a completed, committed increment. Append only; newest last.
-
4e7287d— Bootstrap bootcc via M2-Planet; full M2→blood-elf→M1→hex2 chain; tokenizer milestone; deterministic build. -
49dadbe— Emit newline tokens so the preprocessor can track directive boundaries. -
f546411— Preprocessor: object-like macros + #define/#undef/#ifdef/#ifndef/#else/#endif with conditional emission; fixed line-bounded macro bodies. -
29f5b51— Function-like macros with parameter substitution; M2-subset compliance (no for(;😉, C89 decls). -
15cd408— Nested macro re-expansion of substituted args (ADD(ADD(1,2),3) => 1+2+3). -
48b3e80— # stringification (#param => "arg", spaces preserved); added block-bounded pp_strlen for M2 link. -
(NEXT)
#includeresolution — resolved: relative-then-vendor search, recursive header preprocessing, newtests/pp/hdr/defs.hguard-header golden test,read_reset()for re-lexing include files. See TASKS/NEXT.md for the next increment. -
(NOW)
#if/#elifinteger constant-expression evaluation — resolved: macro/defined()-expanded conditions, C-precedence arithmetic/comparison/logic/shift integer evaluator, chain-to-#elseconditional emission; hardenedpp_walkagainst a missing-final-newline EOF crash and NULL-safe newline/hash checks; newtests/pp/ifexpr.cgolden test. See TASKS/NEXT.md. -
(NOW)
##token pasting — resolved: added a paste branch tosubst_bodythat fuses the already-emitted left token with the substituted text of the operand after the##pair (the lexer emits##as two adjacent#tokens; previously the tail#was mis-lexed as stringification). Object-like macros now expand throughsubst_bodyso their bodies paste too. A merged result is re-classified (all-digits => int, else ident), so a paste that names a macro re-expands throughfull_expand(LAZY(2) => V2 => 200).##with no left or right operand is a hard error. Newtests/pp/paste.cgolden test covers name+name, name+number, number+name, and a paste-then-re-expand chain; builds stay byte-deterministic. See TASKS/NEXT.md. -
(NOW)
__LINE__/__FILE__predefined macros — resolved:expand_macrospecial-cases the identifiers__LINE__/__FILE__before table lookup and returns a fresh token (int in decimal for__LINE__, a quoted string of the file basename for__FILE__) stamped with the invocation token's lineno/file;subst_bodyadditionally re-stamps__LINE__/__FILE__tokens inside a macro body with the expanding token's info, so even object-like references (#define L __LINE__) report the invocation site, not the definition site. Also corrected tokenizer line counting:grab_bytenow mirrorsunget_byte's newline decrement, so comment/blank lines are counted accurately (previously off on files with leading comments). Existing golden snapshots were regenerated from the M2-built binary — token content is identical, only the now-accurate line numbers shifted. Newtests/pp/linefile.cgolden exercises__LINE__on several lines and__FILE__; all 12 tests (3 tokenizer + 9 preprocessor) pass and builds stay byte-deterministic. See TASKS/NEXT.md. -
7c8307b—#error/#warning/#linedirectives — resolved:#errorand#warningshare a handler that assembles the rest of the directive line into a bounded message and prints it (with the directive's logical file/line) on stderr;#errorthenexit(EXIT_FAILURE)to abort preprocessing,#warningcontinues and leaves the token stream untouched.#line N ["file"]re-bases the following tokens in place (walk from the token after the directive to end of the file's flat list applyingN + (lineno - base)), so__LINE__/__FILE__immediately report the new value and basename; numbers are parsed in plain decimal (leading 0 not octal), and each#includeed header keeps its own independent line counting (its tokens are a separate flat stream, so outer/inner#lines never leak across). Newtests/pp/line.cgolden covers#line 500→__LINE__,#line 10 "boot/sub.c"→__FILE__(basenamesub.c), and a#warningthat leaves the dump unchanged; newtests/pp/error.cis asserted by a new*.experrharness golden inrun-pp-tests.shthat requires a nonzero exit plus the exact stderr. All 14 tests (3 tokenizer + 11 preprocessor) pass; builds stay byte-deterministic. See TASKS/NEXT.md. -
e72a643— multi-/zero-arg and GNU variadic function-like macros — resolved: hardens function-like macro arguments to full C semantics.struct boot_macrogains avariadicflag, set indefine_macrowhen it sees the lexer's...(two punct tokens..then.); the ellipsis is consumed rather than treated as a param.expand_macronow performs strict arity checks: a non-variadic call with more args than params (or fewer) aborts with atoo many/too few arguments to macrodiagnostic at the invocation site, and the no-argFUNC()form yields zero arguments for a zero-param macro but one empty argument for a param-taking macro. For a variadic macro the excess args fold into a single comma-joined__VA_ARGS__argument (build_varargssplices the excess arg runs with comma tokens and the chain is truncated so the varargs node sits at zero-based index = number of named params).param_indexmaps__VA_ARGS__to that slot,operand_text/parameter substitution/stringification all honor it (#xof an empty arg yields""), andsubst_bodyspecial-cases, ## __VA_ARGS__: the comma is spliced with the varargs run when non-empty and erased entirely when empty (the GNU comma-elision idiom). Newtests/pp/variadic.cgolden exercises multi-arg, zero-arg, empty stringification, and variadicLOGnon-empty/comma-elided; newtests/pp/args.c/argsfew.c*.experrgoldens assert the too-many/too-few failure messages. All 17 tests (3 tokenizer + 14 preprocessor) pass; builds stay byte-deterministic (verified: two clean builds cmp identical). See TASKS/NEXT.md. -
parser engine step 1: type system + symbol table - resolved:
bootcc.hgains the type system (enum type_kindfor void/char/int/long/pointer/array/struct/union/enum/func/funcptr/typedef; a 32-bit-cleanstruct typewith kind,size,align,signed_p,array_len,flags and base/members/params/tag) and the symbol table (struct symbolwith name,type,storage,linkage,scope_index,is_def and scope/global chains);boot_type.cprovides type allocation and stable kind names;boot_sym.cbuilds a chained scope stack (pushed once per file, around function bodies) whose head-linked scope chains record every top-level declaration and computes storage/linkage/size; the driver gains-s/--symbols, which tokenises, preprocesses and parses the token stream and prints a deterministic typed symbol dump to stderr. A newtests/run-parse-tests.shharness (mirroring the pp harness) assertstests/parse/types.c(struct/union/enum tags and a tagged object) againsttypes.expected. NOTE (honest scope): a fully general declarator (multi-level pointers, array bounds, function declarations,typedefname resolution) is the declared next increment; the in-session M2-Planet binary exercised the struct/union/enum/tag-object subset deterministically, and richer mixes regressed late in the session and are driven by the forthcoming declaration-parser work. The build stays byte-deterministic (two clean buildscmpidentical) andmake testpasses 3 tokenizer + 14 preprocessor + 1 parser (0 failed). See TASKS/NEXT.md. -
parser engine step 2: declaration parser - resolved:
src/boot_sym.c's declarator now mirrors TCC 0.9.27'stype_decl()/post_type()and resolves the full declaration surface. Multi-level pointers, arbitrary array extents (multi-dimension arrays lay out outermost-first:int a[2][3]isarray[2]<array[3]<int>>), function declarations and definitions with ANSI and K&R parameter lists (an old-style body retypes the params), parenthesised function-pointer groups (int (*fpa[3])(int)isarray[3]<ptr<func<int>@1>>whileint *p[3]stays array-of-ptr),typedefname resolution, storage classes (extern/static) that feed linkage, and complete struct/union/enum member typing (sizes/offsets/alignment on the SysV amd64 ABI) with the tag namespace kept separate from typedefs. A tagged struct redefinition completes an earlier forward-declared tag/typedef in place; enumerators dump as compile-time constants with their integer value (X = 7,ON = 4thenAUTO = 5). The declarator is a value-only recursion with arelinkstep, and array bounds/enum values use a token-array constant-expression evaluator mirroring the preprocessor's; both changes were required to keep the M2-Planet build correct (M2 mis-compiles interior pointer-to-struct-member doubles).bootcc -s/--symbolsnow prints a richer typed table (storage/linkage, sizes/aligns, member offsets, param lists, enum values). Newtests/parse/decls.c+decls.expectedcover the corpus; sizes/offsets cross-checked against a reference compiler on SysV amd64 (TCC 0.9.27's x86-64 ABI).make testpasses 3 tokenizer + 14 preprocessor + 2 parser (0 failed); builds stay byte-deterministic (two clean builds cmp identical). See TASKS/NEXT.md. -
parser engine step 3: expression compiler - resolved:
src/boot_sym.cnow generalises a function definition by parsing its body into a flat, integer-indexed tree of typed expression rows (enode[]) and statement rows (stnode[], children as row indices, never interior pointers) instead ofskip_body()-ing it. The expression grammar is the full C precedence cascade (|| && | ^ & == != < <= > >= << >> + - * / %, unary- + ! ~ * & ++ --, casts,?:, assignment and every compound-assign form including the two-token/=<<=>>=the tokenizer emits, comma), with lvalue/rvalue classification, member access./->, subscript, calls,sizeof/typeof/alignof, and short-circuit&&/||all modelled. The statement grammar covers blocks, if/else-if/else, while, do-while, for (incl. local-declaration and expression init), switch/case/default, goto+labels, break/continue, return, and local declarations with initializers; a function prologue pushes a fresh scope registering the parameter types so identifiers resolve to their real types, and epilogue drops it. Constant folding applies C/TCC integer semantics (32-bit signed wraparound, division/modulo truncating toward zero, shift counts masked to the 5-bit width) and each foldable node carriesconst+val;-x/--exprsprints the whole per-body tree deterministically. The-x-mode dumps are gated by new goldenstests/parse/{expr,fold,stmts}.exprsintests/run-parse-tests.sh, each additionally byte-compared against a gcc build of the same sources, andfold.cis cross-checked value-for-value against the TCC 0.9.27 binary (overflow, division/modulo truncation, shift masking, bitwise, comparisons, ternary,sizeof, compound assignment) on the amd64 ABI. Getting this to self-host under M2-Planet required two codegen fixes: the node pool accessors were rewritten fromstruct exode* p=&enode[i]interior pointer reads (which M2 mis-compiles) to directenode[i].fieldindexing, and a label (ident:) statement branch plus nestedif(M2 does not short-circuit&&) for the void(params were added.make testpasses 3 tokenizer + 14 preprocessor + 9 parser (0 failed); two clean buildscmpbyte-identical (byte-deterministic). See TASKS/NEXT.md. -
parser engine step 4: statement compiler / x86-64 codegen + ELF - resolved:
boot_sym.cgains a full x86-64 codegen pass over the compiled statement/expression tree (theenode[]/stnode[]pools) on TCC 0.9.27's SysV amd64 ABI. Each function gets a prologue (push rbp,mov rbp,rsp/mov r13,rsp, sub a measured local frame), spills the six register arguments into stack slots, evaluates expression trees to registers (add/sub/mul, signed div/mod, width-masked shifts, setcc comparisons, short-circuit&&/||,?:, casts, plain + compound assignment, pre/post increment, member/subscript, pointer scaling, and calls across the register-arg boundary), and lowers the full statement set (blocks, if/else, while/do/for, switch dispatch, goto/labels, break/continue, return). Host==target==amd64 so int-wrap / div-mod truncation / shift-mask replicate TCC 0.9.27 at runtime. A newbootcc -e(--emit) outputs a standalone M1 assembly object that the vendored blood-elf/M1/hex2 chain statically links into a runnable ELF64;make elf SRC=prog.cdrives that static-link runner, and a new runtime-parity gatetests/run-codegen-tests.shexecutes eachtests/codegen/*.cELF and compares its exit status againsttcc -run— green for a parameter-free corpus (fold_arith=198,loop_sum=2,ops_tern=9, each matching TCC exactly). Self-hosting under M2-Planet required the node-pool discipline (readeslots[i].field/enode[i].fielddirectly) and writing emitter guards as nestedifs rather than&&chains, because M2 0.x mis-short-circuits&&and mis-compiles a few runtime emitter paths for parameter-bearing expression functions (so the runtime corpus is parameter-free for now; the reference gcc build emits those cases correctly). The build stays byte-deterministic (two cleanmakebuildscmpidentical) andmake testpasses 3 tokenizer + 14 preprocessor + 9 parser + 3 codegen suites (0 failed); struct-by-value, stdarg, bitfields, and a couple of expression edges (e.g. deref of a pointer cast) remain honest opens. See TASKS/NEXT.md. -
parser engine step 5: struct-by-VALUE argument ABI (SysV amd64 aggregate classifier) - resolved:
src/boot_sym.cemits the 9..16-byte struct/union argument shape correctly. Newagg_t_is_2reg/agg_is_2regclassify a 9..16-byte store/union as two integer register positions (<=8 stays scalar);cg_callnow sizes each argument by its ABI word count (so a struct param fills two consecutive caller registers and the stack-arg cleanuptot-6accounts for aggregate sprawl) withpush_agg_lo/push_agg_hipushing the two System-V eightbytes; the function prologue spills a 9..16-byte param from BOTH incoming registers (low eightbyte from register i, high from i+1) and advances the running register index by +2 for such params so trailing scalar params still land in the right register. New 8th runtime corpustests/codegen/struct_byval.c(12-bytestruct pt{x,y,z}passed by value tosum3reading all members, stdout "43\n", exit 3) assembles/links/runs byte-identical to TCC 0.9.27 on stdout+exit. Confirmed the M2-hostbootcc -ecrash on any >=2-real-arg call is pre-existing (a plain scalarh(int,int)two-arg call also crashes on the pristine binary; the reference gcc build emits these correctly), so multi-arg/struct-multi-arg/stdarg/long longruntime verification stays gated on the M2 vendor fork.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 8 codegen (0 failed); builds stay byte-deterministic (two clean builds cmp identical). See TASKS/NEXT.md. -
M2 vendor-fork blocker resolved (>=2-arg calls + string-literal emission) - resolved via boot-side restructure, not a vendored-M2 patch. Root cause 1 (label clash):
boot_pp.c'sstatic struct macro_arg* arg_at(struct macro_arg*,int)collided on the emitted labelFUNCTION_arg_atwithboot_sym.c'sstatic int arg_at(int,int); in M2-Planet's single-translation-unit build two bodies land under one label and the linker keeps the last (boot_pp's pointer walker), socg_call's walk of a comma-chain argument list dereferenced garbage andbootcc -esegfaulted on ANY call with >=2 real args. Renamed the preprocessor onepp_arg_at(definition + 5 call sites). Root cause _2 (array of pointers): the vendored M2-Planet mis-lowerschar* arr[N]; arr[i]to a byte stride + BYTE load (achar* pool[4]; pool[1]probe segfaults under the same M2), so the literal poolchar* strpool[]crashed the string-emission path. Replaced it with a flatchar strpool_data[STRPOOL_MAX*STRPOOL_STR]arena where sloti=strpool_data + i*STRPOOL_STRplus an intstrpool_n(no pointer-array indexing anywhere), and addedstr_content()to strip a TOK_STRING token's surrounding quotes and resolve backslash escapes (the tokenizer had been storing"hi"including the quotes, so the pool used to emit the literal"bytes; now:STRING_0='h' 'i' '00'). Verify results: two-arg scalarh(int,int)and 4-argh(1,2,3,4)emit byte-identical to the gcc reference;tests/codegen/multi_arg.c(a 4-arg and a 2-arg scalar call) is TCC-parity green (derr=254 tcc=254) and links/runs at runtime; aprint("hi"); print("there")program emits byte-identically to gcc with correct string bytes.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 10 codegen (0 failed); two-clean-buildcmpgate and them2==gccgate hold. Honest residuals (each a follow-up item): a struct param combined with a trailing scalar (int f(int a,struct pt p,int b)) now EMITS without crashing but the CALLER marshals args wrong (TCC puts exit 15 vs ours 4: theavalue is clobbered andpis read as one byte), two aggregate args in one call hang -e, string-literal RUNTIME output needs the blood-elf/M1 data-section rows (same gap as dense jump tables), and undeclared-extern calls still crash the parser. See TASKS/NEXT.md. -
aggregate marshalling with a trailing scalar in one call — resolved:
src/boot_sym.c's caller no longer drops or miscounts an argument list that mixes a 9..16-byte struct value with surrounding scalars. Root cause 1 (comma representation): the call argument list was accumulated left-associated (comma(comma(comma(a,b),c),d)), but the marshalling walkers (arg_count/arg_at) follow the.bspine and read.a. Forsum_pt(5,p,4)that meant every arg after the first collapsed into one comma subtree, so the struct<pt>was never seen as an argument:5was clobbered by the aggregate-address computation andpwas read as a single BYTE (movsx BYTE_PTR_[rax]) instead of two eightbytes. The build now links the list canonically right-nested (comma(a1, comma(a2, ...))), giving every real argument its own top-level node (root.a = arg1, arg(i) = the i-th.bspine node's.a), soagg_is_2reg/push_agg_lo/push_agg_hipush both System-V eightbytes intact between the scalars. Root cause 2 (a latent callee clobber that surfaced once the caller was right): a 9..16-byte aggregate param is spilled by the prologue as two full 8-byte stores, but the frame only reservedesize(t)(=12) bytes; the high eightbyte's store atsoff+8overran 4 bytes into a neighbouring scalar (f(int a,struct pt p,int b)laidaat -4, andp's high eightbyte landed at -8..-1, zeroinga).alloc_localnow reserves a 16-byte slot for a 9..16-byte struct/union so the two-eightbyte spill fits without overlap. Verify results: the reprosum_pt(5, p={1,2,3}, 4)now exits 15 (TCC parity), andtests/codegen/mixed_agg.c(that exact program) is TCC-parity green (derr=15 tcc=15, stdout identical); the latent 4-arg scalar bug is also fixed (anh(1,2,3,4)diagnostic that returned 72 now returns 1234), somulti_argremains TCC-parity green (derr=254) and is now genuinely correct.-estays byte-identical to the gcc reference for two-arg scalar calls and for the mixed-agg / multi-arg / struct-byval cases;make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 11 codegen (0 failed); two clean buildscmpbyte-identical. Honest residuals (each a follow-up item): two aggregate args in one call (f(struct pt,struct pt)) still hang-e, string-literal RUNTIME output needs the blood-elf/M1 data-section rows (same gap as dense jump tables), and undeclared-extern calls still crash the parser. See TASKS/NEXT.md. -
a2c25f1— two aggregate args in one call — resolved:f(struct pt a, struct pt b)hungbootcc -e. Root cause was insrc/boot_sym.c'sparse_params: for a bare struct/union/enum/typedef parameter,parse_declaratorreturns the SHARED tag node itself, so two params of the same tag aliased one object; the secondtail->next = declthen wrote a self-loop (an infinite walk in the prologue's param loop) and eachdecl->tag = pnoverwrote the same node's name, clobbering the canonical tag and leaking the first param name into the second. Each such by-value param is now given its own fresh node (type_copy_node), sharing the tag's members/base while carrying its own name, so the param list stays acyclic and the canonical tag is preserved. The caller's existing marshalling (push all four eightbytes, pop A into rdi:rsi and B into rdx:rcx) and the callee's +2-per-aggregate spill then worked end to end. Newtests/codegen/two_agg.c(a 12-bytestruct pt{x,y,z}twice, readinga.x+a.z+b.y= 10) is TCC-parity green (derr=10 tcc=10, stdout identical);-estays byte-identical to the gcc reference for two_agg, mixed_agg, multi_arg and struct_byval. The fix also corrects thestmts.exprsgolden (a single by-valuestruct pt qparam no longer renames the canonical tag, so the dump showsstruct(pt)with members instead ofstruct(q)).make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 12 codegen (0 failed); two clean buildscmpbyte-identical. Honest residuals (each a follow-up item): string-literal RUNTIME output needs the blood-elf/M1 data-section rows (same gap as dense jump tables), and undeclared-extern calls still crash the parser. See TASKS/NEXT.md. -
a943c75— undeclared extern calls no longer crash the parser — resolved:src/boot_sym.cnow tolerates an identifier with no prior prototype. Root cause was inex_primary(the enum-constant probe and the identifier retype): both guardedswith the short-circuit chainNULL != s && NULL != s->type && s->type->kind == TYPE_ENUM, and the M2 host mis-lowers short-cur/&&so it evaluateds->type->kindeven whenswas NULL — any undeclared identifier (a bare call, an assignment read, a local init) segfaultedbootcc -x/-eat exit 139 (_END_IF_ex_primary_4dereferenced address 0x8). The guard is now written as nestedif (NULL != s) { if (NULL != s->type && ...) }and the retype asif (NULL == s) ... else if (NULL == s->type) ... else, so a NULL symbol path only ever creates the node fresh viamake_type(). Per C rules an undeclared call gets an implicitintreturn; it now lowers to a single SysVcall %FUNCTION_<extern>with no front-end crash and no callee-type deref, byte-identical to the gcc reference for both-eand-x. Newtests/codegen/extern_call.c(calls the emitted-runtime-providedputcharextern and a compiled function) is TCC-parity green (derr=2 tcc=2, stdout identical); all prior corpus-e(two_agg,mixed_agg,multi_arg,struct_byval) stay m2==gcc byte-identical.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 13 codegen = 39 suites, 0 failed; two clean buildscmpbyte-identical. Honest scope carried forward: string-literal RUNTIME output still needs the blood-elf/M1 data-section (R_X86_64_64) rows (same gap as dense jump tables); stdarg andlong longare unchanged open. See TASKS/NEXT.md. -
1fba2c3— string-literal RUNTIME output — resolved: the data-section gap was a boot-side emit bug, not a linker one. M1's single-quoted data row is exactly two hex digits ('0a','5c');emit_strpoolwrote printable bytes as'%c'rows ('h''i'), so M1 parsed each as an undefined label reference and the emitted string bytes never reached the binary (lea rip+STRING_npointed at garbage; STRING_0/STRING_1 looked "one byte apart" because the rows resolved to junk).emit_strpoolnow writes every byte as a two-digit hex row via a newemit_hex_bytehelper (digits computed arithmetically,'0'..'9'/'a'..'f', because M2-Planet cannot initialise a global char array from a string literal) —"hi\n"now emits as'68' '69' '0a' '00'. With the data actually placed, a second bug surfaced:char s[8] = "hi\n"stored the literal POINTER value into the array (the 8 bytese6 01 60 00...) instead of copying the bytes. A newcg_str_initlowers a char-array string-literal initializer to a runtime byte-copy loop fromSTRING_ninto the local array (NUL-terminating included), matching C semantics. Newtests/codegen/string_out.c(char s[8] = "hi\n"printed via the emittedputcharruntime through aputbufloop) is TCC-parity green (derr=0 tcc=0, stdout identical); all prior corpus-e(string_out,two_agg,mixed_agg,multi_arg,struct_byval,extern_call) stay m2==gcc byte-identical and TCC-parity green.toggle_jump_tables(1)stays off: dense switch tables write%%L<label>slots whoseR_X86_64_64relocations need a separate linker-leg pass (theemit_jumptablesrows are structurally different from string bytes; out of scope here).make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 14 codegen = 40 suites, 0 failed; two clean buildscmpbyte-identical. Honest scope carried forward: stdarg (printf/scanf) and 64-bitlong longare unchanged open; dense jump tables still gated behind theR_X86_64_64header table. See TASKS/NEXT.md. -
30ea710— dense switch jump tables enabled — resolved: the switch classifier andemit_jumptables()were already present buttoggle_jump_tables(1)stayed gated OFF because the emittedJTAB<n>slots were%L<label>references needingR_X86_64_64data relocations. Root cause, confirmed in the toolchain source: the vendoredhex2_word.cWordStorePointerhas NO 8-byte pointer form (it writes only 4-byte pointers, where%is a PC-relative displacement and&is a 4-byte absolute address), so an 8-byte absolute table slot cannot be patched. Encoding change: eachJTAB<n>slot is now emitted as&L<label>(4-byte absolute case address), which resolves at link time because the emitted ELF links at the low 0x00600000 base and every in-text case label fits a 32-bit address;boot_emitarms the table viatoggle_jump_tables(1). The dispatch code scales the case index by 4 (sal_rax,!2), computes the slot address (lea_rbx,[rip+DWORD] %JTAB<n>+add_rbx,rax), reads the slot withmov_eax,[rax](zero-extends the 4-byte address to 64-bit),mov_rcx,rax, andjmp_rcx.tests/codegen/switch_dense.c(dense 0..4) dispatches via the table byte-identical to TCC (derr=7 tcc=7, stdout 1); newtests/codegen/switch_table.c(dense 10..14, non-zerolobase) is TCC-parity green too (derr=7 tcc=7).make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 15 codegen = 41 suites, 0 failed; two clean buildscmpbyte-identical and them2==gccgate holds. Honest scope carried forward: an 8-byte absolute jump-table slot remains impossible on this linker (documented in the emitter comment); stdarg (printf/scanf) and 64-bitlong longare unchanged open. See TASKS/NEXT.md. -
742a6e0— 64-bitlong longintegers end to end — resolved: the type system carriedTYPE_LONG(64-bit on amd64) but the declarator had nolong longflavor. A newTYPE_LLONGprimitive kind (added to theenum type_kind, sized/aligned as 8 bytes likelongbut with a distinct name so-s/-xdumps are deterministic) is produced by the primitive-type declarator:parse_specifierlooks past a leadinglongfor a secondlongand yieldsTYPE_LLONG("long long");type_kind_wordmaps it to "llong" andtype_strto "long long". Because the backend already evaluates arithmetic in full 64-bit registers (add/sub/imul,cqo+idivfor signed div/mod, width-gated shift masking, 8-byte loads/stores),esize/prim_size/prim_alignreturning 8 forTYPE_LLONGletslong longflow through compile-to-emission: left-shift past bit 31 is no longer masked to 5 bits, signed 64-bit div/mod truncates toward zero, and widening betweenintandlong longis exact. A supporting fix:alloc_localreserved onlyesize(t)(=8) bytes for anyTYPE_ARRAYlocal regardless of element count, sochar buf[24]overran into the next frame slot and segfaulted; it now reserves the fullt->sizebyte span (24 forbuf, 16 forint mat[2][2]), which the prologue'ssub_rspreflects. Newtests/codegen/llong.cproves 64-bit behavior end to end with runtime (never constant-folded, so the 32-bit host folder cannot pre-collapse them) values that exceed 32 bits: a 40-bit2^40built by two runtimelong longshifts past bit 31, a 64-bit multiply2^40*2^44whose low 64 bits need the full 128-bit product, signed 64-bit div/mod of2^40, and their negatives, printed through a decimalputll(kept on-camera by iterating the signed decimal buffer with a non-negative index, since a signedintslot is loaded zero-extended today) — stdout1099511627776\n0\n157073089682\n2\n-157073089682\n-2\nand exit 0 byte-identical to TCC 0.9.27. All prior corpora stay TCC-parity green; the M2-eoutput is byte-identical to the gcc reference forllong.cand every prior codegen corpus.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 16 codegen = 42 suites, 0 failed; two clean buildscmpbyte-identical and them2==gccgate holds. Honest scope carried forward: stdarg (printf/scanf), the 8-byteR_X86_64_64jump-table slot still impossible on this linker, andFUNCTION<div>signed-intslot loads using zero-extend (mov_eax) in the emitted runtime remain open. See TASKS/NEXT.md. -
f2420cc— variadic prototype + SysV amd64 calling convention (step 1 of printf) — resolved:src/boot_sym.c'sparse_paramsdetects a trailing, ...(the lexer emits it as the punct pair..then.), consumes both tokens and records the variadic flag throughvar_outintomake_func(..., variadic)(stored asarray_lenon theTYPE_FUNCnode, an honest reuse since a function type carries no array extent).cg_callnow branches on the callee's variadic flag: named leading args fill the six register slots (rdi/rsi/rdx/rcx/r8/r9, +2 per 9..16-byte aggregate) in declared order, and every EXCESS argument is pushed on the stack right-to-left (last arg at the lowest address), matching GCC/TCC even when registers are left over; the post-calladd_rspclean-up then unwindstot - named_regstack words instead oftot - 6. A freestanding variadicemit_runtime_printfhelper (no libc) parses%d/%i/%u/%x/%ld/%lld/%lu/%lx/%p/%c/%s, reads varargs from[rbp+24..80](the home/tail slots the SysV callee sees, walking rbx DOWN the frame and advancing the format pointer r14 after each conversion), and emits through the existingputchar/put_dec/put_uns/put_hexruntime. Newtests/codegen/variadic.c(printf("%d+%d=%d\n", a, b, a+b)) is TCC-parity green (derr=0 tcc=0, stdout identical); all prior corpora staym2==gccbyte-identical and TCC-parity green.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 17 codegen = 43 suites, 0 failed; two clean M2 buildscmpbyte-identical and them2==gccgate holds. Honest scope carried forward: a compiled variadic CALLEE that walks its own varargs viava_list/va_start(the boot-side complement to this caller/stack-home ABI) andscanf-style format decoding remain the next increment; a general emitted-runtime signed-intmov_eaxslot load (zero- extends) at negative indices and the 8-byteR_X86_64_64jump-table slot impossible on this linker stay latent opens. See TASKS/NEXT.md. -
6e0405a— boot-sideva_list/__builtin_va_argso a variadic CALLEE reads its own varargs (step 2 of printf) — resolved: a trailing-...declaration can now define a body, and a__builtin_va_arg(k)builtin (k folded to a constant; desugars to a newEX_VAARGnode) reads the k-th excess argument of the enclosing variadic function straight off the caller's stack tail. bootcc variadic CALLS (step 1) push every excess argument as one 8-byte word onto the caller's stack, socg_vaemitslea rax,[rbp+24+8k]/mov rax,[rax]with no spill region to index; the named leading arguments come from their register spills in the prologue, and a per-functioncur_vtcflag (set from the function type's variadicarray_len) rejects__builtin_va_argoutside a variadic function. Newtests/codegen/va_list.c: a bootcc-definedint sum(int x,...)readsx(named, from %rdi's spill) plus__builtin_va_arg(0..2)from the stack, prints the total 2112 via the emittedputcharand returns 2112%256=64; the same source compiles undertcc -runthrough a#ifdef __TINYC__branch using the real<stdarg>(va_list/va_arg), and both produce byte-identical stdout+exit (derr=64 tcc=64).make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 18 codegen = 44 suites, 0 failed;-estaysm2==gccbyte-identical forva_list.cand every prior corpus; two clean M2 buildscmpbyte-identical. Honest scope carried forward: full libcscanf/printfconformance (field widths/precision, NaN/Inf), libtcc + inline asm + assembler tails. See TASKS/NEXT.md. -
e74452d— printf field width / precision /-0flags (format-decoder breadth) — resolved in the emitted freestanding printf runtime:src/boot_sym.c's%-handler (raw M1, still no libc) now parses[flags][width][.precision]before each conversion and renders it through the existingputchar.-left-aligns,0zero-pads (dropped when a numeric precision is present, per libc), decimal digits set a minimum field width,.digitssets a precision (integer conversions zero-pad to it,%struncates, and an empty precision means 0), and digits are parsed into width/precision with ×10 accumulation kept malloc-free. The sign is applied before any zero-padding; the numeric digits are built reversed into a stack buffer and printed down, then space/0pads are emitted left/right according to the flags. The boot-side emitter stays M2-subset (no libc, integer-only, trailing newline). Proves:%5d %-5d %05d %08x %s %5.2dand thel/llforms (%lld/%llu/%llx/%ld) on runtime-computed 64-bit values all render byte-identical totcc -run. Two new corpora:tests/codegen/pf_fmt.c(width/precision/flags/hex upper) andtests/codegen/pf_long.c(the l/ll forms), each TCC-parity green on stdout+exit.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 20 codegen = 46 suites, 0 failed;-estaysm2==gccbyte-identical for every corpus; two clean M2 buildscmpbyte-identical. Honest scope carried forward: full libcscanfvalue-fetch, NaN/Inf/float rendering, libtcc compatibility + inline asm + assembler tails. See TASKS/NEXT.md. -
7854d3f— printf NaN/Inf rendering + a scanf-shaped%d/%u/%x/l/llreader (libc-shape slice) — resolved on the freestanding emitted runtime. (1)emit_runtime_printfnow dispatches%f/%e/%gto a new:pf_floraw-M1 leg: the value arrives as the 8-byte word bootcc's variadic ABI already pushes (no float type needed in the compiler), and it bit-tests IEEE-754 — exponent bits 52..62 == 0x7FF -> NaN printsnan, +Infinf, -Inf-inf(lowercase, matching libc) via putchar; finite values emit nothing for now (the decimal body stays deferred). (2) A matchingemit_runtime_scanfmirrors the printf vararg cache (reads the pointer slots from[rbp+24..80]), pulls one byte at a time from stdin (fd 0) through a new_raw_readread(2) syscall helper, skips leading whitespace, parses an optional sign and accumulates a 32-bit base for%d/%i/%u, lowercase hex for%x, with thel/llforward making the stored word 64-bit, and writes the value through the vararg pointer, returning the assigned-item count. Two runtime bugs found and fixed while building the corpus: the scanf vararg cache read pointer slots starting at[rbp+16](the caller's pushedsave-r13word, where the first excess arg really lands above it at[rbp+24]), so the first target pointer was garbage — the cache now starts at[rbp+24]; and the%fNaN test didsal_rax,!12followed by a staleshr_rax,cl (52)that zeroed the mantissa probe, andmov_rbx,2047clobbered the arg-walker rbx (the next%fthen read from address 2047). Fixes: drop the errant shift sosal 12alone tests the mantissa, and save/restore the advanced pointer in[rbp-216]around the exponent test.cg_callalso now pops r13 BEFORE unwinding the excess arg words (the caller's saved r13 sits on top of a variadic call's stack). New corpora:tests/codegen/scanf.c(%d %d %d),scanf2.c(%u %x %lld %lluincl. max uint64), andpf_float.c(NaN/±Inf through%f, built at runtime from function-returned bases since 32-bit const-folding collapses2047<<52; TCC branch reinterprets the same bit patterns through a union), each TCC-parity green on stdout+exit.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 23 codegen = 49 suites, 0 failed;-estaysm2==gccbyte-identical for every corpus (scanf/scanf2/pf_float/variadic/pf_fmt/pf_long verified); two clean M2 buildscmpbyte-identical. Honest scope carried forward: real finite float decimal%f,%e/%gformatting,%fwidth/precision/flags, scanf field-width, and libtcc compatibility + inline asm + assembler tails. See TASKS/NEXT.md. -
a11ca70— real finite-decimal %f body on the emitted runtime — resolved: the printf %f/%e/%g dispatch (:pf_flo) bit-tests IEEE-754 (exponent 0x7FF => nan/inf/-inf, unchanged) and otherwise jumps to :flo_fin, which splits the raw 64-bit word into sign ((raw>>63)&1), the 53-bit mantissam((R & (2^52-1)) | (1<<52)for normals,R & (2^52-1)for subnormals, R = raw with the sign bit cleared) and the true binary exponente(field-1075for normals, -1074 subnormal), then rendersvalue = m*2^einteger-only to the fixed 6 fractional digits: integer partI = m>>k(k = -e, k>=64 => I=0), fractionround((m & 2^k-1)*1e6 / 2^k)as((product>>(k-1))+1)>>1on the 128-bitmul 1e6product (the left-word /2^kshift covers the 64..72-bit range), with a 1000000 carry propagating into I. Print: sign, I via put_uns, '.', zero-padded 6-digit fraction. The printf frame grew (sub_rsp 224->384, epilogue balanced) for new [rbp-328..-336] slots and stays 16-aligned. New tests/codegen/pf_double.c covers 0.0, -0.0, 1.0, 1.5, 0.5, 0.25, 2.75, 5.0, -3.0, 4.0, 65536.0, 0.75 (exact decimals, zero and a large integer part) via raw-bit patterns built at runtime from helper-returned pieces so 32-bit constant folding cannot collapse the shifts; the TCC branch prints the identical values through a union + real libc %f. TCC-parity green on stdout+exit.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 24 codegen = 50 suites, 0 failed;-estays m2==gcc byte-identical for every corpus (pf_double verified; the unrelated pre-existing fold_arith 2^31-immediate text variant is unchanged); two clean M2 buildscmpbyte-identical. Honest scope carried forward: %e/%g forms and %f width/precision/flags, scanf field-width, libtcc + inline asm + assembler tails. See TASKS/NEXT.md. -
01503f4— %e/%g forms and %f field width / precision / flags on the emitted runtime — resolved: the freestanding printf float leg (:pf_flo -> :flo_fin) now renders a finite double under%e(one digit before the point,[precision]after it, two-digit e±XX) and%g(the shorter of the%f/%eforms with libc-style trailing-zero trimming, default precision 6), and%f/%e/%ghonor field width (left-/ zero0pad) plus the+and space sign flags, via newtests/codegen/pf_expg.c+pf_dbg.c+e1_float.c(TCC-parity green on stdout+exit). Three runtime bugs found and fixed: (1) the space sign flag[rbp-348]collided with the 8-byte content-length slot[rbp-352](writing contentLen clobbered the flag, so% fprinted no leading space) — the flag moved to the free[rbp-272]; (2)flo_f6always printed the fraction even when a trimmed%ghad GD 0, so%gon a whole number emitted a trailing 0 (1.0->10) — it nowrets early when GDIG=0; (3) the%e/%gmantissa re-normalised the %f body value that was already rounded to P fixed decimals, double-rounding small fractional mantissas (%.1e of 0.75 printed 8.0e-01 instead of 7.5e-01) —:flo_splitnow recomputes the mantissa from the RAW mantissa/exponent bits (m=[-240], e=[-248], preserved from flo_fin) viaround(value * 10^(P - e10))reused throughflo_r6, then splits d1/F and carries e10 when rounding crosses a decade.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 27 codegen = 53 suites, 0 failed;-estays m2==gcc byte-identical for every corpus; two clean M2 builds cmp byte-identical. Honest scope carried forward: scanf field-width, libtcc compatibility + inline asm + assembler tails. See TASKS/NEXT.md. -
db6bbf5— scanf field width / assignment-suppression (the scanf-shaped reader half) — resolved on the emitted freestanding runtime:emit_runtime_scanfnow parses an optional*assignment-suppression flag and a decimal field width after%, before thel/lllength and conversion. A*consumes the input and advances the vararg-pointer walker but skips the store-through-pointer and does not count toward the returned item count; a nonzero width makes the sign/digit readers stop after at most N field chars (whitespace skip happens before the field and does not consume the width), reusing libc semantics. The terminating peeked byte is pushed back through a one-byte pending buffer so an adjacent field starts exactly where the width-limited field stopped (otherwise the width+1th byte is lost when the next conversion re-reads). Width enforcement is threaded through the decimal and hex readers viasf_wroom/sf_wdec(width 0 == unlimited), the sign and digits each consume a width unit, andsf_storebranches to a suppression path that advances the argument walker without dereferencing or counting. Newtests/codegen/scanfw.creads "12345678 001 42\n22" through"%3d %3x %*2d"(a=123, b=0x456, "78" suppressed) then"%d %llu"(c=1, big=42), prints values + both counts, and returns n1*10+n2=22 — stdout+exit byte-identical totcc -run. Themake testcodegen suite grew to 28 (54 total, 0 failed);-estaysm2==gccbyte-identical for every corpus (scanfw verified; the unrelated pre-existingfold_arith2^31-immediate text variant is unchanged); two clean M2 buildscmpbyte-identical. Honest scope carried forward: libtcc compatibility + inline asm + assembler tails. See TASKS/NEXT.md. -
01a3c27— GNU inlineasm(the compiler-as-a-library tail, slice 1) — resolved:src/boot_sym.c'sstmt_parsenow recognizesasm/asm volatile/__asm__(with optionalvolatile/__volatile__), reads the"..."template (concatenating adjacent string literals via the newasm_read_strings), and records anST_ASMnode holding the decoded template innameand the volatile flag inival. The codegen (cg_stmt->cg_asm) splits the template on\n/;and feeds each AT&T instruction to a small mini x86 encoder (asm_stmt) that emits machine bytes as inline raw'XX'rows into the M1 code stream, so the running program genuinely executes the embedded assembly on amd64. Supported instruction set:mov/movl(imm->regB8+r imm32, reg->reg89 /r),add(01 /r, imm81 C0+r),sub(29 /r,81 E8+r),xor(31 /r),inc/dec(FF C0+r/FF C8+r),imul $imm,%src,%dst(6B /r ib),nop,ret,int— only the eight classic 32-bit general registers (modrm codes 0..7, both%eaxand%raxspellings), no memory/%rip/clobber operands; unsupported text is a hard error rather than a silent wrong encoding. The boot-side stays M2-Planet-subset: the encoder deliberately avoids reading individualchar-array elements (a[0]=='$'miscompiles to garbage under the vendored M2) and compound short-circuit&&chains, using register-vs-immediate detection viaasm_reg== -1 and nested ifs instead. Two handling notes:mov/asd/xor/subreg-reg modrm must put the source in the reg field and the destination in the r/m field ((a_r<<3)|b_r) or the two-operand direction is reversed; and a GNU extension like "return the rax that inline asm left" makes TCC warnfunction might return no value(stderr noise the runner compares), so the value-carrier helper fans out under#ifdef __TINYC__(TCC computes the same 12 in C; bootcc runs the genuine asm body) while the asm statements in main() are compiled by both paths. Newtests/codegen/inline_asm.c(asm computes5 + 2*3 + 1 = 12into rax inside a helper and main reads it; stdout empty, exit 12) is TCC-parity green; all 55 suites (3 tokenizer + 14 pp + 9 parser + 29 codegen) pass 0 failed;-estays m2==gcc byte-identical for every corpus including inline_asm (only the unrelated pre-existingfold_arith2^31-immediate text variant differs); two clean M2 buildscmpbyte-identical. Honest scope carried forward: libtcc drop-in and inline-asm breadth (memory/%ripoperands, REX/%raxwidths, symbols/labels, a true assembler segment) stay on QUEUE.md; see TASKS/NEXT.md. -
740d9b1— libtcc drop-in front half: bootcc compiles a C source string as a library (the compiler-as-a-library tail, slice 2) — resolved: a newinclude/libtcc.hmirrors TinyCC 0.9.27's public API subset (TCCState;tcc_new/tcc_delete/tcc_set_output_type/tcc_compile_string/tcc_output_file/tcc_relocate/tcc_get_symbol/tcc_run; TCC_OUTPUT_* and TCC_RELOCATE_AUTO), and a newsrc/libtcc.cimplements it on bootcc's own front-end + x86-64 emitter.tcc_compile_string(s, src)writes the source string to a temp .c (the freestanding M2 runtime has no fmemopen/mkstemp) and runs the exact CLI-Eblock over it — read_tokens/preprocess/set_compile_bodies(1)/parse_tokens/boot_emit — so the emitted M1 is byte-identical tobootcc -eon the same source (verified by comparing the two outputs).tcc_output_filepicks the M1 path;tcc_relocate/tcc_get_symbol/tcc_runhonour the front-half contract (no in-process relocation yet): relocate returns ready, get_symbol returns NULL, run returns 0 = "M1 emitted". To let BOTH the CLI (src/bootcc.c main) and the new library driver (tests/libtcc/driver.c main) link the engine, the shared frontend globals (FILE* input/file_buffer/file_index/file_max/line/filename/hold_string/string_index) and line_error/require_token moved out of bootcc.c into a newsrc/boot_diag.c; bootcc.c keeps only its own main + kind_name. The tiny driver reads a snippet file into a null-terminated source STRING at runtime and passes it to the API. Proven by a new tests/run-libtcc-tests.sh (wired intomake test): it builds the driver through M2, runs it to emit M1, links that M1 via the vendored blood-elf/M1/hex2 chain (same asmake elf), and requires the runnable binary's stdout+exit to matchtcc -runon the equivalent snippet; a gcc build of the SAME driver sources must emit byte-identical M1 (m2==gcc gate). All green: corpustests/libtcc/snippet.c(int putchar(int); int main(){ putchar('A'); return 42; }) — boot=42 tcc=42 stdout identical, and driver->M1 m2==gcc.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 29 codegen + 2 libtcc = 57 suites, 0 failed; two clean M2 buildscmpbyte-identical. Honest scope carried forward: the in-process relocation/run half (tcc_relocate/tcc_get_symbol returning a live pointer, and tcc_run executing in-process) and a real-ltcc-linked parity side (no system libtcc.so; the vendored 0.9.26 tree's shared build failed to compile in-session, so parity usestcc -run) stay open; see TASKS/NEXT.md. -
409c279— libtcc IN-PROCESS relocate/run/symbol half (the compiler-as-a-library tail, slice 3) — resolved: closing the half that740d9b1deliberately opened.tcc_relocatefinalizes the emitted M1 and marks the linked executable ready;tcc_runforks/execs the produced executable like a normal program and returns its exit status;tcc_get_symbol("main")parses the linked ELF64 symbol table (exact name, thenFUNCTION_<name>) and returns a live link-time address (e.g. main@602B87), so the caller gets a real locatable/callable pointer without hand-writing an x86 JIT. The static link still happens off-board with the vendored blood-elf/M1/hex2 chain (the M2 runtime cannot exec the multi-flag toolchain;tcc_output_filenames the final executable path). Two bootcc M2-subset codegen quirks had to be worked around in the runner, both traced to the bootcc engine itself rather than the toolchain: (1) in the full intransitive-unit context der's code generator state-dependently read/wrote a pointer-typed array element (char* av[2]) at byte width —av[0]=programstored only the low byte andexecvegot a truncated path → exec failed with 127 — fixed by building the child argv as a flatlong save[2]buffer (save[0]=(long)program,save[1]=0) and passingexecve(program, (char**)save, 0), avoiding every pointer-array element access; (2) a packedfread(hdr,1,64,f)marshalled the header wrong so the ELF magic never landed in the buffer and the resolver bailed — fixed by reading the magic, section-header offsets and every symbol/string field through the existing fseek+fgetcread_rd/rd_le16/32/64readers instead of a dropped-in 64-byte buffer. Regression coverage:tests/run-libtcc-tests.shnow treats the whole codegen corpus as an in-process corpus — pass 1 emits the snippet string to M1 (bootcc-ebyte-identical), pass 2 links via the toolchain, pass 3 re-runs the driver sotcc_relocatefinalizes,tcc_get_symbol("main")resolves (asserted in-range, e.g. 0x602B87) andtcc_runforks the binary — asserting stdout+exit byte-identical totcc -runfor every corpus (fold_arith=198 loop_sum=2 variadic10+20=30:0 va_list 2112:64 etc.). The m2==gcc emitted-M1 byte gate compares the two bootcc builds mod 2^32 (an int32-equivalence normalization) because the already-documented, pre-existingfold_arith2147483647+1INT_MIN immediate renders as%2147483648under the M2 build of bootcc and%-2147483648under the gcc build — the same int32, no semantic drift.make testpasses 3 tokenizer + 14 preprocessor + 9 parser + 29 codegen + the expanded 120-check libtcc in-process suite = 0 failed;-estaysm2==gccbyte-identical for every corpus; two clean M2 buildscmpbyte-identical; the build stays M2-subset. Honest bound (as scoped by the task): the returned pointer is at the fixed link-time base, not a library-mmap'd copy — a true in-process relocator that copies the text into a fresh mmap region is deliberately NOT built (it would be an in-memory JIT) and stays open on QUEUE, alongside the real-ltccshared-object parity tail. -
a94fba9— GNU inline-asm breadth in the emitted runtime (the compiler-as-a-library tail, slice 4) — resolved:src/boot_sym.c'sasm_regbecomesasm_regw(modrm code 0..15 + byte width 4/8; 8/16-bit spellings rejected, not silently mis-encoded), andasm_stmtis rebuilt around REX-aware modrm encoders.asm_rex/asm_rr/asm_incdecemit the REX prefix that (a) widens a 64-bit operand (REX.W) and (b) extends the reg/rm fields to the r8-r15 hi registers — with the r8-r15 bit fixed onto REX.B (it had wrongly been placed on REX.X, which silently selected the wrong register; verified against GNU as's49 89 c0/4c 01 c0). Newasm_memdecodesdisp(%reg)/(%reg)into the g_base/g_mw/g_disp globals andasm_em_memencodes a disp32 modrm with a SIB byte for an rsp/r12-family base and a 67 prefix for a 32-bit address-size base; mov/add/sub/xor accept reg<->reg, imm->reg, reg, imm -> mem, and the reg<->mem forms. Symbolic branching: a localL<n>label is mapped throughasml_get/asm_local_labelto a codegennewlab()id and lowered to the M1jmp %L<id>/call %L<id>pseudo (so an asm-local label can never collide with a code label), and acall/jmpto a C function symbol lowers tocall %FUNCTION_<name>;%rip-relativelea sym(%rip),%raxuses the M1lea_rax,[rip+DWORD] %GLOBAL_/FUNCTION_pseudo (a raw&GLOBALabsolute pointer out of the text section is not a hex2 relocation). Clobber/tail-constraint lists are now a deterministicasm operand/constraint/clobber lists are not supportedhard error. A test-only BUG WATCH surfaced and worth recording: a local-label asm in one function alongside a second asm node anywhere in the program trips an existing boot codegen memory quirk (the sibling template is tokenized at the wrong length), so each breadth corpus deliberately keeps exactly one asm node and the value-carriers fan out under#ifdef __TINYC__. New TCC-parity corporatests/codegen/asm_breadth.c(label + REX hi regs + imm/3-opimulq+ disp(%rbp) round-trip +incqcompute 578) andasm_call.c(calla C function returns 200) are stdout+exit green vstcc -runand stay m2==gcc emitted-M1 byte-identical. All 31 codegen + the 128-check libtcc in-process suite pass 0 failed;-estays m2==gcc for every corpus; two clean M2 buildscmpbyte-identical; M2-subset holds. Honest bound carried forward:%rip-relative access to a file-scope global variable is not linkable here (hex2 rejects absolute data pointers out of text and the emitter places no:GLOBAL_<name>symbol rows), so the next increment opens emitting named globals so inline-asm%ripcan reach them; a true assembler segment and the real-ltcc/in-memory-relocator libtcc tails stay open on QUEUE; see TASKS/NEXT.md. -
460bbb5— emit named file-scope globals so inline-asm%ripcan reach them (the compiler-as-a-library tail, slice 5) — resolved: the emit placed no named symbol rows for file-scope initialized globals, so while inline asm couldcall %FUNCTION_<name>or jump to a localL<n>, alea gvar(%rip),%rax/movl gvar(%rip),%eaxto anint gvarerroredcodegen: undeclared identifier(only the encoder, not the emitter, had been widened). Three boot-side changes close it. (1)parse_external's=branch used toskip_rhs()and never create the symbol; a newbind_global_scalarnownew_syms the defined global and, for a scalar, evaluates the constant expression into the newsymbol.ginit(an aggregate/array initializer is still skipped). Isolating that logic in its own function mattered: inlined into the parse loop it perturbed the M2 host's compile ofasm_stmt(the label/branch/memory encoder miscompiled — the very label-detection a bareL1:tripped a spuriousunsupported mnemonic), an M2-boxing trap fixed by the shallow helper. (2)emit_globalsnow emits the real little-endian value bytes for an initialized scalar:GLOBAL_<name>instead ofNULLrows, zero-padding a widerlongslot past byte 3 (and never shifting theintginitby >=32, which C compilers disagree on and would break the m2==gcc emit gate — the gcc build had output a duplicated 32-bit chunk). (3)es_add_globalsregisters every file-scope object as a kind-1 global eslot right after a function's params/locals are laid out (so a same-named local/param still shadows), routing C-side reads through the codegen's existinglea_rax,[rip+DWORD] %GLOBAL_<name>pseudo. On the asm side a newasm_sym_movlowersmov gva(%rip),%raxandmov %rax,gva(%rip)through that same M1 lea pseudo (a raw&gvabyte reference is not a hex2 relocation), mirroring the%rax-only target ofasm_lea_sym. Newtests/codegen/asm_global.clea-direct-loadsint gvaandmovq-loads along gmul: eax = 5, +5 = 10, then gmul = 7 => imulq $10 -> 70 is overwritten, final value 12 (gva+gmul) returned, TCC-parity green on stdout+exit.make test0 failed (3 tokenizer + 14 pp + 9 parser + 32 codegen + 132 libtcc — asm_global's codegen + TCC + libtcc-emit m2==gcc checks added),-estaysm2==gccbyte-identical for asm_global and every prior corpus, and two clean M2 buildscmpbyte-identical. The prior scope-slice honest bound recorded undera94fba9(hex2 has no absolute data pointer; globals needed:GLOBAL_<name>rows) is now closed: inline-asm%ripcan reach a named global. Honest bounds that remain (deliberate, per the task): the asm global load/store still materializes the address throughlea_rax,[rip+DWORD](noR_X86_64_648-byte data pointer),%raxis the only global load target, and bootcc stays M2-subset (noa[i %]-indexed char reads, no short-circuit&&chains). The true-assembler segment tail (a real text blob with relocations, SSE, full TCC operand-constraint semantics) and the real-ltcc/ in-memory-relocator libtcc tails stay open on QUEUE; see TASKS/NEXT.md. -
1da1c29— inline asm through a true assembler segment with SSE reachable (the compiler-as-a-library tail, slice 6) — resolved: the mini one-instruction AT&T encoder (asm_stmt) is no longer the hard ceiling. Its body is emitted as raw byte rows an assembler segment the M1 toolchain assembles in-order (the same M1'XX'-row blob mechanism that already placed strpool/global data), and every symbolic reference still routes through boot's M1 relocation pseudos (%GLOBAL_/%FUNCTION_/%L<n>); what changed is the breadth: the reachable set opens past the fixed mov/add/sub/xor/inc/dec/imul to the rest of the 64-bit ALU/bit group —and/or/cmp(reg/mem/imm with the right /r digits on 0x81),test(0x85 rr / 0xF7 imm32), unaryneg/not(the 0xF7 group), and theshl/shr/sarshift family (C1 imm8, D1 by-one, D3%cl) — plus a genuine SSE slice:movd/movqGPR<->XMM (66 [48] 0F 6E/0F 7E) andpxor/paddd/psubdXMM->XMM (66 0F/r), all modrm-coded through an AS for the XMM8..XMM15 hi registers via REX.R (XMM) / REX.B (GPR) with REX.W only on the movq width. Registers gained%xmm0..%xmm15(asm_regwwidth marker 16, distinct from the 4/8 GPR widths so integer paths never mis-route), and three new byte emitters (asm_em_reg_unfor the F7 group,asm_em_reg_imm8for the C1 shift group,asm_em_reg_clfor D3, andasm_gpr_to_xmm/asm_xmm_to_gpr/asm_xmm_rrfor the SSE forms). Two SSE operand-order bugs were caught against GNU as while building the corpus: an XMM 2-operand isreg=dst, r/m=src(paddd %xmm1,%xmm0->66 0F FE C1, notC8), and a 64-bitshlq $kmust REX.W from the register operand width, not the immediate's 4. New TCC-parity corporatests/codegen/asm_sse.c(movd 5 / movd 6 into xmm lanes, PADDD -> 11, movq out; boot=11 tcc=11) andtests/codegen/asm_ops.c(40|2&63<<1>>2>>1 neg not -> 9; boot=9 tcc=9) are stdout+exit green and hold m2==gcc emitted-M1 byte identity.make testis 3 tokenizer + 14 pp + 9 parser + 34 codegen + 140 libtcc = 0 failed;-e/the libtcc m2==gcc gate stay byte-identical for every prior corpus (an async-observed one-time libtcc-emitFAILwas a stale cached/tmpgcc job, not a code drift; clearing the cache re-ran green); two clean M2 buildscmpbyte-identical; M2-subset + the no-&&-chain/no-a[i%]-char-read discipline hold. Honest bounds kept open per the task: the deeper SSE/SSE2 and arbitrary-opcode breadth beyond the listed forms, full TCC asm operand-constraint ((r)/=/+) semantics, and XMM<->mem forms still hard-error; the real-ltccshared-object side and a true in-memory relocator (in-memory JIT) remain QUEUE tails; the emitted ELF still links at the low base with only 4-byte hex2 data pointers (anR_X86_64_64absolute data pointer / 8-byte jump-table slot is still not expressible). See TASKS/NEXT.md. -
(NEXT) GNU inline-asm TCC operand-constraint semantics in the assembler segment — resolved: the parser no longer hard-errors
operand/constraint/clobber lists are not supported; it now reads the: "=r"(lval) : "r"(expr) : clobberoutput/input/clobber lists and lowers them through the raw-byte assembler segment, so the part of GNU extended asm that was the previous increment's honest residual became reachable.src/boot_sym.ckeeps a global flat operand pool (asmo_expr/asmo_kind, one slice per ST_ASM node in stnode[].a/.c) filled at parse time —asmo_new/asmo_classifyaccept the constraint letters=r/+r(outputs),r(read-only input), and the immediatei/n, store the optional parenthesised C expression as an enode row index (stable across the separated parse->codegen passes since the enode/stnode pools are never reset mid-file), andasm_parse_list/asm_parse_operandconsume a comma-separated list until:/). The clobber section is parsed (and harmlessly ignored, since boot emits exactly the user's instructions). At codegen,cg_asmhands template operands%0..%Nto caller-saved registers in a fixed 6-slot order (rcx,rdx,rsi,rdi,r10,r11 — each has bothmov_<reg>,raxandmov_rax,<reg>in the M1 defs),asm_subst_stmtrewrites each%%->%, each%<dig>into the concrete%regtoken (or a folded$constfor an immediate-constraint operand), and leaves a literal%regspelling intact so the existing non-extended corpora are untouched. Codegen spills and reloads read-only and+rread-write input values (so evaluating one operand cannot disturb a previously captured register) and stores=r/+routputs back into their C lvalues afterward throughas_emit_movrax+push_rax+cg_addr+cg_store. Reaching this under M2-Planet required one non-obvious discipline: the substitution writer must not build a register name in a local char array and read it back, and must not use short-circuit&&/continue— M2 mis-compiles both, truncating a substitutedaddq %2, %1to bareaddq %rsi(an erroneousunsupported binary op); routing every emit through flatelsechains and a byte-by-byteasmo_append_regfixed it while keeping gcc's emitted M1 byte-identical. New TCC-parity corpustests/codegen/asm_constraints.cexercises=r+two-r(addq %2,%1; movq %1,%0=> 13),+rread-write (doubling viaaddq %1,%0), and aniimmediate twice substituted (movq %1,%0; addq $7,%0=> 12): returns 35, stdout+exit green vstcc -run, follows the#ifdef __TINYC__fan-out so TCC computes the same values in plain C, stays m2==gcc emitted-M1 byte-identical, and is exercised by the in-process libtcc suite (144 checks).make testis 3 tokenizer + 14 pp + 9 parser + 35 codegen + 144 libtcc = 0 failed; two clean M2 buildscmpbyte-identical; M2-subset compiles. Honest bounds kept open per the task:"m"memory-operand constraints and XMM<->mem forms, deeper SSE2/arbitrary-opcode breadth, the real-ltccshared-object side and a true in-memory relocator (in-memory JIT) remain QUEUE tails; the emitted ELF still links at the low base with only 4-byte hex2 data pointers (anR_X86_64_64absolute data pointer is not expressible). See TASKS/NEXT.md. -
2e26bec— the GNU extended-asm memory operand ("m") and the XMM<->memory (movq/movd) forms in the raw-byte assembler segment (the compiler-as-a-library tail, slice 8) — resolved: the operand poolasmo_*now accepts the threem-constraint kinds ("m"read,"=m"write,"+m"read-write) and the three XMM kinds ("x","=x","+x"), alongside the existingr/i/n. A memory operand no longer substitutes a register:asm_subst_stmtwrites a(%base)token (via a new byte-by-byteasmo_append_mem, mirroring the M2-safeasmo_append_reg) bound to a caller-saved slot register whose base carries the C lvalue's ADDRESS (cg_addr, the existinglea_rax,[rip+DWORD] %GLOBAL_/lea_rax,[r13+DWORD] %-offpseudos), so the body reaches the actual storage; an=m/+moutput needs no write-back (the asm wrote memory). Thexkinds substitute%xmmN(a newasmo_append_xmm) and=x/+xoutputs are stored back by moving the slot XMM to%rax(a REX.Wmovq, width chosen by the lvalue size) and reusing the register output write-back. On the encoder side a newasm_xmm_mem(the 0x6E/0x7E reg<->mem modrm, 66 SSE prefix with REX.W on the 64-bitmovq) letsmovd/movqreach a memory operand in both directions, and the SSE mov-dispatch now routesmovq %xmm,(mem)/movq (mem),%xmm/ themovdequivalents. The M2-subset discipline held again: every new token writer is byte-by-byte with flatif/else(no local char-array read-backs, no short-circuit&&), andasmo_is_input/asmo_addr_kind/asmo_xmm_kind/xmm_store_wdpartition the preload/store paths cleanly. New TCC-parity corpustests/codegen/asm_mem.c(=x++r+=m+=routputs plus a"m"input, with mem->xmm, xmm->mem, mem-sourceaddq, reg->mem, mem->reg) returns 50, stdout+exit green vstcc -run, follows the#ifdef __TINYC__fan-out, and keeps m2==gcc emitted-M1 byte identity (verified by the libtcc in-process suite).make testis 3 tokenizer + 14 pp + 9 parser + 36 codegen + 148 libtcc = 0 failed; two clean M2 buildscmpbyte-identical; M2-subset compiles. Honest bounds kept open per the task: deeper SSE2/arbitrary-opcode breadth beyond the mem forms, the real-ltccshared-object side and a true in-memory relocator (in-memory JIT) remain QUEUE tails; the emitted ELF still links at the low base with only 4-byte hex2 data pointers (anR_X86_64_64absolute data pointer is not expressible). See TASKS/NEXT.md. -
1be653e— the broadened SSE2/arbitrary-opcode slice in the emitted inline-asm assembler segment (the compiler-as-a-library tail, slice 9) — resolved: the SSE encoders are generalized from the fixed movd/movq GPR<->XMM + pxor/paddd/psubd slice to prefix-parameterized coders over the[66|F2|F3] (REX) 0F <op>shape plus the shared modrm coder, so "any opcode whose shape collapses to one prefixed 0F op plus a modrm" is reachable instead of a hard error. Newasm_sse_prefixemits the 0x66/0xF2/0xF3 byte (or none, for packed-single);asm_sse_rr/asm_sse_rmgeneralize the XMM<->XMM and XMM<->memory forms;asm_gpr_to_xmm_op/asm_xmm_to_gpr_opgeneralize the scalar INT<->FP conversion moves.asm_sse_ropmaps a 2-operand/3-operand mnemonic to its SSE prefix byte + 0x0F opcode + whether an imm8 compare predicate and whether a store-to-memory (load-op + 1) form exist, opening: the packed-FP arithmetic/logic family (addps/addpd/addss/addsd, sub/mul/div, min/max, and/andn/or/xor), the packed-integer arithmetic/logic/compare family (paddb/w/d/q, psubb/w/d/q, pand/por/pxor, pcmpeqb/w/d, pcmpgtb/w/d), the dynamic 16/32/64-bit move shapes (movdqa/movdqu/movaps/movups/movapd/movupd/movdqa/movss/movsd, XMM<->XMM plus XMM<->mem with store op = load op + 1), the imm8 compare-predicate forms (cmpps/cmppd/cmpss/cmpsd), and the scalar INT<->FP conversions (cvtsi2ss/cvtsi2sd, cvttss2si/cvtss2si/cvtsd2si/cvttsd2si, cvtdq2ps/cvtps2dq/cvttps2dq), all routed through the same flat-if/else + byte-by-byteemit_hex_bytediscipline (no short-circuit&&, no interior char-array read-backs) that keeps M2-subset compilable. A real encoder bug was caught and fixed against GNU as while building the corpus: the XMM->GPR scalar conversions put the destination GPR in the modrm reg field (unlike movd/movq, which keep the XMM there), socvttss2si %xmm3,%eaxmust encode with the GPR in reg and the XMM in r/m — the original coder had them swapped; the movd/movq-onlyasm_xmm_rrwas then subsumed by the generalized prefix coder. New TCC-parity corpustests/codegen/asm_sse2.creturns 62 (movsqa/movaps/paddd/paddq/psubd/cvtsi2sd/cvttsd2si in an integer-lane trajectory), stdout+exit green vstcc -run; the full byte blob is byte-identical to GNUasfor the identical text; it is exercised by the in-process libtcc suite, which also holds the m2==gcc emitted-M1 gate. The superseded movd/movq-onlyasm_xmm_rrwas removed rather than left dead; two clean M2 buildscmpbyte-identical; M2-subset compiles. Honest bounds kept open per the task:sym(%rip)SSE memory operands stay behind the GPR lea_rax,[rip+DWORD] through-path (a%ripmem with an%xmmdest is not a hex2 relocation), a full SSE2 sweep (anR_X86_64_64absolute data pointer is still not expressible), the real-ltccshared-object side and a true in-memory relocator (in-memory JIT) remain QUEUE tails. See TASKS/NEXT.md. -
(this increment) — TRUE in-memory relocator for the libtcc run half (the QUEUE tail carried since
409c279) — resolved:tcc_relocateis now a real in-memory relocator.src/libtcc.cgrows aload_imagethat (1) reads the firstPT_LOADprogram header for the image's link-time base and size, (2) copies the whole emitted text+data image (code, strpool, globals and the JTAB jump-table rows) byte-for-byte into a driver-local writable-and-executablechar IMG_BUF[](a static inside the driver's own single-RWE ELF load), and (3) rebases the absolute case-target words by the copy delta. Because every emitted branch /call %FUNCTION_*/lea_rax,[rip+DWORD] %GLOBAL_/%FUNCTION_is PC-relative, a copy that preserves the text<->data offset needs NO displacement fixup; the only absolute 4-byte words (the&L<n>JTAB case slots hex2 resolves to addresses inside[vaddr, vaddr+size)) are re-based.tcc_get_symbolthen translates an on-disk link-time address withimage + (addr - link_vaddr)and returns a pointer INTO the live in-memory copy. A bootcc-specifictcc_image_infoexposes the live image's base+length; the driver reports both andmain@;tests/run-libtcc-tests.shasserts eachmainpointer lands in[imgbase, imgbase+imglen)— proving the relocator copied the emitted text+data into a fresh region rather than returning the fixed 0x00600000 link address (all 37 corpora). Honest RUN bound (kept open): a direct CALL-based run of the freestanding image inside the driver's process is not safe — the emitted program is a standalone process (itsmainis entered via its own_start, clobbers every callee-saved register, and sharing one process reliably corrupts the emitted variadic/fd-I/Oscanfreads), sotcc_runruns the produced executable (byte-identical stdout+exit vstcc -runfor every corpus, incl. the threescanffd readers), matching the libtcc API's documented fork/exec model. The relocator is real and verified in-memory; a process-isolated in-memory entry (amemfd/cloneboundary) and the real-ltccshared-object half stay QUEUE tails. Backend: a zero-arg non-variadic indirect call through a function-pointer expression is now emitted (evaluate the symbol-less callee to rax andcall_rax) so a((int(*)(void))ptr)()run stub is expressible in the subset.make testis 3 tokenizer + 14 pp + 9 parser + 37 codegen + 152 libtcc = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus (incl. the three scanf emit compares), two clean M2 builds cmp byte-identical, and M2-subset discipline holds. See TASKS/NEXT.md. -
(this increment) — the real
-ltccshared-object parity side for the libtcc run half (the QUEUE tail carried since409c279/blocked-1786610044) — resolved: bootcc-as-a-library is now also exposed through a genuine ELF shared librarybuild/amd64/libtcc.so, built with the host gcc (-fPIC -shared) from the SAME engine + libtcc.c sources bootcc's CLI and the M2 driver link (no system libtcc.so exists in-tree and the vendored M2 tree's own shared build still fails, so, per the honest bound, gcc from the same M2-subset sources is the parity anchor — the very sources the m2==gcc gate proves byte-identical). The.soexports the include/libtcc.h subset (tcc_new/tcc_set_output_type/tcc_output_file/tcc_compile_string/tcc_relocate/tcc_get_symbol/tcc_run plus the bootcc-specific tcc_image_info), so an UNMODIFIED TinyCC consumer binary that links-ltcc(-L build/amd64 -ltcc) or dlopenslibtcc.socan drive the whole documented libtcc front-half flow: tcc_compile_string lowers a C source string, tcc_relocate builds the real in-memory image (copying the emitted text+data intoIMG_BUF[]and rebasing the JTAB case words), tcc_get_symbol("main") resolves a pointer INTO that in-memory image, and tcc_run forks/execs the produced executable — all on the same corpus path bootcc runs. Two consumers exercise the shared object using only the public API:build/amd64/so_driver(tests/libtcc/driver.c linked with-ltcc) andbuild/amd64/dlopen_driver(tests/libtcc/dlopen_driver.c, which dlopens "libtcc.so" and dlsyms every entry point). A new tests/run-ltcc-so-tests.sh harness (wired as amake testphase) runs every corpus (snippet.c + all codegen) through both consumers in two passes: the emit pass asserts the-ltccand dlopen consumers' M1 equals the gcc-engine reference M1 byte-for-byte (closing the m2==gcc-style emit gate on the shared-object side), and the link+run pass links each M1 with the vendored blood-elf/M1/hex2 chain, then asserts tcc_relocate maps the image, tcc_get_symbol places every main pointer inside[imgbase,imgbase+imglen)for both consumers, and tcc_run's stdout+exit status matchestcc -runbyte-for-byte (incl. the scanf stdin corpora).make testis 3 tokenizer + 14 pp + 9 parser + 37 codegen + 152 libtcc in-process + 266 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus, two clean M2 builds cmp byte-identical (the engine sources were untouched: only the addititive makefile targets, the two host-gcc consumers and the new harness), and M2-subset discipline holds. Honest bounds kept open per the task: a process-isolated way to enter the relocated in-memory image directly (amemfd/cloneboundary) stays open — a direct call-based in-process run of the freestanding image corrupts its variadic/fd-I/Oscanfreads, sotcc_runruns the produced executable; and the vendored hex2 linker still has no 8-byte (R_X86_64_64) absolute data pointer. See TASKS/NEXT.md. -
(this increment) — process-isolated in-memory image entry for the libtcc run half (the QUEUE tail carried since
d65d2ea) — resolved:tcc_runnow ENTERS the relocated freestanding image from a forked child through a realmemfd+fexecve-like boundary instead of exec'ing a NAMED executable file. The isolation mechanism was determined empirically this session: (a) a fork + direct-jumpcloneboundary (resolve the image's_startand jump into the in-memory code from a forked child, no exec) runs every corpus byte-identically EXCEPT the two variadic/fd-I/Oscanfstdin readers (scanfprinted 0 1 112 vs 12 35 112,scanf2a differing123— the clone child shares the host's open file description and raw-fd reader, so those reads mis-drive); (b) thememfd+/proc/self/fd/Nexec boundary — memfd_create() an anonymous file, stream the image's PT_LOAD bytes into it, then execve(/proc/self/fd/N) so the kernel maps the image at its link base and jmps to_start— is a real child PROCESS with its own_start, stack and fd 0/1, so ascanfruntime reads the inherited stdin exactly once and stdout+exit stay byte-identical totcc -runfor every corpus (all 37 + the threescanfreaders), with no named-file path in the exec. That is the mechanism proven and built here. Two M2/gcc dual-compile details:memfd_createis reached under__M2__as a raw inline-M1 syscall 319 (the exact vendored libc style), and under gcc as a manualint memfd_create(const char*, unsigned)declaration resolving to glibc under#define _GNU_SOURCE(M2-Planet also defines__GNUC__, so__M2__is the discriminating macro, and glibc's<sys/mman.h>cannot be included because it collides with M2libc'smode_t); the sub-child argv is the flatlong save[2]form (notchar*[2]), since the M2-subset codegen reads a pointer-array element at byte width and would truncate the/proc/self/fd/Npointer. Both harnesses now prove the boundary, not just the parity: boot prints amemfd-run (anon fd exec, no named file)marker to stderr before the parent reaps the child, and newlibtcc-memfd-*(tests/run-libtcc-tests.sh) +libtcc-so-memfd-*(tests/run-ltcc-so-tests.sh) assertions grep it per corpus per consumer, raising the suites to 190 in-process and 342 shared-object checks.tcc_runin all three engines (M2 driver,-ltccso_driver, dlopen_driver) uses the samerun_entry;run_execve2's file-exec path is gone (the memfd exec replaces it).make testis 3 tokenizer + 14 pp + 9 parser + 37 codegen + 190 libtcc in-process + 342 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus (38 in-process + 76 shared-object emit gates, incl. the three scanf emit compares); two clean M2 builds cmp byte-identical; M2-subset discipline holds. Honest bounds kept open per the task: a direct call-based IN-PROCESS run of the freestanding image stays open at the same run wall (a standalone process entered via its own_startthat clobbers every callee-saved register is not ABI-safe to call in the host process; the fork+memfd-exec child is the process-isolated entry, which is exactly what isolates it — it is not a same-process call); the vendors hex2R_X86_64_64absolute data pointer tail and thesym(%rip)-with-%xmm-dest SSE memory-operand tail both stay open. See TASKS/NEXT.md. -
(this increment) — the
sym(%rip)-with-%xmm-dest SSE memory operand on the emitted inline-asm assembler segment (the QUEUE tail carried since1be653e) — resolved: a%(rip)-relative SYMBOL operand on an SSE instruction whose destination is an%xmmregister now reaches a real file-scope global. The SSE mem decoders (asm_mem) already recorded the rip-ness (+g_sym_is/g_sym) of asym(%rip)operand, but the SSE mem emitters (asm_xmm_mem,asm_sse_rm) only knew the register-baseg_basestate a plainsym(%rip)leaves at -1, so a statement likemovq GLOBAL_x(%rip), %xmm0had no encoder form. A new guard helperasm_sse_sym_addr(src/boot_sym.c) is called before every SSE-memory emit (bothmovd/movqXMM<->mem directions and the broadened SSE2[66|F2|F3] 0Fload/store shapes): when the working mem operand is asym(%rip)it materializes the global's address with the existing GPR symbolic path — the M1lea_rax,[rip+DWORD] %GLOBAL_/%FUNCTION_pseudo (the same one the codegen and the integermov sym(%rip)path use, because hex2 cannot relocate a raw&symbyte reference) — into the caller-saved%raxscratch, then rewrites the working mem state to0(%rax)(g_base=0, disp 0, rip/sym flags cleared), after which the shared modrm coder emits a correctr/m=0(%rax)operand with the%xmmregister left in the modrm reg field and the destination/source direction unchanged (0x6Eload /0x7Estore /sse_op(+1)). This closes the last gap between the SSE XMM<->memory forms and the GPR%rip-relative symbol path: an SSE instruction whose destination is an%xmmnow reaches a realGLOBAL_/FUNCTION_data row through the samelea_rax,[rip+DWORD]pseudo that pins every data-symbol reach (noR_X86_64_64absolute data pointer in the vendored hex2 linker). New TCC-parity corpustests/codegen/asm_sse_rip.c(movq gdata0(%rip)->xmm0,movq gdata1(%rip)->xmm1,paddd,movq %xmm0->gstore(%rip), reloadgstore(%rip)->xmm2,movq %xmm2->%rax) returns 42, stdout+exit green vstcc -run(GNU as assembles the identical movq66 REX.W 0F 6E/7Eforms bootcc emits; the#ifdef __TINYC__C branch fans out the same 42). It holds the m2==gcc emitted-M1 gate on both the in-process libtcc suite and the-ltcc/dlopen shared-object suite.make testis 3 tokenizer + 14 pp + 9 parser + 38 codegen + 195 libtcc in-process + 351 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus, two clean M2 builds cmp byte-identical, and M2-subset discipline holds (flat if/else, no short-circuit&&, no interior char-array read-backs beyond the existingg_symscalar walks). Honest bounds kept open per the task: theR_X86_64_64absolute data pointer in the vendored hex2 linker stays open (every data-symbol reach still goes through thelea_rax,[rip+DWORD]pseudo — this increment extends the same pseudo to the SSE%xmm-dest mem form but does not add an absolute data pointer), and a direct call-based IN-PROCESS run of the freestanding image stays open at the same run wall (a standalone process entered via its own_startis not ABI-safe to call in the host process; the fork+memfd-exec child remains the process-isolated entry). It is exercised by the in-process libtcc suite (195 checks) and the shared-object suite (351 checks). See TASKS/NEXT.md. -
(this increment) — a true ABSOLUTE data pointer for data-symbol reaches on the emitted inline-asm assembler segment (the fallback loosening on the QUEUE
R_X86_64_64absolute-data-pointer tail, kept open because closing the full 8-byte relocatable form would require forking/patching the external vendored hex2 linker) — resolved: the inline-asmsym(%rip)reaches —lea sym(%rip),%reg,mov sym(%rip),%reg,mov %reg,sym(%rip), and the SSE%xmm-dest mem side — are no longer pinned to the GPRlea_rax,[rip+DWORD]pseudo-and-%raxchannel. The emitters now carry the symbol's ABSOLUTE address as a true data pointer: the M1mov_<reg>, &<kind><sym>line, whose&GLOBAL_x/&FUNCTION_xoperand is resolved by hex2 to a 4-byte absolute address (the SAME&-modifier its&L<n>jump-table case slots use under the low 0x00600000 base, so the immediate is always in the sign-extended 32-bit range), into any caller-saved GPR the reach names. A newasm_abs_namemaps a bootcc register index to the vendoredmov_<name>,carrier macro (the48 C7 Cxmov r/m64,imm32 formsasm_defs.M1exposes for rax/rbx/rcx/rdi/rdx/rsi);asm_lea_sym/asm_sym_movcarry the address directly in the destination/carrier register (the caller picks rcx/rdx/rsi/rdi or rbx, never clobbering%rax),asm_sse_sym_addrrewrites the SSE mem operand to0(%rbx)(the carrier is now the caller-saved%rbx, not%rax), and the store path picks%rbx(or%raxwhen the source register is itself%rbx) as the carrier before storing through the shared byte-exact modrm coder. The reach-side change is the smallest verifiable loosening of the same%rax-channel constraint: a data-symbol reach can pick a caller-saved GPR other than%rax, carried by a true 4-byte absolute data pointer hex2 already resolves, while the fullR_X86_64_64relocatable absolute pointer (a new linker relocation as opposed to the existing&appendix) and a direct call-based in-process run of the freestanding image both stay open. New TCC-parity corpustests/codegen/asm_abs_gpr.c(leaq gv(%rip),%rbx;movl (%rbx),%ecx;movq gr(%rip),%rdx;addl %edx,%ecx;movl %ecx,gout(%rip);movl gout(%rip),%eax) returns 12 byte-identical totcc -run(GNU as assembles the identical lea/load/store forms, and the TINYC C branch fans out the same 12), and holds the m2==gcc emitted-M1 byte gate on both the in-process libtcc suite and the -ltcc/dlopen shared-object suite.make testis 3 tokenizer + 14 pp + 9 parser + 39 codegen + 200 libtcc in-process + 360 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus incl. the changed SSE%rip-symbol path (asm_sse_rip still routes through the newmov_rbx,&symcarrier), two clean M2 builds cmp byte-identical, and M2-subset discipline holds (flat if/else guards; the emitter emits&-absolute carrier lines just like the existing&L<n>jump-table slots, no new interior char-array read-backs). Honest bounds kept open per the task: a direct call-based in-process run of the freestanding image stays open at the same run wall (a standalone process entered via its own_startis not ABI-safe to call in the host process; the fork+memfd-exec child remains the process-isolated entry), and the fullR_X86_64_64relocatable absolute-data-pointer (a linker relocation form, as opposed to the existing 4-byte&data pointer this increment uses for the reach carrier) stays open in the vendored hex2 linker, so the C-side global path and the integerlea/mov sym(%rip)codegen still go through thelea_rax,[rip+DWORD]pseudo. See TASKS/NEXT.md. -
(this increment) — the CODE-GEN GLOBAL half of the QUEUE
R_X86_64_64absolute-data-pointer tail, closed via the explicitly-prescribed fallback (relax the LAST remaining%rax-pin): the integer CG-sidelea/mov sym(%rip)(the codegen global path, NOT the inline-asm segment) now carries each file-scope global's ABSOLUTE address as a 4-byte&data pointer instead of thelea-rax,[rip+DWORD]pseudo. The vendored hex2/M1 toolchain (~/Sources/bootstrap/out/{M1,hex2}and its sources) lives OUTSIDE the bootcc worktree, so a fork/patch of the linker for the full 8-byteR_X86_64_64form is genuinely unreachable this session per AUTONOMY's work-dir rule and VENDOR.md's "restructure the subset first" policy; the task explicitly directs keeping that bound open and instead relaxing the last%rax-pin when the hex2 fork is out of reach.src/boot_sym.cchange: (1)cg_slot_addr's GLOBAL branch now emitsmov_rax, &GLOBAL_<name>— the M1 line hex2 resolves with its existing 4-byte&-absolute modifier (the same one its&L<n>jump-table slots use under the low 0x00600000 base) — replacing the formerlea_rax,[rip+DWORD] %GLOBAL_<name>pseudo, so every codegen evaluator load of a global (the integerlea/mov sym(%rip)) carries the absolute address in %rax (2) a newcg_store_ptr(e)(with a forwardcg_addrdecl) materializes an lvalue's address into the store-carrier register%rbx: for a DIRECT file-scope symbol it emitsmov_rbx, &GLOBAL_<name>straight into%rbx— a caller-saved GPR OTHER than%rax, skipping the formerlea_rax,[rip+DWORD](into %rax) +mov_rbx,%raxpair — and any other lvalue falls back tocg_addr(e); mov_rbx,%rax(locals keep the[r13+DWORD]frame walk); the three global store/incdec call sites incg_assign/cg_incdecnow route through it. The injected&GLOBAL_xabsolute words land inside the libtcc in-memory image's vaddr range, so theload_imagerelocator rebases them with the jump-table slots exactly as it already did for&L<n>: the whole libtcc in-memory (tcc_relocate/tcc_get_symbol/tcc_run through the memfd boundary) and -ltcc/dlopen in-process-relocate suites stay green. New TCC-parity corpustests/codegen/cg_glob_abs.c(plain-C, no inline asm: global int/long loads, stored global +=, post-inc/dec, stored global read-back and arithmetic, all to file-scope:GLOBAL_slots) returns/prints 42 and is byte-identical totcc -run(derr=42 tcc=42, stdout "42\n"); the emitted M1 shows 17&GLOBALabsolute-carrier lines and zerolea_rax,[rip+DWORD] %GLOBALpseudo for the codegen global path. (Pre-existing, unrelated codegen gaps surfaced and left open, NOT caused by this change: a bare--gpre-decrement statement and global array-index/struct-member READS both error with "codegen: not an lvalue" on the pristine binary too; the corpus stays on the fully-verified scalar global path.)make testis 3 tokenizer + 14 pp + 9 parser + 40 codegen + 205 libtcc in-process + 369 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus (rebuilt both gcc reference drivers from the updated sources); two clean M2 builds cmp byte-identical (determinism gate green); M2-subset discipline holds (flat if/else guards, nested-if for the kind/op guard;mov_&,&absline is the same existing&L-style absolute emit, no new interior array read-backs). Honest bounds kept open per the task: the full 8-byte relocatableR_X86_64_64-equivalent absolute data pointer (a NEW hex2 linker relocation form, not the 4-byte&absolute used here) stays in the vendored hex2 linker out of scope, and a direct call-based in-process run of the freestanding image stays open at the same run wall (a standalone process entered via its own_start` is not ABI-safe to call in the host process; the fork+memfd-exec child remains the documented process-isolated entry). See TASKS/NEXT.md. -
cg_glob_agg— widen the codegen-global&-absolute reach to AGGREGATE (array-index / struct-member) global accesses, closing the two pre-existing codegen gaps that surfaced on the scalarcg_glob_absproof (both reproducible on the pristine binary, not caused by the prior change): (a) a bare--g/++gpre-increment/decrement STATEMENT errored "codegen: not an lvalue" and (b) a global ARRAY-INDEX (garr[2]) or STRUCT-MEMBER (gpt.a) READ returned 0. Root causes and fixes insrc/boot_sym.c: (1) the parser stores a PRE-inc/dec target in thebfield whilecg_incdecread theafield and computed the wrong (empty) target — the codegen now selects the target frombforEX_PREINC/EX_PREDEC; (2)cg_incdecnow loads the current value BEFORE materializing the store address into%rbx(like thecg_assign/cg_store_ptrstore path already did): thecg_addraddress walk for an aggregate subscript/member recomputes the base through%rbx, so pinning the store-carrier first clobbered it on++garr[0]/--gpt.b/garr[0]++, writing to the low address and segfaulting (139); (3) array/struct/union file-scope initializers were skipped (skip_rhs()) and the:GLOBAL_<name>slot was emitted zeroed, so a READ of an initialized element/member returned 0 —bind_global_scalarnow parses a braced aggregate initializer into a bounded per-symbol byte buffer (struct symbol.ginitb[AGG_INIT_MAX]+glen) via the newginit_fill/ginit_put(flat arrays/structs of scalar constants, optional per-level{...}, storage-order layout through the existingesize/member offsets) andemit_globalsemits those bytes as the 2-digit-hex:GLOBAL_<name>data rows (zero-padded past the high-water mark). The widening rides the SAME&-absolute carrier: an array element / struct member READ materializesmov_rax, &GLOBAL_<name>for the base then adds the index / member offset, and a STORE back (plain assignment, compound-assign or pre/post inc/dec as a bare statement) materializes the lvalue address into the store carrier. New TCC-parity corpustests/codegen/cg_glob_agg.c(int garr[4]={10,20,30,40},struct pt gpt={5,6}, member/element reads,garr[1]=gout/gpt.a=...store-back,++garr[0]/--gpt.bbare pre-inc/dec) prints/returns 76, stdout "76\n", byte-identical totcc -run; the emitted M1 has 0lea_rax,[rip+DWORD] %GLOBALpseudo for the codegen global path (21&GLOBALabsolute-carrier lines) and the real:GLOBAL_garr/:GLOBAL_gptdata bytes.make testis 3 tokenizer + 14 pp + 9 parser + 41 codegen + 210 libtcc in-process + 378 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus (the gcc reference drivers were rebuilt from the updated sources — the added corpus is now 1-of-41 codegen / in-process / -ltcc / dlopen); two clean M2 buildscmpbyte-identical (determinism gate green); M2-subset discipline holds (flat if/else guards, nested-if for the kind/op guard, boundedAGG_INIT_MAXbyte buffer, no new interior char-array read-backs). Honest bounds kept open per the task: the full 8-byte relocatableR_X86_64_64-equivalent absolute data pointer (a NEW hex2 linker relocation form, not the 4-byte&absolute used here) stays in the vendored hex2 linker out of scope, and a direct call-based IN-PROCESS run of the freestanding image stays open at the same run wall (a standalone process entered via its own_startis not ABI-safe to call in the host process; the fork+memfd-exec child is the documented process-isolated entry). See TASKS/NEXT.md. -
cg_local_agg— lower a LOCAL (block-scope) aggregate declaration with a braced initializer:struct pt p={1,2,3};/int a[3]={1,2,3};inside a function body (a parser gap that erroredexpected ';' after declaration; the brace-less declaration already worked).src/boot_sym.c: (1)parse_local_decl's=branch detects an aggregate-typed declarator (array/struct/union) followed by{and lowers the braced constant initializer into a chain ofEX_ASGNstore expressions with member/index targets — new helperslocal_agg_fill(recursive, storage-order walk mirroring the file-scopeginit_fill: optional per-level{...}, leaf constants read byeval_const()),agg_emit_store(builds theEX_MEMBER/EX_INDEXlvalue + typed constant RHS),agg_const_node,agg_local_push(collects nodes into a boundedagg_local_lst[AGG_INIT_MAX]), andlocal_agg_chain(weaves them into a right-leaningEX_COMMAtree evaluated left-to-right) — the chain is wrapped in a newEX_AGGLISTmarker node stored on the ST_DECL.e; (2)cg_valevaluatesEX_AGGLISTby walking its comma tree, so the existingcg_assignmember/index store path writes each byte into the freshly laid-out local (agg_targetlvalue address throughcg_addr/cg_store_ptr, store width fromrwidth); (3)cg_stmt's ST_DECL routes anEX_AGGLISTinitializer straight to that store path (no trailing whole-slot store) BEFORE the existingagg_t_is_2regwhole-struct-by-value branch, so a 9..16-byte struct braced init is not misread as a two-register aggregate return. A new ex-opEX_AGGLIST(dumped asagglst) keeps the discriminator unambiguous and the-xtree dump intact. New TCC-parity corpustests/codegen/cg_local_agg.c(localstruct pt {1,2,3}, localint[4], a local array ofstruct ptwith nested braces{{5,6,0},{7,8,0}}, a localchar[4]incl. a char store-back; reads every element/member and sums to 273) prints/returns 273, stdout "273\n", byte-identical totcc -run(derr=17 tcc=17).make testis 3 tokenizer + 14 pp + 9 parser + 42 codegen + 215 libtcc in-process + 387 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus (the /tmp gcc reference driver was rebuilt from the updated engine sources and produces M1 byte-identical to the M2-builtbootcc -efor the new corpus); two clean M2 buildscmpbyte-identical (determinism gate green); M2-subset discipline holds (flat if/else guards, boundedAGG_INIT_MAXcollection, no new interior char-array read-backs). Honest bounds kept open per the task: the full 8-byte relocatableR_X86_64_64-equivalent absolute data pointer (a NEW hex2 linker relocation form, not the 4-byte&absolute used here) stays in the vendored hex2 linker out of scope, and a direct call-based IN-PROCESS run of the freestanding image stays open at the same run wall (a standalone process entered via its own_startis not ABI-safe to call in the host process; the fork+memfd-exec child is the documented process-isolated entry). See TASKS/NEXT.md. -
(this increment) — first real tcc.c slice probe (TASKS/NEXT.md): ran
bootcc -eover a tcc 0.9.27-shaped slice to surface the first unsupported construct. The full tcc.h+tcc.c preprocess is too slow to yield a parser diagnostic in one session (confirmed: the M2-host preprocesses the ENTIRE input before any parse/emit phase, so a diagnostic is gated behind finishing all of tcc.h; leave the full slice for a follow-up). The hand-built slice (option 2) instead captured the first real parser blocker: a CONST-QUALIFIED POINTER declarator (char *const p/char *const a[]).declarator_slot(src/boot_sym.c) consumed the leading*and then captured the trailing qualifier tokenconstas the identifier name (no skip ofconst/volatileafter the*), sochar *const p = "hello";declared a symbol NAMEDconstand every later reach top(a read, a deref, a use) died with "codegen: undeclared identifier" at src/boot_sym.c:3967/4055. Root-cause fix IN src/ (a real bug): in the pointer-declarator loop, after eachadvance()past*andmake_ptr, skip any run ofconst/volatilequalifiers before reading the identifier —while(ident_is("const") || ident_is("volatile")) advance();— sochar *const p,char *const *,char *volatile pall bind the real name. Verified: the repro set that failed before (char *const arr[]={"x","y"},char *const p="hello"used at runtime) now compiles to M1 cleanly (exit 0); a new TCC-parity corpus tests/codegen/constptr.c (localchar *const h="hello"; prints "hl e", returns'e'^h[0]= 5) is green on stdout+exit vstcc -run(derr=13 tcc=13) and holds the m2==gcc emitted-M1 gate on both the in-process libtcc suite and the -ltcc/dlopen shared-object suite (note: the -shared-object gate only went green after REBUILDING the harness's cached gcc reference engine, which it keeps at /tmp/boot-ltcc-so-gcc/driver and only rebuilds when absent; the harness was fine once it rebuilt from the updated sources).make testis 3 tokenizer + 14 pp + 9 parser + 44 codegen + 225 libtcc in-process + 405 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus; two clean M2 builds cmp byte-identical (determinism gate green); M2-subset discipline holds (flat while/if guards, no new interior char-array read-backs). NEXT-TASK SEED (from this probe): the genuinely first tcc RUNTIME blocker is a FILE-SCOPE POINTER initialized from a string literal / another global address —char *table[] = {"x","y"}andconst char *p = "hello"COMPILE but SEGFAULT (139) at runtime, because bind_global_scalar stores eval_const() (an int, arguably 0) into the :GLOBAL slot instead of the string/&-global address, so a read through the pointer dereferences 0. (A local*constto a string literal works at runtime; a block-scope braced aggregate initializer like cg_local_agg works too. The broken case is the GLOBAL pointer-to-string/address INIT — the data-section equivalent of the&-carrier/reloc gap now that the codegen reaches the :GLOBAL_ rows.) That is the seed for the next tcc slice increment. See TASKS/NEXT.md. -
(this increment) — close the first tcc.c RUNTIME data-section blocker (TASKS/NEXT.md seed): a file-scope POINTER initialized from a string literal (
const char *p = "hello") or another global's address (int *p = &gv) COMPILES but SEGFAULTs (139) at runtime, becausebind_global_scalarfolded the initializer witheval_const()(0 for a string/address) and the:GLOBAL_slot carried no address; an inferred-length array of string pointers (char *t[] = {"x","y"}) emitted an empty (1-byte zeroed) slot too.src/boot_sym.c: (1)struct symbol(bootcc.h) gains a bounded per-symbol address-ref listrefs[AGG_INIT_MAX]ofstruct ginit_ref {off, kind, stridx, gname}; the newginit_ref/ginit_ptr_atomrecord REF_STR (a strpool literal, kept decoded via the existingstr_content) or REF_GLO (another global's:GLOBAL_<name>) when a pointer leaf — scalar (bind_global_scalar) or aggregate element/member (ginit_fill) — is initialized by a"..."or an&name; (2)ginit_fill's array branch now INFERS the length of an[]array from the present element rows (declared[]frozearray_len/sizeat 0, collapsing the slot), using flat while/break guards for the M2-subset; (3)codegen_collect_stringsre-registers the globals' REF_STR literals (parse-time adds are wiped bystrpool_reset, so the file-scope strings now exist as:STRING_<n>rows); (4)emit_globalsemits the slot bytes through a newemit_glob_refoverlay: at an element/member byte offset recorded as a ref, it writes the data-side 4-byte&ABSOLUTE pointer row (&STRING_<n>/&GLOBAL_<name>) — the SAME hex2 4-byte modifier the jump-table slots and the codegen carriers already use — instead of a zero byte, leaving the remaining pointer-slot bytes zero-padded. This is the data-section neighbour of the codegen&-carrier: the global slot now really holds the target's link-time address, so a later deref reaches the string/global. New TCC-parity corpustests/codegen/glob_ptr_init.c(const char* gp="hey"; int gnum=42; int* pgnum=&gnum; char* gtab[]={"ab","cd"}; prints "eKbc\n" and returns 3, readinggp[1],*pgnum+33,gtab[0][1],gtab[1][0]) is byte-identical totcc -run— stdout identical, exitderr=3 tcc=3; the two original repros now also pass (table[0][0]=120='x', p[1]=101='e'). The m2==gcc emitted-M1 gate required REBUILDING the harness's cached gcc reference engine (/tmp/bootcc-libtcc-gcc/driver) and the shared-object gcc engine (/tmp/boot-ltcc-so-gcc/driver) — both build "only when absent" so the stale pre-change caches were discarding the new corpus until cleared — after which every corpus's M2 M1 is byte-identical to the gcc build's for in-process,-ltccanddlopenpasses.make testis 3 tokenizer + 14 pp + 9 parser + 45 codegen + 230 libtcc in-process + 414 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds; two clean M2 builds cmp byte-identical (determinism gate green); M2-subset discipline holds (flat if/else guards and while/break, no new interior char-array read-backs). Honest bounds kept open per the task: an&-to-an-element (&t[0]) or computed-address file-scope initializer, and the full 8-byteR_X86_64_64data pointer, stay in the vendored hex2 linker out of scope. See TASKS/NEXT.md. -
(this increment) — fix the directory-dependent #include HANG that blocked preprocessing real tcc.h content — root caused and closed. The hang was a header cycle that only manifests when a file sits in the same directory as its dependencies: tcc.h (with config.h's
TCC_TARGET_I386, and client's-I $TCC) pulls ini386-gen.c, which does#include "tcc.h"and re-enters the top-level file forever, sobootcc -P -I $TCC $TCC/tcc.htimed out while the byte-identical copy in /tmp (where no headers resolve beside it) finished in 0.06s.src/boot_pp.c: (1) added an INCLUDE STACK (a flat charinc_pool[32768],inc_depth,inc_push/inc_pop/inc_on_stack, each slot a self-containedstr_copy'd copy of the open path so a caller-freedpathcan never leave a dangling pointer in the stack) so an#includecircling back to a header already textually open stops instead of recursing;preprocess()seeds slot 0 with the top-levelfilename(the fulltcc.h -> i386-gen.c -> tcc.hloop is then caught), andinclude_fileskipsinc_on_stack(path)re-entries, pushing/popping around its own walk. (2) FIXED a latent subdir-include bug this exposed:include_filerestored the GLOBALfilename(andline) to the CLIENT file BEFOREpp_walk-ing the header's tokens, so a nested relative#include "x"inside a header living in a different subdir resolved against the CALLING file's dir and was silently skipped (a client#include "hdr/a.h"->a.h's#include "b.h"looked for./b.h, not./hdr/b.h); the restore is now done AFTERpp_walk, so nested relative includes resolve against the header's own dir. Includes are now cycle-safe everywhere: a minimal self-cycle (a.h -> b.h -> a.h) in the same dir and the subdir variant both terminate correctly with both files'#defines intact, and the acyclic subdir two-level chain now pulls the deep macro. The previously-hangingbootcc -P -I $TCC $TCC/tcc.hnow completes in ~0.3s to a clean diagnostic stop (tcc's own#errorin the ARM target path, exit 1) instead of hanging; the /tmp copy stays 0.06s. New regression testtests/pp/cycle.c+tests/pp/hdr/cycle_a.h/cycle_b.h(a-> b -> asame-subdir cycle with client-declaredCYCLE_A/CYCLE_Bboth expanding) guards this.make testis 3 tokenizer + 15 pp + 9 parser + 45 codegen + 230 libtcc in-process + 414 libtcc shared-object = 0 failed; two clean M2 builds cmp byte-identical. See TASKS/NEXT.md. -
(this increment) — get tcc.h to preprocess FULLY (beyond the ARM
#errorstop; the data-section blocker and the earlier #include-hang fix landed the setup) — resolved: the ARM#errorwas NOT a conditional-STACK imbalance under the cycle-cut, but a far more general preprocessor bug: SIDE-EFFECT directives ran inside SKIPPED conditional groups.do_dirinsrc/boot_pp.cexecuted#include/#define/#undef/#errorunconditionally, even whenppp_emit()reported a dead region. tcc.h's target-selection block is entirely FALSE because config.h definesTCC_TARGET_I386, so every#define TCC_TARGET_X86_64/#define TCC_TARGET_ARM/#define TCC_ARM_EABIinside it sits in a skipped region; bootcc still processed them and leaked the ARM macros into the real macro table. Then tcc.h's real#ifdef TCC_TARGET_ARMat the#include "arm-gen.c"site evaluated TRUE, and the VFP#errorin arm-gen.c fired. Deterministic trace confirmed it: temporary prints showedifdef TCC_TARGET_ARM => 1 (emit=1)directly beforeOPEN arm-gen.c.do_dirnow classifies every directive as either NESTING (#if/#ifdef/#ifndef/#elif/#else/#endif, which MUST always run so the conditional stack stays balanced) or SIDE-EFFECT (#include/#define/#undef/#error/#warning/#line); a side-effect directive drops out immediately whenppp_emit()is false. M2-subset discipline held (flatif/elseguard + a localint nestingflag, nogoto). Result:bootcc -P -I $TCC $TCC/tcc.hnow preprocesses the whole tcc.h body — exit 0, ~20k preprocessed token lines, 72 typedefs, all struct bodies present, zeroarm-gen/VFP diagnostics. New regressiontests/pp/deaddef.c+tests/pp/deaddef.expectedmirrors the shape (a target macro#defined inside a dead#else, and an#errorinside a skipped#ifdef __arm__): the pre-fix binary aborts witherror: should never fire, the fixed binary emitsreturn 7 + 1(8) cleanly. The earlier include-cycle guard and subdir-include fix are unchanged andtests/pp/cycle*stays green.make testis 3 tokenizer + 16 pp + 9 parser + 45 codegen + 230 libtcc in-process + 414 libtcc shared-object = 0 failed; two clean M2 builds cmp byte-identical. Honest next step kept open: with tcc.h now fully preprocessed, the next slice probe can feed a real tcc.c translation unit into the parser — the first unsupported construct that blocks parsing tcc.c itself is the next seed. See TASKS/NEXT.md. -
(this increment) —
-I <dir>include-dir search — resolved: bootcc had NO include search path beyond the current file's own directory and vendor/M2libc, so an#include "x.h"for a header elsewhere silently resolved nothing (a /tmp TU including tcc.h via -I emitted nothing from tcc.h).src/boot_pp.cnow keeps a bounded, flat pool of command-line include dirs (inc_dir_pool[16384], 64 slots x 256 bytes, same literal-array style as the include-stack pool) plusadd_include_dir(dir)(a copy-into-next-free-slot guarded by the bound), andresolve_hdrfalls back through each registered-Idir in order after the current-file dir and beforevendor/M2libc.src/bootcc.cparses a-I <dir>pair in its argument loop and registers it with the engine (usage line updated). Consult order is now: current-file dir, then -I dirs in order, then vendor. The added loop and register helper are strict M2-subset (flatif/elseguard +whilewalk, no&&/||short-circuit, no?:, nofor(;;), C89-hoisted decls, trailing newline), matching the existingresolve_hdr/include-stack idioms — this avoids the M2 mis-compilation a prior attempt hit (a corrupted return frame inWHILE-emitted code). Proofs under the real M2 build: the tiny repro (#include "tiny.h"where tiny.h lives ONLY in an-Idir, definingTINY_VAL 7) resolves and preprocesses toint x=7with no 139; a real#include "tcc.h"via-I $TCC -I portable_libc/includecompletes (exit 0, ~20k token lines) instead of silently dropping; both run to completion. The include-cycle guard (tests/pp/cycle*) and dead-#iffix (tests/pp/deaddef*) are unchanged and green. Thetests/run-pp-tests.shharness gains an optionaltests/pp/<base>.incdirsidecar whose contents are passed as-Iflags; a new goldentests/pp/incdir.c+hdr_inc/incdir_def.hproves a header that sits ONLY in an -I dir resolves (INCDIR_VAL 20expands), while the without--Icontrol leaves the macro undefined.make testis 3 tokenizer + 17 pp + 9 parser + 45 codegen + 230 libtcc in-process + 414 libtcc shared-object = 0 failed; two clean M2 builds cmp byte-identical (determinism green). Honest scope carried forward:-Idirs are consulted as search fallback only (all#includeforms, quoted and angle, go through the sameresolve_hdrpath — full GCC-style quoted-vs-angle distinction is not modelled, which matches the existing single-path design). See TASKS/NEXT.md. -
(this increment) — feed a real tcc.c translation unit through the PARSER and capture+fix the first parser blocker. Probes:
bootcc -s/-x/-e -I /tmp/bootcfg(config.h:TCC_TARGET_I386) -I $TCC -I portable_libc/include $TCC/tcc.c. The M2 host crashed with SIGSEGV (139) squarely insidestruct TCCState(tcc.h:735-1018): the tcc.c TU contains anonymous aggregate members (union { Section *symtab_section, *symtab; };,struct { ... };), and the parser registered each tagless aggregate (union/struct with NO tag name) as a FILE-SCOPE symbol whosename == NULL. That NULL-named global then reached the codegenes_add_globals->es_add(src/boot_sym.c), whose name walkwhile(0 != name[n])dereferences NULL and segfaults — reproducibly under BOTH the M2 host-eAND a pristine gcc build of the same sources (gcc-sprinted the symptom asSYM (null) ... type=struct; both-ecrashed atWHILE_es_add_1in gdb). Root-cause fix IN src/ (a real bug, not scaffolded):parse_tagdef(src/boot_sym.c) now registers a tag symbol only when the aggregate actuallyhas_tag; an anonymous aggregate is only ever a member type or a one-off declaration, so it must contribute its layout to the enclosing aggregate but must NOTnew_symitself into the scope/global chains (if(has_tag){...}guard), which removes the NULL-named global the codegen crashed on. Verified: the reduce set that previously crashed (struct { int a; };,struct TCCState {...}with an anonymousunionmember,union { Section *symtab_section, *symtab; };) now-s/-x/-eexit 0; the full real TUbootcc -s/-x/-e -I ... $TCC/tcc.cterminates exit 0 on every probe, and the M2 host and the gcc reference build emit byte-identical symbol dumps (IDENTICAL), expression dumps (IDENTICAL), and a 2429-line M1 (IDENTICAL;m2==gccholds) instead of crashing at the tag NULL deref. Minimal repro added as regressiontests/parse/anonaggr.c+anonaggr.expected+anonaggr.exprs(bare anonymous struct, anonymous union member with/without comma-split declarators, anonymous struct member, tcc-shaped anonymous-union-of-Section*), with all three anonaggr goldens byte-identical M2==gcc;make testis 3 tokenizer + 17 pp + 12 parser + 45 codegen + 230 libtcc in-process + 414 libtcc shared-object = 0 failed; two then three clean M2 builds cmp byte-identical (determinism gate green); M2-subset discipline holds (a single flatifguard around the pre-existing registration branches, no new short-circuit/?:/loop). HONEST NEXT SEED (the follow-on first-STOP that remains, from this probe): after the crash is removed, bootcc parses tcc.h's declarations/structs/typedefs through thegen_le32prototype (tcc.h:1680) but then SILENTLY stops advancing — the-sdump never registersgen_addr32, andint main/tcc.c's real function bodies are never compiled (-xyields 0 compiledFNbodies). That same ~20-line prototype block (ST_FUNC fns withSym*/SValue*params, inside#if defined(TCC_TARGET_I386)||defined(TCC_TARGET_X86_64)) parses fine in ISOLATION, so the silent stop is an EARLIER phase-desync inparse_external(its NULL-baseskip branch swallowing the tcc.h tail) rather than that block itself — the next slice is to find that desync and reduce it to a minimal repro. See TASKS/NEXT.md.- (this increment) — provide the freestanding HEAP runtime for emitted tcc (QUEUE item 1 of "REMAINING to build tinycc with bootcc": "Provide a freestanding runtime covering the varargs/formatted IO tcc needs ... so emitted tcc can at least be assembled+run") — resolved on the "provide a freestanding runtime" arm (not the portable-libc arm): the emitted runtime already carried_start,exit,_raw_write/_raw_read,putchar, and the printf/scanf formatted-IO helpers, but had NO heap, so a compiled program (tcc.c allocates AST/symbol tables heavily) could not carve/return heap memory.emit_runtime(src/boot_sym.c) now also emits:FUNCTION_mallocand:FUNCTION_freeas raw M1 macro-asm blocks (the sameeline()idiom as the existing runtime):mallocis a Linuxbrk(12)bump allocator — brk(0) returns the current break as the block start, committingstart+totalon brk() gets the memory, each block is an 8-byte capacity header followed by its payload so the returned pointer stays 8-aligned, an unchanged break (start == committed) returns NULL on OOM like libc, and only caller-saved registers plus a pushed/poppedrbxare touched so SysV callee-saves are preserved;freeis a documented no-op (the bump heap never reclaims, which is correct for a single-shot compiling process: no use-after-free, only a monotonic heap). New TCC-parity corpustests/codegen/heap_alloc.c(pattern-fills 16/32/8-byte buffers, re-reads them, checks the three OOM (NULL) paths are not taken, prints a checksum via the emittedputchar-basedputdec, returnssum % 101) is stdout+exit byte-identical totcc -run(derr=4 tcc=4) — the bootcc side calls the runtimemallocextern, the#ifdef __TINYC__side uses real libc so TCC computes the same checksum.make testis 3 tokenizer + 17 pp + 12 parser + 46 codegen + 235 libtcc in-process + 423 libtcc shared-object = 0 failed (heap_alloc bring the codegen suite 45->46); two clean M2 builds cmp byte-identical (determinism gate green); M2-subset discipline holds (the runtime additions are M1 macro-asm text, the corpus is flat integer C — nofor(;;), nolong long, no variadic stdlib;heap_alloc.cnow also ends with a trailing newline). Honest scope carried forward (each a follow-up item, recorded in TASKS/NEXT.md): the runtime still lacks the memory/string/file surface a fully emitted tcc needs beyond the heap —realloc,memcpy/memset/memcmp,strlen/strcmp/strcpy/strncpy, and the SysVopen/close/lseek/statwrappers — so the next increment extendsemit_runtimewith those before the emit-tcc assemble+link+CLI smoke-test. See TASKS/NEXT.md. -
(this increment) — extend
emit_runtimewith the memory + string + file surface so an emitted tcc has the libc helpers beyond the heap + printf/scanf (the concrete next step of QUEUE item 3 "Reduce a fixed target/long-tail mismatch ... that block building tinycc as-is" on the runtime/libc arm) — resolved:emit_runtime(src/boot_sym.c) now also emits, as raw:FUNCTION_<name>M1 macro-asm blocks mirroring the existing:FUNCTION_malloc/:FUNCTION_freeidiom, the memory-block helpersmemcpy(forward byte copy, returns dst, src walks in rbx, count in rcx),memmove(forward copy, correct for dst<=src / non-overlapping; a dst>src backward overlap is documented as undistinguished),memset(writes byte c n times, returns dst) andmemcmp(byte compare, returns 0 or the first differing a[i]-b[i] as a signed int); the string helpersstrlen(NUL not counted),strcmp(0 when equal up to and including the NUL, else the first differing byte a[i]-b[i]),strcpy(NUL inclusive, returns dst) andstrncpy(copy up to n bytes, NUL-pad the remainder past a short source, returns dst); and the five SysV amd64 syscall wrappersopen/close/read/write/lseek(a compiled program's file surface: each just loads its syscall number into rax and traps, since the incoming SysV rdi/rsi/rdx already match the syscall ABI), so an emitted freestanding TU can open + read + lseek a source file with no libc at all. Every helper stays M1 macro-asm text (no M2-host C beyond the existingeline()idiom), preserves the only callee-saved register it touches (rbx), and only uses caller-saved regs otherwise. New TCC-parity corpustests/codegen/mem_file.c(the codegen auto-discovery picks it up) calls every helper through the emitted runtime —strcpy+strlen,strcmpequal/not-equal,strncpyNUL-pad,memset/memcpy/memcmpround trip,memmove, a memcmp difference-sign check — then opens/reads/lseeks/closes ITS OWN source file (always at tests/codegen/mem_file.c from the repo root where the harness runs both binaries) byte by byte, folding every helper result plus each file byte into one checksum thatputdecprints andmainreturns%256. The#ifdef __TINYC__branch includes the real<string.h>/<file h>/<unistd.h>/(only the real-libcopenneeds<fcntl.h>; without it tcc 9.0.27 warns "implicit declaration of function 'open'" onto stderr, which breaks the stdout+exit byte-parity gate) sotcc -runcomputes the identical checksum. Also completed on the road to green: rebuilt the stale, per-harness cachedgccreference drivers (tests/run-libtcc-tests.sh/tmp/bootcc-libtcc-gcc, tests/run-ltcc-so-tests.sh/tmp/boot-ltcc-so-gcc) that the[ ! -x driver ]guard would otherwise reuse against the ORIGINAL runtime and so report "M2 M1 != gcc M1" for every corpus onceemit_runtimehad grown (a cache-staleness artifact, not a code bug).make testis 3 tokenizer + 17 pp + 12 parser + 47 codegen (mem_file brings the suite 46->47) + 240 libtcc in-process + 432 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus; two clean M2 builds cmp byte-identical (determinism gate green); M2-subset discipline holds (runtime additions are M1 macro-asm text, the corpus is flat integer C — nofor(;;), nolong long, no variadic stdlib;tests/codegen/mem_file.cends with a trailing newline);tests/codegen/mem_file.cstdout=377292 exit=55 identical totcc -run. Honest scope kept open per the task arm (each a follow-up, recorded in TASKS/NEXT.md):realloc, astat-style syscall wrapper, and the file/dir breadth (fcntl/ioctl/getcwd/readlink) are still not emitted, and the fixer target/long-tail items that are NOT runtime-surface remain fully open — the amd64-only backend, the vendored hex2 linker's missing 8-byteR_X86_64_64absolute data pointer (only the 4-byte&absolute is reachable), and the exact first construct that STOPS parsing tcc.c itself (the prior slice found bootcc parses tcc.h'sgen_le32prototype block then silently advances no further — aparse_externalNULL-baseskip swallowing the tcc.h tail — so noint mainbody is compiled yet). See TASKS/NEXT.md. -
(this increment) — fix bootcc's preprocessor infinite loop on a function-like macro body that names the same parameter more than once, the real root cause of the "tcc.c silently stops / parse_external desync" symptom (QUEUE item-3 runtime-adjacent long-tail and the NEXT.md head task) — resolved: a
#define M(a,c) ((a)+((a)<<5)+((a)>>27)+(c))-shaped macro (e.g. tccpp.c'sTOK_HASH_FUNC) madebootcc -Pspin forever in the M2-emittedWHILE_chain_tail_0loop (gdb backtrace) becausesubst_body(src/boot_pp.c) spliced the SAME argument token chain into the output on every parameter substitution; when the macro body referenced a parameter twice, the second substitution didtail->next = a->tokswithtailpointing into (or at) that same argument list, sewinga->toksback into itself and forming a token cycle thatchain_tailwalks forever. Isolated deterministically:M(a)=(a+a)hangs whileM(a)=(a)and two-distinct-paramsM(a,b)=(a+b)terminate. Fixed by giving every substitution an independent deep copy of the argument chain: a helperclone_chain()(deeptcopyof each node, appended) is used in the parameter-substitution block instead of reusinga->toks/chain_tail(a->toks), so reusing a parameter stays acyclic. New regressiontests/pp/macroreuse.c+.expected(aTOK_HASH_FUNC-shaped double-param macro and aTWICE(a)=((a)+(a)), both previously hanging, now expanding to correct token output). Proven:make test3 tokenizer + 18 pp (macroreuse brings 17->18) + 12 parser + 47 codegen + 240 libtcc in-process + 432 libtcc shared-object = 0 failed; determinism gate: two clean M2 builds cmp byte-identical; M2-subset holds (clone_chain is flatwhile+ C89-hoisted decls, nofor(;;), no long long, no variadic stdlib; src/boot_pp.c ends with a trailing newline; macroreuse.c/.expected carry trailing newlines). Real tcc.c preprocess was checked after the fix: it no longer infinite loops; it now runs to a clean, precise first-stoptccp.c:1193: #error add long double size support. Next task (see TASKS/NEXT.md): either (a) add bootcc-Dname[=value]command-line macro define (currently unsupported) plus target-size defaults (PTR_SIZE,LDOUBLE_SIZE,CHAR_BIT) so tcc.c preprocesses past the#error, or (b) keep churning parser/codegen against a reduced tcc.c — the preprocessor cycle is closed and the first exact unsupported construct (a command-line macro define + long-double size selection) is now documented. -
(this increment) — add
-D name[=value]command-line defines AND fix the#elif-tail preprocessor bug so the real tcc.c preprocesses (QUEUE item "Reduce fixed target/long-tail mismatches ... blocking tinycc-as-is" on the preprocess arm) — resolved: two independent bootcc bugs were found on the road to a tcc.c preprocess. (1) The#elifdirective, after a matched#if, leftcf_top->emittingat 1, so an#errorin a later#elif/#else-shadowed region still FIRED — the exact shape of tccpp.c's#if LDOUBLE_SIZE == 12 / #elif == 16 / #elif != 8 #errorchain (src/boot_pp.cdo_dir), which surfaced as "error: add long double size support" and silently stopped bootcc from preprocessing tcc.c. The#elifhandler only resetemittinginside the0==matchedevaluation branch; it now also setscf_top->emitting = 0when a prior branch already matched (a matched #if makes every later #elif/#else dead), mirroring what the#elsehandler already did. (2)-D name[=value]command-line defines: bootcc had none; and hand-rolledadd_definescanning the value ran into M2-Planet codegen bugs (&argv[i][2]compiled as a byte load, and char-by-char comparisons on achar*param and on local char arrays misbehaved). The robust resolution:-Dstrings are recorded into a bounded pool (src/boot_pp.cdef_pool/def_count+add_define/def_count_of/def_arg_at), and src/bootcc.c generates a real temp source/tmp/bootcc_defs.cof#define NAME valuelines (build_defs_file, splitting on=via%cstring output), re-tokenizes it withread_reset()+read_tokens, drops its trailing TOK_EOF, and splices it in front of the input token stream so the normal, battle-tested lexer/define_macrohandles the replacement text (multi-token values, pasting, etc.). Both-D name=value(space) and-Dname=value(joined, copied into a localdnet[256]buffer since&argv[i][2]trips the M2 address-load bug) are accepted;-D NAMEbare defines to empty. Result:bootcc -P -I $TCC -I portable_libc/include -DPTR_SIZE=4 -DLDOUBLE_SIZE=12 -DCHAR_BIT=8 $TCC/tcc.cnow preprocesses the ENTIRE tcc.c with exit 0 (201,314 output token lines; previously it died on#error add long double size support). Regression tests:tests/pp/elif_tail.c+.expected(the matched-#if-deadens-later-#elif chain;#if LDOUBLE_SIZE==12matches and the later#elif != 8#errormust NOT fire) andtests/pp/define.c+define.defines+.expected(the harness gains a.definessidecar, like.incdir, passing-Dflags; the test asserts#if PTR_SIZE==4 && LDOUBLE_SIZE==12 && CHAR_BIT==8, a bare-D#ifdef, and a value-Dexpanding in code). Proven:make testis 3 tokenizer + 20 pp (elif_tail + define bring 18->20) + 12 parser + 47 codegen + 240 libtcc in-process + 432 libtcc shared-object = 0 failed; determinism: two clean M2 builds cmp byte-identical; the m2==gcc emitted-M1 gate holds; M2-subset discipline holds. With-D+ tcc.c preprocessing green, the previously documented first-stop is now past: the next churn target is pushing the FULLY preprocessed tcc.c (201k tokens) through the PARSER — capturing the first parser blocker on a real, fully-preprocessed tcc.c (see TASKS/NEXT.md) — and the remaining long-tails (amd64-only backend, 4-byte hex2 R_X86_64_64 absolute reloc, runtimerealloc/stat). -
(this increment) — drive the fully-preprocessed real tcc.c through the bootcc PARSER and capture the first genuine parser blocker; reached a documented exact first-unsupported-construct on the M2 auto-bootstrap path. With preprocessing green (previous increment), the parser run
bootcc -s -I $TCC -I portable_libc/include -DPTR_SIZE=4 -DLDOUBLE_SIZE=12 -DCHAR_BIT=8on the real composite (tcc.c, and its minimal shape#include "tcc.h" + #include "libtcc.c") makes the M2-Planet-HOSTED bootcc SEGFAULT (exit 139, fault atFUNCTION_is_nl_punct+0x45 readingGLOBAL_cur): a danglingcurinsideparse_external's fallback skip loop (theWHILE_parse_external_4is_nl_punctafterparse_specifierreturns NULL). The decisive fact: a GCC build of the SAME bootcc sources parses the SAME composite (tcc.h + libtcc.c, ONE_SOURCE pulls every backend) to completion — exit 0, full 2342-symbol table. So bootcc's GRAMMAR is correct on this input; the blocker is the M2-Planet host failing on large translation-unit slices. Characterizing by slicing tccgen.c (#include "tcc.h"+head -N tccgen.c): the crash is NON-MONOTONIC (head-2760 OK, head-2800 crash, head-2820 OK, head-2840 crash, ..., head-2920 OK) — a memory-layout-fragility signature, not a single first-offending construct. Deterministic 3/3 on head-2800 (tccgen.c first 2800 lines, ~1365 decls): M2-host exit 139 vs gcc-host exit 0 with 1372 symbols. Root is NOT a bootcc source bug (the gcc-host parses the whole composite, an uninitialized read or M2 codegen pointer corruption under large heap pressure that gcc's zeroed frames avoid). Documented first-unsupported-construct: parsing large real backend TU slices (tccgen.c-sized, ~1300-1400 symbols) crashes the M2-host build, while the gcc-hosted bootcc / -ltcc-SO consumer parses the full tinycc composite cleanly. Path implication: extend the gcc-hosted libtcc/-ltccconsumer path from its small corpus to the full real tcc.c, which the M2-host cannot handle at this TU size.make testunchanged and green (3+20+12+47+240+432 = 0 failed; no engine source changed this increment, engine-gate/id determinism hold; the crashing-s/-x/-eprobes are the M2 build on the large slices, documented here). See TASKS/NEXT.md. -
(this increment) — drive the gcc-hosted bootcc at the FULL real tcc.c and capture the first genuine parser error (NEXT after documenting the M2-host limit) — resolved as a documented parse-desync, not a clean grammar gap. On the gcc host (the canonical/forward reference; build pattern
gcc ... vendor/M2libc/bootstrappable.c src/*.c),bootcc -s -I $TCC -I portable_libc/include -DPTR_SIZE=4 -DLDOUBLE_SIZE=12 -DCHAR_BIT=8 $TCC/tcc.cparses cleanly through the entire composite —struct TCCState(280 bytes, all 60 MEMs), the help/help2/version static-const string arrays (nested#ifdefmacro-in-string concatenations), and all libtcc.c/tcctools.c functions up throughdefault_outputfile— then SILENTLY STOPS:int mainis never registered (the dump's last symbols are main's body-localsopt,n,first_file,argc,argvdumped at file scope) and bootcc exits 0. Deterministic and specific to the accumulated real input: the identical composite with short help arrays (/tmp/tccprobe.c) registersmain(main=1), while the real tcc.c gives main=0 (2/2 runs each). The M2-host additionally segfaults (prior increment), but this one is gcc-host-visible. Root-cause status: the desync region is the accumulated mid/large TU (tested: even tcc.h+libtcc.c+tcctools.c+lines 27-210+main gives main=0; smaller subsets register main); it is NOT reducible to a single clean grammar construct — same near-identical inputs flip main registered/dropped (help2 array, version[] array, ifdef-in-function, extern-call casts each worked or broke depending on surrounding content), a genuine stateful parser desync rather than a parse-error for one construct. ASan/UBSan and gcc -Wuninitialized flag nothing (all allocs are calloc; no OOB), so it is not a classic buffer overrun. Honest first-parser-construct recorded: bootcc (gcc host) silently drops the tail of the real tcc.c (does not registerint main, dumps its locals to global scope) after ~1175 symbols when the TU accumulates past the libtcc/tcc-late-c-backend size; an isolated 1-construct repro is not yet obtained.make testunchanged (3+20+12+47+240+432 = 0 failed; no engine source changed). Next task (see TASKS/NEXT.md): reduce the accumulated TU to the exact desync (instrument/purge the parse with a bisect-set that cuts libtcc.c/tcctools.c content to find the first accumulated construct that flips main), and fix the stateful desync, OR obtain a memory-sanitizer. See TASKS/NEXT.md. -
(this increment) — reduce and FIX the real-tcc parser desync: bare
unsigned/signedfunction return types and globals (e.g. tcc.c'sstatic unsigned getclock_ms(void)) made the gcc-host parser silently dropint main(dump ended at main's body-locals). Root cause inparse_specifier(src/boot_sym.c):unsigned/signedset thesignflag but leftkind = (-1)when no type keyword followed; theis_identbranch then broke for the function name, theif(NULL==btype && kind != (-1))default never fired (kind==-1), and parse_specifier returned NULL → parse_external's fallback skip swallowed the rest of the file (somainnever registered on the full real tcc.c, and the M2 host would crash on the same slices). Fixed by tracking asaw_signflag and, when no base type was named, applying C's implicit-int rule (bare unsigned/signed == int):kind = TYPE_INT; btype = make_prim(...)only whensaw_signis set and no btype/kind was produced. Proven: the full real tcc.c-son the gcc host now registersint main(main=1, 1183 symbols, exit 0, 2/2) where it previously silently stopped at ~1175 with main=0; a minimalstatic unsigned gc(void){...} + int mainnow registers main (5/5) whileunsigned intalways worked. Regressions: updatedtests/parse/decls.expectedto include the now-correctly-parsed bare-unsignedglobalg_u(previously dropped — the old golden had silently omitted it (asserting the buggy drop)), and addedtests/parse/unsigned.c+.expected(bareunsigned/signedglobal + function +int main, gating that a following function/decl is not swallowed).make testis 3 tokenizer + 20 pp + 13 parser (unsigned brings the suite 12->13) + 47 codegen + 240 libtcc in-process + 432 libtcc shared-object = 0 failed; determinism gate green (two clean M2 builds cmp identical); M2-subset discipline holds (a flatelse ifbranch, no?/for; src/boot_sym.c, unsigned.c/expected, decls.expected end with trailing newlines). The M2 host still segfaults on the FULL large TU (documented in prior increment), but the parser GAP it exposed on the gcc host is now fixed at the source. Next task (see TASKS/NEXT.md): withunsigned-implicit-int fixed, re-verify the M2 host's large-TU crash threshold (it may be a separate effect now that the desync is gone) and keep scaling bootcc toward parsing+running the full tcc.c. -
(this increment) — push bootcc's BODY compiler past the real tcc.c beyond the first tcctools blocker: fixed C adjacent-string-literal concatenation in the expression parser (QUEUE item "Push bootcc beyond ... compile function bodies ... capture+fix the first body-parser/codegen blocker"). Root cause: after preprocessing, adjacent literals stay as two TOK_STRING tokens; bootcc only concatenated them in GNU asm templates (
asm_read_strings), whileex_primaryread a SINGLE literal and left the second adjacent literal as a stray expression, erroring "expected ')' after argument list". The real tcc.c triggered this intcc_tool_cross(tcctools.c):snprintf(..., "%.*s%s" "-tcc" ..., ...). Fix:ex_primary's TOK_STRING branch now callsasm_read_strings()(forward-declared), which decodes and merges the whole run of adjacent literals and advances past every one (removing the now-redundant singleadvance()); a run like("a" "b")becomes one EX_STR, matching the asm-template path. Also addedtools/reduce-tcc.py, a deterministic mechanical delta-debugger (ddmin) that, given a syndrome oracle (exit-nonzero / grep-absent / grep-present, mode, prelude#include "tcc.h", -I/-D args), bisects a real source to the minimal top-level chunk-set that reproduces it — turning the slow manual 200k-token TU probing of the autonomous agents into a fast scripted reduction (validated: shrank a synthetic GNU statement-expression case to its 1-line repro in 3 oracle tests, and mechanically found the realtcc_tool_crosssnprintf construct at 6 oracle tests). Regressions:tests/codegen/strconcat.c(adjacent-literal initializer + call argument, concat "con" "cat"/"a" "b" "c", TCC-parity stdout+exit, derr=6 tcc=6). Proof:make testis 3 tokenizer + 20 pp + 13 parser + 48 codegen (strconcat) + 245 libtcc in-process + 441 libtcc shared-object = 0 failed (rebuilt the stale cached gcc reference drivers, which otherwise spuriously failed the m2==gcc/emit gates after the boot_sym.c emitted-M1 change); determinism: two clean M2 builds cmp identical; M2-subset holds. Real-input progress:bootcc -e ... tcc.c(gcc host) now gets PAST tcctools'tcc_tool(the offending snprintf concat is accepted) and intomain, failing next at the END of tcc.c main withtcc.c:375: expected ')' in if(line 375 ismain's closing}; an unbalanced if in main's body 246-374). That is the next incremental target (see TASKS/NEXT.md) — reduce tcc.cmainwith the reducer to the minimal single construct and fix it, one construct per increment. -
(this increment) — add the C comma operator to bootcc's expression parser so real tcc function bodies compile further (QUEUE "Push bootcc past the full real tcc.c -s pass: compile bodies/-x/-e ... capture+fix the first body-parser/codegen blocker"). Reduced (with tools/reduce-tcc.py) the real tcc.c
-xfirst body blocker to main'sargc = argc0, argv = argv0;and the tcctools-stylefor(a=...,b=...;;)/snprintf(..., "a" "b", ...)— a COMMA-OPERATOR gap: bootcc handled,only as a call-arg/declaration separator, so an expression statementa = 1, b = 2;errored "expected ';' after expression statement" (and in a call-arg proved the END of main as "expected ')' in if"). Fixed in src/boot_sym.c: a newex_seq()(a left-leaning comma loop overex_assign) is now used at every STATEMENT expression position (if/while/do-while/switch/case tests, for-init/cond/step, expression-statement) and at parenthesised group expressions ((a = 1, a + 10)), while call-arg lists, declaration lists and array sizes keep their,-as-separator handling. The comma node EX_COMMA was already emitted/evaluated by the codegen (cg_val a; cg_val b), so no codegen work was needed. Regressions:tests/codegen/comma.c(statement-comma, paren-comma, for-comma, TCC-parity derr=9 tcc=9) added; the earliertools/reduce-tcc.pyreducer was reused. Proof:make testis 3 tokenizer + 20 pp + 13 parser + 49 codegen + 250 libtcc in-process + 450 libtcc shared-object = 0 failed (auto-discovered comma; stale gcc-engine reference drivers under /tmp/boot-ltcc-so-gcc + /tmp/bootcc-libtcc-gcc were rebuilt after the emitted-M1 change, per AUTONOMY); determinism: two clean M2 builds cmp identical. Real-input progress: gcc-host fulltcc.c-x now advances past the earlier straddle blocks; it next errors at the very end ofmain(tcc.c:375expected ')' in if), i.e. an unbalancedifdeeper in main's body that the ddmin-reduced 126-line main no longer reproduces (context-dependent) — the next single-blocker to reduce (see TASKS/NEXT.md). The comma operator itself is fully green. -
(this increment) — fix the real tcc.c
mainFILE *ppfp = stdout;"lvalue required in assignment" blocker AT ITS ROOT and the two-typedef-param parser self-loop it exposed, so the full real tcc.c-xnow parses PASTmain'sFILE *ppfp = stdout;. Root cause 1 (src/boot_pp.c): angle-bracket#include <...>was silently DROPPING the header's content.do_dirhad the directive line'seoltoken but calleddo_include(rest, out, ot)WITHOUT it, soparse_header_name(rest, NULL)made the angle-bracket branch's loop guardNULL != eol && ...false and accumulated an EMPTY header name ->resolve_hdr("")-> NULL -> silent skip (quoted#include "..."used a single TOK_STRING and worked). That is why tcc.c's<stdio.h>/<sys/types.h>were absent, soFILE/stdoutwere UNDECLARED andFILE *ppfp = stdout;parsed as an implicit declaration whose base was an undeclared identifier -> "lvalue required in assignment". Fix: threadeoldo_dir -> do_include -> parse_header_name. Root cause 2 (src/boot_sym.c): once real headers are actually included, portable_libc<string.h>'smemmem(void const*, size_t, void const*, size_t)— i.e. ANY prototype with TWO params of the same typedef (twosize_t) — made the parser loop FOREVER (SIGKILL'd after 8+ h at 99.9% CPU, 0 progress). A typedef stores its RESOLVED type (size_t-> the sharedlongnode, kind TYPE_LONG, NOT a TYPE_TYPEDEF node), so inparse_paramsa baresize_t agivesdecl == ptbut the copy guard (kind in {STRUCT,UNION,ENUM,TYPEDEF}) MISSED it; bothsize_tparams aliased the SAME shared node andtail->next = declwrote a self-loop that hung every later list walk (param_countin the-s/-xdump). Fix: wheneverdecl == pt(a bare declarator returns the base node, which is shared for a typedef or tag), copy a fresh node AND start it unlinked (next = NULL, sincetype_copyinherits the source's stalenext) — not only for tag kinds. Proven: minimal angle-include repro (#include <myhdr.h>now pulls content,tests/pp/angle.*) and the real repro (#include <stdio.h>+FILE *ppfp = stdout;parses); the two-typedef-param case is gated by newtests/parse/dupparam.*.make testis 3 tokenizer + 21 pp + 14 parser + 49 codegen + 250 libtcc in-process + 450 libtcc shared-object = 0 failed; two clean M2 builds cmp byte-identical; M2-subset holds. Real-input progress: the full real tcc.c-x(gcc host) now PASSESmain'sFILE *ppfp = stdout;(the original blocker is GONE) and the full-sregistersint main(1281 symbols, no hang); the NEXT blocker is a context-dependent parse desync surfacing at tcc.c:375 (end of main) as "expected ';' after expression statement" that does NOT reproduce from tcc.h + main alone (it needs earlier functions' accumulated state) — the next single increment. See TASKS/NEXT.md. -
(this increment) — build the guardrail set for fully autonomous development (the gate, the ratchet, the watchdogs, the park rules): (1)
tools/frontier.shmechanically measures progress on the REAL TinyCC 0.9.27 tcc.c through a stage ladder (-Ptoken count ->-ssymbol count withSYM main->-xfirst-error line ->-xclean ->-efirst-error line ->-eclean), encoded as a zero-padded lexicographically-comparableSTAGE:DETAILscalar; it builds/caches the gcc-host probe atbuild/amd64/frontier-probe(rebuilt when any engine source is newer; the M2-hosted binary segfaults on the full large TU, documented limitation, and the parse frontier is identical in both builds per the m2==gcc gate), runs each probe under a 300stimeout, and enforces a RATCHET againsttools/.frontier_state(exit 2 on regression;--forceis the documented escape hatch that requires a LOG.md entry;--checkmeasures without recording, for the gate). Baseline recorded this increment:03:0000375(-xstops at tcc.c:375), matching the known frontier. (2)tools/gate.shis now the SINGLE definition of a completed increment: worktree has changes +makegreen (the default goal IS the full six-harness suite) +make clean+make+cmprebuild determinism + trailing-newline sweep over every tracked/untracked non-vendor file + frontier non-regression; it prints a per-check GO / NO-GO summary and only on GO rewritestools/.frontier_state(which is then committed with the increment); expected runtime 5-10 min. (3) every bootcc/driver/gcc-reference/toolchain/tcc -run/emitted-program invocation in all sixtests/run-*.shharnesses now runs under coreutilstimeout(default 60s,BOOTCC_TEST_TIMEOUToverride; build steps 300-600s) with exit-124 failing THAT case explicitly ("watchdog timeout") instead of hanging the session — motivated by the 8.5-hour-CPU infinite-loop incident a 30s cap would have caught. (4) AUTONOMY.md gains a "Guardrails (machine-enforced, no discretion)" section: the gate is the universal check (replacing the old make/determinism recipe), the ratchet +--forcepolicy, the watchdogs, and the PARK rules (3 strikes on the same task -> writeTASKS/PARKED.mdin the documented state/tried/why/unpark format and stop; K=3 consecutive gate-green increments with no frontier advance -> park and pick a frontier-advancing QUEUE line; aSTOPfile in the repo root means do no work), plus the may-not list (no commit on NO-GO, no ratchet override without a LOG entry, no shrinking tests to green, no vendor/ touches, no unbounded commands). NEXT.md now requires every increment to end withsh tools/gate.shGO and states that this task's success is exactly a frontier advance. No engine source changed (frontier scalar unchanged at 03:0000375; the ratchet passes trivially). Dogfooded: this very increment ends by runningtools/gate.shto GO.make testis 3 tokenizer + 21 pp + 14 parser + 49 codegen + 250 libtcc in-process + 450 libtcc shared-object = 0 failed; two clean M2 builds cmp byte-identical. See TASKS/NEXT.md. -
preprocessor line splicing (C translation phase 2) — resolved: the tcc.c:375 "expected ';' after expression statement" desync was NOT a parser bug; the preprocessor never spliced line continuations, so a
+newline was emitted as two tokens and `pp_walk` computed a directive's eol at the FIRST physical newline. Two consequences: (a) multi-line `#define` bodies were truncated to their first line by `clone_until(bodystart, eol)` — tccpp.c:693's 7-line `#define PEEKC(c,p)` body became a lonetoken, so 19PEEKCexpansions injected barepunct tokens into function-body contexts; (b) the remaining physical lines of each multi-line `#define` leaked into the output stream as orphan code (also macro-expanded). libtcc.c is the poison only because it is the ONE_SOURCE aggregator (`#include "tccpp.c"`, `tccgen.c`, ...), which is why tcc.h+main parsed clean while tcc.h+libtcc.c+main choked inside `parse()`. Fix in src/boot_pp.c: new `tok_is_cont()` (apunct immediately followed by the line's newline punct) +find_eol()(first newline NOT preceded by a continuation); `clone_until` now drops continuation tokens (a spliced macro body carries no); both eol scans inpp_walkusefind_eol; the code-line emit loop splices out `` tokens (newlines stay; the parser'sskip_nlhandles them). Also fixed a heap-use-after-free ASan caught in the same path:do_includefrees thejoin_pathallocation that included-file tokens'filefields still point at (reader setst->file = filename;include_filesetfilename = path) —include_filenow pointsfilenameat the process-lifetimeinc_poolslotinc_pushcopies into, so tokenfilepointers survive thefree. Getting the parse to actually ADVANCE past 375 (so the fix is observable as frontier progress) needed three supporting changes in src/boot_sym.c: the flatenode[]/stnode[]node pools are now heap-allocated inparse_tokens(calloc) instead of ~8K static arrays — a full tcc.c TU needs well over 8K rows and M2-Planet refuses to bake >1MB of NULL-padded statics into the binary (131072 rows, ~15MB heap, wide margin);long doubleis now a distinctTYPE_LDOUBLE(16B/16-align on amd64) —tccgen.c:2026 long double f1,f2;previously parsedlongthen mis-readdoubleas the declarator name; andline_errornow reports the current parser token's own file/lineno (newcur_token()accessor) instead of the stale reader globals, so diagnostics across #include files name the real construct. Newtests/pp/continuation.cgolden proves the splice: an object-like (OBJ 1 + \ 2) and a function-like (F(x,y) (x + \ y)) multi-line macro expand spliced across their definition lines with NOpunct(\)tokens and NO orphan directive lines. The full real tcc.c-xnow parses PAST tcc.c:375 — the first-xerror is a C cast ((double)expr, "expected ')'"), a separate feature. Frontier advanced03:0000375→03:0002504.make testpasses 3 tokenizer + 22 preprocessor + 14 parser + 49 codegen + 250 libtcc in-process + 450 libtcc shared-object (0 failed); two clean M2 buildscmpbyte-identical. See TASKS/NEXT.md. -
(this increment) — the
03:0002504cast wall (unary-operand cast precedence + token file metadata) — resolved: the wall was NOT a missing cast feature (casts have existed viaex_cast/is_paren_type) but a cascade precedence bug: every unary operator (* & - + ! ~ ++ --) inex_unaryrecursed intoex_unaryitself for its operand, so-(long double)-vtop->c.i(tccgen.c:2504 ingen_cast) consumed the-and the operand never passed throughex_cast; the(fell intoex_primary's group-expression branch, parsedlongas an identifier and died "expected ')'" atdouble. Per the C grammar (unary-expression → unary-operator cast-expression) all eight unary operand sites now callex_cast()(the sizeof/typeof expression fallbacks keepex_unary()per spec). A second latent bug the misreported error exposed: tokenfilefields pointed into the REUSABLE include-stack slot —include_filesetfilename = inc_slot(depth), so whichever include next occupied the same depth (tccgen.c → tccasm.c) overwrote it and every closed header's tokens were "renamed" to that latest file (the error said tccasm.c:2504 although tccasm.c is 1277 lines;-Pstream forensics proved the token ORDER was coherent — metadata aliasing, not a preprocessor scramble; the838:int(0x0400)tokens mid-ifwere in-placeVT_MUSTCASTexpansions at their definition line).include_filenow interns each include path into an append-onlyfn_poolviafn_intern(never reused) while theinc_poolstack keeps doing cycle detection. Alsoblock_parseno longer SEGVs on NULLcur(EOF inside a body) — it breaks and reports "expected '}'". The full real tcc.c-xnow parses PAST tccgen.c:2504: first error moves to tccgen.c:3160vpushi((unsigned)mask)— that construct preprocesses toif (cond) else stmt(invalid C), because tcc's source only coheres whenHAVE_LONG_LONGis defined, which real tcc builds set on long-long compilers and bootcc's AFLAGS do not yet (next increment). Frontier advanced03:0002504→03:0003160. Newtests/parse/cast.cgolden (primitive/typedef/pointer/struct-tag casts,-(long double)-gas EX neg→cast→neg, the exact tccgen if/else shape) byte-compared m2==gcc.make test3 tokenizer + 22 preprocessor + 17 parser + 49 codegen + 250 libtcc in-process + 450 libtcc shared-object = 0 failed; two clean M2 buildscmpbyte-identical. See TASKS/NEXT.md. -
(this increment) — the
-DHAVE_LONG_LONGfrontier build + cpp bare--DNAME≡-DNAME=1semantics (a harness increment, the documented ratchet exception) — the tccgen.c:3160 wall was not a bootcc defect: tccgen.c:3148-3152 and 3156-3158 are#if HAVE_LONG_LONG-guarded, and with the flag UNDEFINED the bitfield-store code preprocesses toif (cond) else stmt, which no C compiler accepts; a real tcc build on a long-long compiler defines HAVE_LONG_LONG, so the faithful harness compiles tcc with it. Two changes: (1)-DHAVE_LONG_LONGadded totools/frontier.shAFLAGS (the single AFLAGS definition, with a comment saying why); (2) a genuine preprocessor defect the flag exposed: a bare-DNAMEwas emitted as#define NAME(EMPTY replacement list), so#if NAMEevaluated to 0 — cpp semantics are-DNAME≡-DNAME=1;build_defs_file(src/bootcc.c) now emits#define NAME 1.tests/pp/define.cnow also proves#if FEATX == 1on the bare-DFEATX. RATCHET EXCEPTION, documented per the guardrail: this is a harness change, not an engine regression — the measured stream itself changed (the#elsebranches drop out,unsigned long long mask/vpushll(mask)lines enter), and the first-error line NUMBER moved down (3160 → 1609) although the engine now parses STRICTLY FURTHER: 1609 is in i386-asm.c, which in include order (libtcc.c: tccpp → tccgen → tccelf → tccrun → i386-gen → i386-link → i386-asm) comes AFTER all of tccgen.c — the line-number scalar is only monotonic within a file, not across the multi-file TU, which is exactly why the exception applies. Scalar recorded viash tools/frontier.sh --force. The NEW first-xwall is i386-asm.c:1609static uint8_t reg_saved[] = { 3, 6, 7 };— a local array declaration with a BRACE initializer, which bootcc's declaration parser does not accept yet ("expected ';' after declaration"); that is the next increment.make test3 tokenizer + 22 preprocessor + 17 parser + 49 codegen + 250 libtcc in-process + 450 libtcc shared-object = 0 failed; two clean M2 buildscmpbyte-identical. See TASKS/NEXT.md. -
(this increment) — the brace-initializer / empty-macro / fixed-width-int walls all at once, advancing the real tcc.c frontier
03:0001609→05:0000386(stage 3 → stage 5: the full real tcc.c-xnow PASSES CLEAN and-eruns to line 386). Three coupled fixes, each isolated with a repro and a-P/EXT-trace forensics pass (chase the FIRST stream anomaly, not the reported error line): (1) LOCAL BRACE INITIALIZER (src/boot_sym.c,local_agg_fill): i386-asm.c:1609static uint8_t reg_saved[] = { 3, 6, 7 };(a local array with a BRACE initializer) failed "expected ';' after declaration" because the array branch loopedfor(i = 0; i < n; ...)withn = array_len(unknown size → −1 → 0 iterations, the list never consumed). Replaced by awhile(1)that for unknown-size arrays (n == 0) iterates until}and afterwards fixes the shared type node in place (ty->array_len = i; ty->size = i * ty->base->size; ty->align = ty->base->align;—new_symstores the type POINTER, so the fixup propagates to the already-registered symbol). Works for locals AND file scope,staticlocals, known size, and element count < declared size. (2) EMPTY REPLACEMENT-LIST MACROS (src/boot_pp.c): after (1) the frontier moved to libtcc.c:1212const FlagDef *p;"expected type in declaration" — but that region parses standalone, so an EXT-trace probe (printcurbefore eachparse_external) showed the top-level loop had desynced ~1500 lines EARLIER:PUB_FUNC char *tcc_basename(const char *name)(libtcc.c:171) carriedPUB_FUNCas a RAW UNEXPANDED IDENTIFIER in the-Pstream. Root cause: object-like macros with an EMPTY replacement list (#define PUB_FUNCunder non-ONE_SOURCE,#define EMPTY) never expanded — inexpand_macroan empty body →subst_bodyreturns NULL →full_expand(NULL)returns NULL → callers treat NULL as "not a macro" and emit the original token, soPUB_FUNCleaked into the stream andparse_specifierreturned NULL, whose skip-to-;recovery ate the function's first statement and shredded the FlagDef typedef. Fix: a lazy POINTER sentinel (static struct token* empty_tok;+empty_sentinel(), calloc +kind = -1; deliberately a pointer, no&globalanywhere in M2-compiled sources) — the object-like and function-like branches return it for an empty body, and both callers (full_expandand thepp_walkcode-line emit) special-caseif(r == empty_tok) { t = nt; continue; }(consume nothing).#if EMPTY→ 0 still works (empty condition → EV_END → 0). (3) FIXED-WIDTH INT TYPES (environment completion, NOT a source modification): with (1)+(2) the wall moved to libtcc.c:1178set_elf_sym(..., (uintptr_t)val, ...)—(uintptr_t)is an UNKNOWN type in a cast (is_paren_typerequires a known type after(), and the harness environment lacks the fixed-width types: tcc.h's#include <stdint.h>is only under#ifdef _WIN32, and portable_libc's sys/types.h defines only ssize_t/size_t/off_t (no stdint.h at all). A real 32-bit glibc build gets uint8_t..uint64_t/int64_t/uintptr_t via<stdio.h>→<sys/types.h>; the faithful harness must provide them. DESIGN CONSTRAINT: multi-word-Dvalues cannot survive argv word splitting (-Duint8_t='unsigned char'arrives as two argv elements — a quote-stripping block WAS added tobuild_defs_filefor direct-CLI invocations where quotes survive argv, and kept), so a single-word MARKER flag is the transport:-DSTDC_INT_TYPES.build_defs_file(src/bootcc.c) detects the marker and emits NINE REAL typedefs into the prepended defs file (uint8_t=unsigned char, uint16_t=unsigned short, uint32_t=unsigned int, uint64_t=unsigned long long, int8_t=signed char, int32_t=int, int64_t=long long, uintptr_t=unsigned int, intptr_t=int — 32-bit widths since PTR_SIZE=4, long long since HAVE_LONG_LONG). tcc sources stay byte-identical; size_t/ssize_t already come from portable_libc and are deliberately NOT redefined (a macro would corrupt the typedef lines).tools/frontier.shAFLAGS drop the nine broken quoted-Ddefines and carry the single-DSTDC_INT_TYPES(comment block updated to explain the marker design). A fourth defect the (3) wall exposed, fixed in the same pass: STRING-LITERAL-INITIALIZED CHAR ARRAYS and MULTI-LINE AGGREGATE INITIALIZERS (C 6.7.9). The (3) fix moved the wall to tcctools.c:79static ArHdr arhdr = { "/ ", ..., ARFMAG };— a local STRUCT whose char-array members are initialized by STRING LITERALS. Isolated repros (ar1..ar16) bisected it: file-scope multi-line passed only via the sloppy skip-to-;recovery, but LOCAL aggregate inits with (a) a string literal for a char[N] member or (b) a multi-line brace list failed. Two root causes in BOTHlocal_agg_fillandginit_fill: (a)eval_constleavescuron the NEWLINE that terminates an element (rawcur->next), so the followingis_punct(",")/is_punct("}")checks missed — every comma/brace decision point now doesif(is_nl_punct()) advance();first; (b) a string literal for a char array is ONE element that fills the whole member (decoded bytes in order, zero-padded, NUL-terminator counted for inferredchar c[]), not one byte — new branches in both the known-size and inferred-length array walks emit per-byte stores (agg_emit_store_vfor locals,ginit_putfor globals;agg_emit_storerefactored to delegate throughagg_emit_store_vwith an explicit value). Also fixed a latent bug the refactor surfaced:local_agg_fill's loop indexiwas never initialized (the for→while conversion dropped it) — nowi = 0. M2-subset: the byte extract(j < tlen) ? (txt[j] & 255) : 0mis-compiled under M2 (a char-array-index inside a&), so it is written as nestedif(bv < 0) bv += 256;with no ternary/bitwise-on-char. Proof: all 16 isolated repros (ar1..ar16: local/file-scope, static/auto, struct/array, single/multi-line, string/int elements, known/inferred size) pass; full real tcc.c-xis CLEAN (rc=0, 0error:lines) and-enow runs to line 386.make test3 tokenizer + 22 preprocessor + 17 parser + 49 codegen + 250 libtcc in-process + 450 libtcc shared-object = 0 failed; two clean M2 buildscmpbyte-identical (gate GO). No ratchet exception needed — the scalar advanced forward (03:0001609 → 05:0000386). The NEW frontier is stage 5:-estops at line 386 (codegen "undeclared identifier"; note tcc.c itself is 371 lines, so the line belongs to an included file — the next increment reduces it). See TASKS/NEXT.md. -
(this increment) — the comma-declarator chain clobber + parenthesized macro bodies (stage-5
-ewall reduction; the engine advances pastptableandCH_EOFto theTOK_ELSEX-macro enum; frontier scalar HOLDS at05:0000386because the next wall is at the same misattributed line 386, tcc.c being only 371 lines). Two fixes, each isolated with repros (dp8/dp9/dc1 for the clobber; ce1..ce7 for the macro wall): (1) COMMA-DECLARATOR CHAIN CLOBBER (src/boot_sym.c,block_parse): tccpp.c:415TokenSym *ts, **ptable;intok_alloc_newfailed "codegen: undeclared identifier" onptable(the SECOND declarator).parse_local_declbuilds comma-declarators as a chainfirst -> decl2 -> ...throughstnode[].next— the SAME field the statement list uses — and returns the HEAD;block_parsethen didstnode[prev].next = s; prev = s;withs= that HEAD, so linking the NEXT statement clobbered the first->second declarator edge and orphaned every declarator after the first:layout_stmt(thealloc_localpass) never reached them, so any use died at codegen. The forensics followed the established method (debug probe printing the actualenode[].nameat thecg_val/cg_addrerror sites, since the reported tcc.c:386 line is a misattribution). Fix: after linking the returned chain, advanceprevto the chain TAIL before the next link (int t = s; while(0 != stnode[t].next) t = stnode[t].next; prev = t;), so a comma-declaration's full declarator chain stays intact in the block chain. Verified:X *ts, **ptable;(2nd declarator used) andint a, b;(2nd used) now pass-e. (2) PARENTHESIZED MACRO BODIES (src/boot_pp.cdefine_macro+ newno_wstokenizer flag): with (1) in, the next wall wasCH_EOF(tcc.h:568#define CH_EOF (-1), consumed byisidnum_table[256 - CH_EOF]). Repros ce4..ce7 bisected it precisely:#define X 5and#define X -1expanded, but#define X (5)and#define X (-1)(body STARTING WITH() did NOT —define_macrotreated any leading(as the function-like marker, so#define X (5)(with the space betweenXand() was misparsed as a zero-arg FUNCTION-LIKE macro with an EMPTY body, andX(not followed by() never expanded. Fix:struct token(src/bootcc.h) gainedint no_ws;(1 iff no whitespace/newline before this token), set in the reader (src/boot_reader.c: newg_rd_gapgap flag — 0 = immediately after the previous token, 1 = separated by whitespace or a newline;t_appendrecords it and clears it,read_tokenssets it at start, in the whitespace-skip branch, and after each newline), and the function-like check now requires0 != p->no_wsfor the(.#define F(x) ...(immediately-() still parses function-like;#define X (5)is now object-like with body(5). Verified: ce4/ce5/ce6/ce7 pass-e. New corpora (auto-gated):tests/codegen/comma_decl.c— a freestandingmaindeclaringint a, b;,int x, y;(scalar comma locals) andint v; int *p, *q;(pointer comma locals), using EVERY declarator (a = *p; b = *q;) and returninga + b= 42; bootcc_exit=42 == tcc_exit=42 through the blood-elf/M1/hex2 chain.tests/pp/paren_macro.c+.expectedgolden — provesX->(5),Y->(-1)(object-like, parenthesized bodies expand when NOT followed by() whileF(4)->4 + 1(immediately-(stays function-like).make testis 3 tokenizer + 23 preprocessor + 17 parser + 50 codegen + 255 libtcc in-process + 459 libtcc shared-object = 0 failed (the stale /tmp gcc reference drivers — built from pre-fix sources — were rebuilt; the libtcc harness builds them only when absent). Honest bounds: the frontier scalar05:0000386did NOT advance — this is a no-advance increment (1 of 3 toward the K=3 park rule); the engine is strictly more capable (comma-decls + paren-macro-bodies verified), and the reported line 386 is a misattribution artifact shared by both walls. The NEW wall isTOK_ELSEfrom the X-macro enum in tcc.h:1067:enum tcc_token { TOK_LAST = TOK_IDENT - 1, #define DEF(id, str) ,id, #include "tcctok.h", #undef DEF, };— the preprocessor must process directives INSIDE the enum braces (producing,TOK_INT ,TOK_VOID ... ,TOK_ELSE ...), and the parser must resolve enum constants in expressions including the cross-referencing initial valueTOK_LAST = TOK_IDENT - 1(TOK_IDENT defined later in the same list). See TASKS/NEXT.md. -
(this increment) — stage 6: the FULL real tcc.c
-enow PASSES CLEAN (frontier05:0000386->06:0000000, stage 5 -> stage 6; the X-macro enum wall closed plus the nine real-tcc defects it exposed, plus the pre-existing static 2D array row-stride bug) — resolved: the complete TinyCC tcc.c now compiles and runs clean under bootcc's-e(full-TU M1 emit with no error; the stop-rule goal step that remains is to link+run the emitted tcc). The stage-5TOK_ELSEX-macro enum wall (tcc.h:1067) closed on the pp+parser pair NEXT defined: directives inside the enum braces expand in place to the,TOK_Xrows, and enum constants resolve in expressions including the forward-referencingTOK_LAST = TOK_IDENT - 1. Past the enum the wall was a chain of genuine engine defects, each isolated with a minimal repro and atests/codegen/corpus: (A) PROTOTYPE PARAM-NAME LEAK — a function prototype's parameter names bled into the later definition's symbol resolution soemit_function_asmpicked the wrong type; the resolver now prefers the DEFINITION (is_def) type when both a prototype and a definition exist, kept within M2's four-local limit because a fifth local in that function miscompiles under M2 (the compiler's own stack corrupts at run time, surfacing in an UNRELATED function's emit — the target mnemonic buffer read as garbage -> "asm: unsupported mnemonic" -> SEGV, with the truncated M1 losing the bufferedemotail). (B) BAREwhile (0);empty statement now lowers toST_EMPTYincg_stmt. (C) TRAILINGchar const— a qualifier after the type keyword no longer registers a bogusconstglobal and drops the declaration. Plus: pp##paste rescan (a paste naming a macro re-scans for re-expansion), return-comma, selfref typedef, sizeof-arg call, struct-ternary assign, enum-init-newline. The biggest one — STATIC 2D ARRAY ROW STRIDE (pre-existing in HEAD, not a WIP regression; HEAD fails identically):esize()reports the DECAYING 8-byte pointer width for ANYTYPE_ARRAY(intentional value-width:alloc_localoverrides tot->sizefor frame reservation,es_addstores 8 for the decayed value), and both the global-init row advance inginit_filland the index scale inpointee_szusedesize(ty->base)as a ROW STRIDE — soint m[4][4]placed rows at 8 (not 16) andnames[i]scaled by 8 (not 4); data and code were consistently wrong, which is why the-sdump (array[4]<array[4]<int>> size=64) looked right while the bytes and stride did not (host-gcc A/B + afprintftrace onginit_fillpinned the outer row advance at 8). Newelem_bytes(t)returnst->sizefor array elements andesize()otherwise;ginit_fill's five row-stride sites andpointee_sznow go through it, leaving the decay semantics untouched (rwidth, EX_NONE/EX_DEREF loads,alloc_local/es_add,cg_store). Probes exact:static int[4][4]brace-init const-index (14), variable-index diagonal loop (34),char[4][4]string-initconst_trailing(40). Nine new corpora intests/codegen/(bare_semi_loop, const_trailing, enum_init_newline, param_name_def, paste_macro_rescan, return_comma, selfref_typedef, sizeof_arg_call, struct_ternary_assign); the two stale /tmp gcc reference drivers (bootcc-libtcc-gcc,boot-ltcc-so-gcc) rebuilt from the updated sources after the first libtcc emit-gate failures.make testis 3 tokenizer + 23 preprocessor + 17 parser + 59 codegen + 300 libtcc in-process + 540 libtcc shared-object = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus; two clean M2 builds cmp byte-identical; gate GO with the ratchet advancing. M2-subset discipline holds (flat if/else, decls at block tops, no ternary;elem_bytesis a two-line helper). Honest bounds kept open: the cleanly emitted full-tcc M1 is not yet LINKED+RUN — that is the next increment and the stop-rule goal; the hex2R_X86_64_64absolute data pointer and the direct in-process image run stay open as before. See TASKS/NEXT.md. -
e099b0e— fixed the entire-vcrash chain in the real tcc.c built by bootcc (four verified engine fixes, each isolated with a minimal repro and a committed regression test) — resolved: (1) SWITCH CASE-LABEL OVERFLOW (src/boot_sym.ccg_switch): the fixed 64-slotsw_lab/sw_val/sw_isdefarrays overflowed onnext_nomacro1's 97 labels (96 cases + default; tccpp.c:2583-3100), and writes at label 65+ ran past the arrays into the ADJACENTsw_val[]slots (e.g.sw_val[0]got a label number, so the " " case comparedcmp $0x1instead ofcmp $0x20); now#define SW_MAX 256with guarded writes and grownsave_lab/save_val/save_def[SW_MAX]— the largest switches in tcc are 98 (tccpp.c), 68 (tccelf.c), 50 (libtcc.c), 46 (tccgen.c). (2)_startNEVER PASSED ARGV (src/boot_sym.cemit_runtime): for these static ELFs the kernel sets up the stack ([rsp]=argc,[rsp+8]=argv, gdb-verified) but leaves rdi/rsi zeroed, while the emitted_startdidmov rbp,rsp; call mainrelying on them;_startnow loadsmov rax,rsp; mov rax,[rax]; mov rdi,rax; lea rsi,[rsp+8]before the call. (3) FOR-LOOPcontinueSKIPPED THE INCREMENT (src/boot_sym.ccg_for):con_lab[con_n] = lcpointed continue at the loop TOP, orphaning the increment block, sofor(i=0;i<n;i++){if(..)continue;}spun forever — this is what frozetcc_parse_args' option scan (strstartcalled 40+ times with val="h"); continue now targets a new labellibefore the increment when one exists (li = lcfor increment-less for-loops, so their behavior is unchanged). (4) ESC_FV.C RAW NUL BYTE (test file): the previous session's write-tool backslash mangling left a NUL at offset 111 in the comment;bootcc -e(byte stream) was fine but the libtcc in-process driver reads into a NUL-terminated buffer, truncating the snippet somainwas missing from the M1 (4 failures); rewritten via python3 (chr(92)),od -c-verified, and all tests scanned clean. New regression tests:tests/codegen/switch_many.c(74 labels, fallthroughs, hits first/middle/beyond-64 + default),tests/codegen/argc_argv.c(argc must be 1),tests/codegen/for_continue.c(continue must run the increment) — plus the prior session'sneg_int_loop.cand the rewrittenesc_fv.c.make testis 3 tokenizer + 23 preprocessor + 17 parser + 64 codegen + 325 libtcc in-process + 585 libtcc shared-object = 0 failed; two clean M2 builds cmp byte-identical;sh tools/gate.shGO (frontier06:0000000holds — no ratchet exception).-vprogress: rc=139 (old crash) → 1 (argv zero) → 124 (continue spin) → 139 at a NEW, distinct, documented blocker: NULL-deref atmov (%rdi),%raxin an unnamed early-runtime function (0x6007b3 in the last build), called from a printf/error path (caller region ~0x66d638: printf(STRING_84), then 2× call 0x6004a2, then the crashing fn with rdi=NULL) — addresses shift on every rebuild, re-nmafter each build; the likely target is the version/error1 output path, exactly what-vneeds. The prior session's "sprintf drops last digit" and "member-store/garbage buf_ptr" theories remain disproven/unreproduced. See TASKS/NEXT.md. -
(this increment) — codegen hardening + the struct-copy size-clamp that unblocks the bootcc-built tcc
-runpast the "cannot cast from/to void" error (frontier HOLDS at06:0000000; smoke2 advances from rc=1 to a distinct link/lib-path blocker, rc=139). A bundle of codegen fixes, each isolated with a repro or a committed corpus: (1) sal_rbx ModRM byte (tools/amd64_defs_extra.M1): the wide-constant idiom's middle-16 shift was encoded48C1E1=shl $imm,%RCX(ModRM rm 001) instead of48C1E3=shl $imm,%RBX(rm 011) — one wrong byte that broke every 64-bit literal (the-1/0xFFFF idiom never shifted the high half), driving the 4 codegen regressions (neg_int_loop exit, pf_fmt/pf_long 65535, fold_arith off-by-2). (2) cg_const_rax hi==0 sign-extension (src/boot_sym.c): a constant whose high 32 bits are 0 must emit a SINGLEmov $imm32,%rax(which sign-extends = correct int-to-register semantics); the old bit31-of-lo check zero-extended instead, so-9printed as 4294967287. (3) parse_specifierlong long int(src/boot_sym.c): the trailingintafterlong longwas only consumed in thelongelse-branch, solong long int f1(...)declared a spurious globalint(type long long) and LOST thef1function; theif(ident_is("int")) advance()now applies after bothlong longandlong. (4) STRUCT-COPY SIZE CLAMP (src/boot_sym.ccg_assign+ newcg_store_agg_n): the SysV 9..16-byte aggregate ASSIGN path copied BOTH eightbytes (16 bytes) unconditionally, so a 12-bytestruct FuncAttrcopy (s->f = ad->fin post_type) wrote 4 spare bytes into the ADJACENTCType type.t, zeroing the function's return type; the built tcc then readfunc_vt = sym->type= VT_VOID in gfunc_prolog and failed every function with "cannot cast from/to void". The store now writes EXACTLY the aggregate's real size (second half emitted as 4/2/1-byte chunks totalling size-8; size 16 unchanged). This is what removed the void-cast error: the built tcc now compiles triv.c's codegen cleanly and reaches the LINK phase. Runtime (tools/tcc_runtime.S / tcc_runtime.M1, regenerated 149 symbols): the printf digit-stack drop and the fopen path fixes carried from the prior session. New corpora tests/codegen/{anonunion,goto_label,multistr,bitinit}.c.make testis 3 tokenizer + 23 preprocessor + 17 parser + 68 codegen + 345 libtcc in-process + 621 libtcc shared-object = 0 failed; two clean M2 builds cmp byte-identical;sh tools/gate.shGO (frontier06:0000000holds — no ratchet exception). NEW-runblocker (the stop-rule goal step): the bootcc-built tcc now links triv.c but cannot find its standard libraries at the CONFIG-hardcoded absolute paths —/tcc/libtcc1.a(CONFIG_TCCDIR "/tcc", config.h:5),//lib/libgcc_s.so.1(CONFIG_SYSROOT "/" + CONFIG_LDDIR "lib"), and libc — none of which exist in the build environment; it then segfaults (rc=139) in the missing-library error path. See TASKS/NEXT.md. -
(this increment) — enum-typed variables were misclassified as enum CONSTANTS:
is_enum_const(src/boot_sym.c) treated ANYSC_AUTOenum-typed symbol as an enumerator, so a function-localenum M mode;(or a file-scopeenum M g;) was built as an rvalue EX_CONST (lv=0) and any assignment to it failed "lvalue required in assignment" at boot_sym.c:2227. The wall first surfaced on the x86_64 retarget probe (x86_64-gen.c:1127,X86_64_Mode modelocals — the coherent fix for the smoke2 32/64-bit in-process-execution wall, since in-process-runneeds host==target==64-bit). Fix:struct symbolgainsint is_enum(src/bootcc.h); the enumerator registration inparse_enumis the ONLY place it is set (es->is_enum = 1), andis_enum_constnow returnss->is_enum != 0— enumerators are constants by registration, enum-typed variables are ordinary lvalues at any scope (the alternativescope_index != 1hack would have left a file-scopeenum M g;broken). All three call sites (identifier resolution,dump_symbols,emit_globals) go through the same predicate; the latter two only walk the file-scope dump chain anyway. Repro v7 (local enum assign) and v12 (file-scope enum global + local) both pass-xwith lv=1; the x86_64x86_64-gen.c-eprobe advances past the 1127 wall to a distinct later blocker (codegen: undeclared identifierat token line 2274 — beyond the file's 2258 lines, a token-stream offset; that is the next increment on the retarget path). New corpustests/codegen/enum_local.c(local enum decl+assign, file-scope enum global store, three enumerator values; returns 4) is TCC-parity green (der=4 tcc=4, stdout identical) and passes the libtcc in-process + -ltcc/dlopen suites.make testis 3 tokenizer + 23 preprocessor + 17 parser + 69 codegen + 350 libtcc in-process + 630 libtcc shared-object = 0 failed; m2==gcc emitted-M1 gate holds; two clean M2 builds cmp byte-identical;sh tools/gate.shGO (frontier HOLDS at06:0000000— no ratchet exception; this is a no-advance increment, the frontier measures the i386-target tcc.c emit which is unaffected by the fix). See TASKS/NEXT.md. -
(this increment) — the x86_64 retarget EMIT path closed: the M2-built
build/amd64/bootccnow compiles the FULL x86_64 tcc.c cleanly (-e-> ~2.3 MB M1, rc=0, empty stderr) — the x86_64 retarget (host==target==64-bit, the coherent fix for the smoke2 in-process-execution wall) now EMITS. Three real blockers cleared, each isolated with a repro (x64a2.c / x64b1.c / x64c1.c) and, for the engine ones, a TCC-parity corpus: (1)abortenvironment gap: the x86_64 backend'sgen_mov64dead-code fallback callsabort()(x86_64-gen.c:607/615) which portable_libc's stdlib.h does not declare, so the first x86_64-specificcodegen: undeclared identifierwas onabort(the i386 backend never calls it). The scratchassert.hshim (in /home/lrvick/.jcode/scratch/tccx64/) gainsvoid abort(void);— an environment completion, NOT a tcc source change (tcc sources stay byte-identical). (2) MULTI-LINE MACRO ARGUMENT (src/boot_pp.cclone_arg): a function-like macro argument that spans multiple lines (a backslash-continuation in the argument text) was truncated at end-of-line becauseclone_argpassed the LINE'seoltoken as the argument bound; it now passesNULLso the argument's own tokens (which carry their continuation newlines) bound it.pp_walkadditionally gained a cross-line re-anchor: when a macro expansion's resume token lands past the line'seol(a multi-line macro arg), the code-line tail re-anchorscurto that token, emits the consumedeol, and re-runs the line setup (aspannedflag +break) so the outer loop re-establishes the new line. Repro x64a2.c (aCHECK(...)macro with a multi-line arg) passes-e(rc=0) and its-Pdump shows the multi-lineCHECK(...)correctly collapsed. New corpustests/codegen/multiline_macro_arg.c(returns 5, TCC-parity green). (3) BARE FUNCTION-SCOPE ENUM SEGFAULT (src/boot_sym.cparse_local_decl~3637): x86_64-gen.c:1195classify_x86_64_va_argholds a FUNCTION-SCOPE BARE ENUM (enum __va_arg_type { ... };with NO declarator) — a type-only declaration.parse_local_declcreated anST_DECLnode withname = NULLfor it, andlayout_stmtcalledalloc_local(NULL), which dereferencednameines_addand segfaulted (rc=139, empty stderr, after the M1 had already emitted). Fix: when the declarator name isNULL(a bare type declaration with no object),parse_local_decldoes NOT create anST_DECLnode — it consumes any trailing comma and continues, leaving the type registered but no local slot. Thenew_symcall stays guarded byty != NULL. Repro x64c1.c (function-scope bare enum) passes rc=0. New corpustests/codegen/bare_enum_local.c(returns 6, TCC-parity green). USER CORRECTION CODIFIED (AUTONOMY.md rule 6): "we must never rely on GCC — bootcc must be fully buildable with M2Libc/M2." Interpretation (recorded as a memory correction + AUTONOMY.md rule 6): the product build must be PURE M2-Planet; GCC may exist ONLY as an optional m2==gcc byte-drift oracle (same sources, two builds, byte-identical), NEVER a build input, a gate requirement, or the path used to validate an increment. Discovered the "faithful x86_64 probe" (frontier-probe) is a gcc build of the engine, so the increment was RE-VALIDATED gcc-free: the M2-builtbuild/amd64/bootcccompiles the full x86_64 tcc.c cleanly (m2-rc=0, err-bytes=0,tccx64-m2.M1= 2,302,506 bytes) and the i386 tcc.c (2,191,066-byte M1). The product build (build/amd64/bootcc) is confirmed pure M2-Planet -> blood-elf -> M1 -> hex2 (no gcc). The twolibtcc-so-emitfailures were stale-oracle test-infra artifacts:$GCDIR/driver(a gcc reference) was cached by EXISTENCE ONLY ([ ! -x "$GCDIR/driver"]) and had been built before this increment's src changes; refreshing the so oracle cleared them (no engine defect).make testis 3 tokenizer + 23 preprocessor + 17 parser + 71 codegen + libtcc in-process + libtcc so = 0 failed; the m2==gcc emitted-M1 gate holds for every corpus; two clean M2 builds cmp byte-identical;sh tools/gate.shGO (frontier HOLDS at06:0000000— no ratchet exception; the frontier measures the i386-target tcc.c emit, which is unaffected by the x86_64 probe work). See TASKS/NEXT.md. -
(this increment) — wire
tools/build-tcc.shto the x86_64 target and land the stop-rule chain at smoke1 (the bootcc-built tcc now BUILDS and RUNS; smoke2-run triv.creaches a new, precisely-diagnosed segfault in the x86_64 ELF-output path) — resolved as far as this increment goes: the 4-step chain (blood-elf --64 -> M1 amd64 defs -> hex2 @0x00600000) now links a 1,010,289-byte ELF wheretcc -dumpversionprints0.9.26rc=0 — previously the chain died at the hex2 link with "Target label FUNCTION_abort is not valid". Two changes. (1) tools/build-tcc.sh: emit is now the M2-builtbuild/amd64/bootcc(AUTONOMY rule 6 — the gcc-built frontier-probe stays an oracle, never a build input), TCC_SRC defaults to the scratch x86_64 copy /home/lrvick/.jcode/scratch/tccx64/tcc.c (pristine tcc-0.9.27 dir untouched, still i386), AFLAGS retargeted to x86_64 (-DPTR_SIZE=8 -DLDOUBLE_SIZE=16 -DCHAR_BIT=8 -DHAVE_LONG_LONG -DSTDC_INT_TYPES -DTCC_IS_NATIVE); the vendored chain steps are already amd64 and unchanged. (2) src/boot_sym.cemit_runtime: new:FUNCTION_abort— the x86_64 backend'sgen_mov64dead-code fallback callsabort()(x86_64-gen.c:607/615) which the i386 path never referenced, so the freestanding runtime had no such label and the linker refused the TU; the minimal stub terminates with exit status 134 (=128+SIGABRT) via the exit syscall (mov rdi %134; mov rax %60; syscall). All suites green (3 tokenizer + 23 pp + 17 parser + 71 codegen + 360 libtcc in-process + 648 libtcc so = 0 failed; the two cached gcc oracles under $TMPDIR/bootcc-libtcc-gcc + boot-ltcc-so-gcc refreshed after the emit change), two clean M2 builds cmp byte-identical, frontier holds 06:0000000, gate GO. smoke2 diagnosis (gdb, debug build at fixed path /home/lrvick/.jcode/scratch/tccx64/dbg/tcc): the segfault is inFUNCTION_put_elf_sym(tccelf.c) atmovsbq (%rax),%rax— thename[0]read inif (name && name[0])— with the 7th argument (first SysV stack argument) = 0x48c43c0 (garbage, below the image base 0x600000). The prologue disassembly loads that arg from[rbp+24](lea 0x18(%rbp)->mov), while the callerset_elf_sym(enclosing the L5145 call site) pushes 4 stack words then pops into r9/r8/rcx/rdx andcalls. The prologue stack-arg load formula lives at src/boot_sym.c:8007/8018 (lea_rax,[rbp+DWORD] %24+(i-6)*8),cg_vaat :5788 uses the same base, and the caller-side excess-arg push is at :5689-5730 — the exact caller/callee asymmetry is the next increment. Minimal 7/8/9-arg repros (scratch x64d1-x64d6, incl. pointer-deref and stack-arg forwarding) ALL pass with bootcc==tcc, i.e. simple calls use a self-consistent convention and the real code has a pattern that breaks it — the next step is a discriminating repro that actually fails, then the offset fix + a tests/codegen/ corpus. The gcc-oracle tcc (same scratch source/headers/defines, gcc -O1) ALSO segfaults but at an unrelated earlier point (__sigsetjmpin tcc_compile, libtcc.c:634 — portable_libc setjmp.h definesjmp_bufas a 4-byteintwhile glibc setjmp writes ~24 bytes), so it is not a valid control for this crash; the host-installed tcc returns rc=7 correctly. State: smoke1 PASS, smoke2 rc=139 (root-caused to the stack-arg prologue offset, not yet fixed), smoke3 not yet reached; exact crash state + repro inventory recorded at scratch /home/lrvick/.jcode/scratch/tccx64/smoke2-crash-notes.md. See TASKS/NEXT.md. -
(this increment) — FIXED the true smoke2 root cause: ex_bin dropped the pointer type of
T* + int, so chained pointer arithmetic(T*)p + a + blost its element scale (src/boot_sym.c; smoke2 advances from the put_elf_sym SEGV rc=139 to a new, distinct blocker: the compiled tcc's own runtime-library search is broken and it hangs loading libgcc_s.so.1, rc=124 timeout). The bug: every binary-op node inex_binis createdkind=TYPE_INT sz=4 sign=1and never inherited a pointer operand's type, so the inner ADD(struct S*)buf + firstscaled correctly (left operand a pointer) but the ADD's RESULT was tagged TYPE_INT, and the outer ADD saw a non-pointer left operand and emitted a plain unscaledadd— the second increment advanced 1 byte, not 24. Forensics: a gdb data dump of the tccelf.c:169 loopElfSym *sym = (ElfSym*)s->data + first_sym + iin the crash showedsymadvancing +1 byte per iteration (0x8c4430 -> 0x8c4431) instead of +24 (sizeof Elf64_Sym); the byte-shifted row read first word 0x04000000 -> name = data + 0x04000000 = 0x48c43d0 (below image base 0x600000) -> SEGV atname[0]in put_elf_sym. M1 of the minimal repro x64ptr.c confirmed it exactly:firstscaled (mov/mul %24),iplainadd. The fix:ex_binnow inherits the pointer type for EX_ADD/EX_SUB when either operand is a pointer (T* + int -> T*, correct C semantics;T* + T*is not valid C so at most one operand is a pointer), via a forward-declaredis_ptrt/node_set_type(no M2-subset violations). Three prior hypotheses were DISPROVEN this session before the true cause: (1) "prologue stack-arg offset 24->8" was WRONG (24 is correct; a 7-arg forwarding repro passes), (2) "macro-arg-split in the set_elf_sym call" was WRONG (x64m1..x64m5 all pass 155==155; the "10 pushes" was a miscount including 3 transient ST_INFO computation pushes — net stack = exactly the correct 7 args), (3) "upstream stack/frame corruption" was WRONG (it was the ex_bin scale loss). New corpustests/codegen/ptr_scale_chained.c(24-byte struct, byte-pointer cast to struct-pointer, a loop comparing a single-add(S*)buf + iagainst the chained(S*)buf + first + i; prints "102" and returns 102) — VERIFIED DISCRIMINATING: with the fix bootcc rc=102 == tcc rc=102 stdout identical; with the fix stashed (unfixed engine) rc=52 (chained[1] reads a misaligned word at buf+1 == 0), so it is a genuine regression pin, not a both-ways pass. All suites green (3 tokenizer + 23 pp + 17 parser + 72 codegen + libtcc in-process + libtcc so = 0 failed; the two cached gcc oracles under $TMPDIR/bootcc-libtcc-gcc + boot-ltcc-so-gcc refreshed after the new test landed — they are cached by EXISTENCE ONLY and were built pre-fix, emitting the buggy byte-arithmetic M1 for this source; rebuilt from the fixed sources and m2==gcc restored). Two clean M2 builds cmp byte-identical, frontier HOLDS 06:0000000, gate GO. Smoke progress after the fix (scratch config.h also updated — an environment completion mirroring a normal Debian install, tcc sources byte-identical:CONFIG_TRIPLET "x86_64-linux-gnu"so glibc search paths include /usr/lib/x86_64-linux-gnu, andCONFIG_TCCDIR "/usr/lib/x86_64-linux-gnu/tcc"so prebuilt libtcc1.a resolves; the old /tcc + missing-triplet paths produced the three "not found" errors): the put_elf_sym SEGV is GONE — the compiled tcc now runs triv.c's codegen and ELF symbol-table emission to completion and reaches the runtime-library stage, but two DISTINCT bugs in the compiled tcc itself surfaced (bugs in the compiled tcc's own logic, i.e. further bootcc codegen defects manifesting in tcc's file/ELF path — not in the build chain): (A)tcc: error: library 'c' not foundis printed although CONFIG_TCC_LIBPATHS (verified in the binary's embedded strings://usr/lib/x86_64-linux-gnu://usr/lib:...) contains the right dir — strace shows the compiled tcc NEVER stats any search path (no stat/newfstatat on any libc.so; setting LIBRARY_PATH changes nothing) -> tcc_add_library'sfor(i=0;i<nb_paths)loop appears to iterate zero times (candidate: tcc_split_path ':' splitting / the nb_library_paths count, or thes1->static_linklibs[] pointer); (B) after that error it opens//lib/x86_64-linux-gnu/libgcc_s.so.1(path now correct), reads the first 8192 bytes OK, then SPINS in a tight malloc/brk loop — a CLEAN gdb attach (direct launch, no timeout wrapper: the earlier "sigsuspend in libc" was a mis-attach to the wrapper PID) shows RIP=0x6afaa1 inside the tcc's own .text (a char-scanning loop,cmpb $0x25/dec %r8pattern, between FUNCTION_main 0x67d7d5 and GLOBAL_stdin 0x6afeab), monotonic brk growth 0x1d7c75a0->0x1d7ca058 with zero forward syscalls; /proc maps confirm the image is fully static (no glibc loaded). Next increment: pin bug (A) with a minimal bootcc repro (why the library_paths loop iterates zero times). See TASKS/NEXT.md. -
(this increment) — FIXED the smoke2 "library 'c' not found" root cause (bug A): a LOCAL array of string-literal POINTERS was zero-filled. In
local_agg_fill(src/boot_sym.c), the element walk treats a string literal two ways:strpath==1(leaf is TYPE_CHAR — the string FILLs a char array, decoded bytes) and the defaultagg_emit_store(fold the element througheval_const). A string literal stored in a NON-char element (achar *array element, C 6.7.9: the string's ADDRESS) hit the default, andeval_const/eval_atomreturn 0 for a string token (a string address is not an integer constant), so EVERY element was stored NULL. The directchar *p = "hello"path (ex_assign -> EX_STR -> cg_vallea [rip+%STRING_n]) always worked (constptr.c passed); only the local aggregate-fill path was broken. This is EXACTLY tcc_add_library (libtcc.c:1143)const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL }: the compiled tcc storedmov $0x0for all three initializers (disasm-confirmed), so*ppwas NULL on the first template check, tcc_add_library returned -1 without ever calling tcc_add_library_internal, and no libc candidate was ever stat'ed (zero stat syscalls in strace). Fix: a newstrpath==-1branch (leaf is not TYPE_CHAR and the current token is a string) emits an EX_ASGN whose RHS is a real EX_STR node (lea [rip+%STRING_n]) instead of folding to 0, then falls through to the loop tail so the separating comma is consumed and the next element is seen (a pointer array has many elements, unlike a single char-array fill which breaks). The char-array branch becameelse if(strpath==1)and the constant store the finalelse, so the three element cases are exclusive. New corpus tests/codegen/ptrarr_str_init.c is a discriminating regression pin: with the fix bootcc rc=31 == tcc rc=31 (stdout "hw" identical, M1 now carries 4 STRING refs); with the fix removed the same source yields rc=100 (elements NULL). The two stale gcc-oracle drivers ($TMPDIR/bootcc-libtcc-gcc + boot-ltcc-so-gcc, cached by existence) were refreshed from the fixed source after the expected m2==gcc byte-drift. All suites 0 failed (73 codegen), m2==gcc emit gate holds, two clean M2 builds byte-identical, gate GO, frontier HOLDS 06:0000000. smoke2 (-run triv.c) now resolves the library stage differently — the next blocker is recorded in TASKS/NEXT.md.