selfhost: migrate tool sources to directory packages

Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
This commit is contained in:
2026-08-12 17:12:03 +09:00
parent 90f9d60291
commit c7d9dc92de
38 changed files with 197 additions and 252 deletions

View File

@@ -4,12 +4,11 @@
// exports and which DT_NEEDED entry to record. We do not pull bytes
// from the .so; the dynamic loader maps it at runtime.
package w6l;
package main;
import os;
import rt;
import strings;
import sym;
def ET_DYN_SO: u16 = 3u16;
def EM_X86_64_SO: u16 = 62u16;

View File

@@ -22,12 +22,11 @@
// [gotplt_off] .got.plt (writable; mapped by PT_LOAD #2)
// [dynamic_off] .dynamic (writable; covered by PT_DYNAMIC)
package w6l;
package main;
import os;
import rt;
import strings;
import sym;
def ET_EXEC_D: u16 = 2u16;
def EM_X86_64_D: u16 = 62u16;

View File

@@ -7,11 +7,6 @@ package main;
import os;
import rt;
import strings;
import sym;
import obj;
import dyn;
import pass;
import out;
def BASE: u64 = 4194304u64; // 0x400000
def CODE_VA_OFF: u64 = 4096u64; // .text starts at base + 0x1000

View File

@@ -1,11 +1,10 @@
// Port of cmd/w6l/obj.c.
package w6l;
package main;
import os;
import rt;
import strings;
import sym;
def ET_REL: i32 = 1;
def EM_X86_64: i32 = 62;

View File

@@ -1,11 +1,9 @@
// Port of cmd/w6l/out.c.
package w6l;
package main;
import os;
import rt;
import sym;
import dynout;
def ET_EXEC: u16 = 2u16;
def EM_X86_64_W: u16 = 62u16;

View File

@@ -3,11 +3,9 @@
// Supported relocation kinds: PC32 (=2), PLT32 (=4); both are 32-bit
// PC-relative displacements (PLT32 == PC32 for static).
package w6l;
package main;
import os;
import sym;
import dyn;
def R_X86_64_64: i32 = 1;
def R_X86_64_PC32: i32 = 2;

View File

@@ -3,7 +3,7 @@
// Singly-linked list, usually a few hundred entries; hashing isn't
// worth it yet.
package w6l;
package main;
import strings;