Sync VCC Plus 3.7.1 build 67 source

Refresh reviewed MCP output export, four-drive owned playtests, bounded BASIC readiness, and pinned CMOC 0.1.101 source/patches. Preserve independent source-edition identity, empty libraries, notices and privacy boundaries.

Validated 74 export/privacy checks, pinned dependency sources, and an independent unsigned universal Release build. A subsequent documentation-only correction removes an excluded qualification link; all build inputs remain identical.
This commit is contained in:
Brian Holman committed 2026-11-17 08:42:27 -07:00
1 parent 4abc194001
commit 5534005799
54 files changed
+2950 -435

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Compile and execute CMOC 0.1.101 correctness cases on both emulated CPUs."""
import argparse
import os
from pathlib import Path
import subprocess
import tempfile
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("runtime", type=Path)
parser.add_argument("core", type=Path)
parser.add_argument("rom", type=Path)
parser.add_argument("--host-arch", choices=("arm64", "x86_64"))
args = parser.parse_args()
fixture = Path(__file__).resolve().parent
runtime = args.runtime.resolve(strict=True)
command = (["/usr/bin/arch", "-" + args.host_arch] if args.host_arch else []) + [runtime / "bin/cmoc"]
env = dict(os.environ, PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
# Build values independently on the host. Include every initialized byte,
# terminating zero and neighboring sentinel rather than an in-guest assert.
language = "LANG 03F807E0 12345678 444 41424300 41424300 5541424300AA END"
cases = [("qualification.c", language),
("handler-addresses.c", "HANDLERS N1 S1 P1 END")]
with tempfile.TemporaryDirectory(prefix="vcc-cmoc-0.1.101-") as work:
diagnostics = Path(work) / "diagnostics.c"
diagnostics.write_text('''struct Empty { char; };
union EmptyUnion { long; };
int main(void) {
int;
char *pointer = (char *) 123;
int array[4];
switch (pointer) {}
switch (array) {}
return 0;
}
''')
result = subprocess.run(command + ["--coco", "-S", diagnostics], cwd=work,
env=env, capture_output=True, text=True)
output = result.stdout + result.stderr
if (result.returncode != 0 or "error:" in output
or output.count("warning: declaration specifies a type but no declarator name") != 3
or output.count("warning: switch() expression is an address") != 2):
raise RuntimeError("Unexpected CMOC diagnostics:\n" + output)
print("PASS diagnostics: three unnamed declarations, pointer and array switch warnings", flush=True)
runner = Path(work) / "run-compiled"
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
fixture.parent / "run-compiled.cpp", args.core.resolve(strict=True), "-o", runner],
check=True)
for source, expected in cases:
for optimization in ("-O0", "-O2"):
print("Checking CMOC 0.1.101", source, optimization, flush=True)
subprocess.run(command + ["--coco", optimization, "--org=2800", "--intermediate", "-Werror",
"-o", "TEST.BIN", fixture / source], cwd=work, env=env, check=True)
subprocess.run([runner, args.rom.resolve(strict=True), "TEST.BIN", expected],
cwd=work, check=True)
if __name__ == "__main__":
main()
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include <cmoc.h>
// The runtime must report the exact assembler label after each LBSR. Subtracting
// an assumed instruction width gives the pre-0.1.101 address and fails this test.
static void *expectedNullReturn;
static void *observedNullReturn;
static void *expectedStackReturn;
static void *expectedStackRegister;
static void nullHandler(void *addressPastFailedCheck)
{
observedNullReturn = addressPastFailedCheck;
}
asm void nullProbe(void)
{
asm {
import check_null_ptr_x
leax null_probe_after,pcr
stx :expectedNullReturn
ldx #0
lbsr check_null_ptr_x
null_probe_after:
}
}
static void stackHandler(void *addressPastFailedCheck, void *stackRegister)
{
printf("HANDLERS N%u S%u P%u END\n",
observedNullReturn == expectedNullReturn,
addressPastFailedCheck == expectedStackReturn,
stackRegister == expectedStackRegister);
exit(0); // The stack handler contract forbids returning.
}
asm void stackProbe(void)
{
asm {
import check_stack_overflow
import end_of_sbrk_mem
leax stack_probe_after,pcr
stx :expectedStackReturn
tfr s,d
std :expectedStackRegister
// Trigger the lower-bound check without corrupting or exhausting the
// actual stack. This is a disposable guest and no allocation follows.
ldd #$ffff
std end_of_sbrk_mem,pcr
lbsr check_stack_overflow
stack_probe_after:
}
}
int main(void)
{
set_null_ptr_handler(nullHandler);
nullProbe();
set_stack_overflow_handler(stackHandler);
stackProbe();
printf("FAIL STACK CHECK RETURNED\n");
return 1;
}
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include <cmoc.h>
// Separate tag and typedef namespaces, with values whose representation differs.
typedef unsigned Ledger;
struct Ledger { unsigned value; };
enum Route { HOME_ROUTE = 1003 };
typedef enum Route RouteAlias;
// CMOC's octal parser requires an initial \0; \103 is not supported.
static const char globalEscapes[] = "\x41" "B\0103";
static unsigned char runtimeIndex;
static unsigned receiveRoute(enum Route route)
{
return (unsigned) route + 13;
}
int main(void)
{
Ledger scalar = 0x1234;
struct Ledger record = { 0x5678 };
char localEscapes[] = "\0101\0102\x43";
unsigned char inferred[sizeof("\x41" "B\0103")];
struct { unsigned char before; char text[4]; unsigned char after; } guarded =
{ 0x55, "\x41" "B\0103", 0xaa };
printf("LANG %04X%04X %04X%04X ",
receiveRoute((enum Route) 1003), receiveRoute((RouteAlias) 2003),
scalar, record.value);
printf("%u%u%u ", (unsigned) sizeof(globalEscapes),
(unsigned) sizeof(localEscapes), (unsigned) sizeof(inferred));
// Include actual bytes and sentinels. Host owns the expected values, not
// the same compiler expression that produced the tested initializer.
for (runtimeIndex = 0; runtimeIndex < sizeof(globalEscapes); ++runtimeIndex)
printf("%02X", (unsigned char) globalEscapes[runtimeIndex]);
printf(" ");
for (runtimeIndex = 0; runtimeIndex < sizeof(localEscapes); ++runtimeIndex)
printf("%02X", (unsigned char) localEscapes[runtimeIndex]);
printf(" %02X", guarded.before);
for (runtimeIndex = 0; runtimeIndex < sizeof(guarded.text); ++runtimeIndex)
printf("%02X", (unsigned char) guarded.text[runtimeIndex]);
printf("%02X END\n", guarded.after);
return 0;
}
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Check the actual CMOC indexed-load peephole rule in a source build."""
import argparse
import re
import subprocess
import tempfile
from pathlib import Path
@@ -11,18 +12,27 @@ def main():
parser.add_argument("source_build", type=Path, help="build.py output's work/cmoc directory")
args = parser.parse_args()
src = args.source_build.resolve(strict=True) / "src"
version_match = re.search(r"^VERSION\s*=\s*([0-9]+\.[0-9]+\.[0-9]+)\s*$",
(src / "Makefile").read_text(), re.MULTILINE)
if not version_match:
parser.error("Cannot read configured CMOC version from src/Makefile")
version = version_match.group(1)
objects = sorted(path for path in src.glob("cmoc-*.o") if path.name != "cmoc-main.o")
if not objects:
parser.error("Build CMOC first; compiler objects are required")
architectures = subprocess.check_output(["lipo", "-archs", objects[0]], text=True).split()
if len(architectures) != 1 or architectures[0] not in ("arm64", "x86_64"):
parser.error("Rule check requires a single supported host architecture")
host_flags = ["-arch", architectures[0], "-mmacosx-version-min=14.0"]
fixture = Path(__file__).resolve().parent / "optimizer-rule.cpp"
with tempfile.TemporaryDirectory(prefix="vcc-cmoc-rule-") as work:
out = Path(work)
# Retain all normal compiler definitions and rename only its CLI entry
# in this extra object. The rule itself comes from unchanged build objects.
subprocess.run(["xcrun", "clang++", "-std=c++11", "-Dmain=vccCompilerDriverMain",
'-DPACKAGE="cmoc"', '-DVERSION="0.1.100"', '-DPKGDATADIR="."',
subprocess.run(["xcrun", "clang++", "-std=c++11", *host_flags, "-Dmain=vccCompilerDriverMain",
'-DPACKAGE="cmoc"', '-DVERSION="' + version + '"', '-DPKGDATADIR="."',
"-D__unix", "-I", src, "-c", src / "main.cpp", "-o", out / "driver.o"], check=True)
subprocess.run(["xcrun", "clang++", "-std=c++11", "-I", src, fixture,
subprocess.run(["xcrun", "clang++", "-std=c++11", *host_flags, "-I", src, fixture,
out / "driver.o", *objects, "-o", out / "rule-check"], check=True)
subprocess.run([out / "rule-check"], check=True)
@@ -10,7 +10,7 @@
#include <iostream>
#include <stdexcept>
void check(const char* first, const char* middleOp, const char* middle, const char* last, bool expectRemoval) {
ASMText text(true);
ASMText text(true, false); // Standard optimization; experimental DCE stays off.
text.ins("LDB", first); text.ins(middleOp, middle); text.ins("LDB", last);
const bool removed = text.removeUselessLdaOrLdb(0);
if (removed != expectRemoval) throw std::runtime_error(std::string(first) + "; " + middleOp + " " + middle + "; LDB " + last);