Skip to content

fix cross-compile datalayout#54

Merged
cs01 merged 1 commit intomainfrom
cross-compile
Feb 24, 2026
Merged

fix cross-compile datalayout#54
cs01 merged 1 commit intomainfrom
cross-compile

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Feb 24, 2026

Summary

  • Fixed chad build --target linux-x64 failing with unknown specifier 'x' target datalayout = "x86_64-unknown-linux-gnu" — the native binary was emitting the target triple as the LLVM data layout string
  • Root cause: native-compiler-lib.ts typed targetInfo as any to avoid importing TargetInfo from target.ts (which depends on Node's os module). The native compiler couldn't resolve GEP field indices for the any-typed object, so this.targetInfo.dataLayout read the wrong struct field (returning the triple instead)
  • Fix: extracted TargetInfo interface and LibC type into a new dependency-free src/target-types.ts, allowing the self-hosted path to import proper type info without pulling in Node's os module
  • Strengthened cross-compilation tests: datalayout assertion now validates actual content (must start with e-, not be the triple), and added a native binary cross-compile test that would have caught this bug in CI

Test plan

  • npm test — 226 tests pass (225 existing + 1 new native binary cross-compile test)
  • npm run verify:quick — self-hosting verification passed (Stage 0 + Stage 1)
  • .build/chad ir --target linux-x64 now emits correct target datalayout = "e-m:e-p270:32:32-..." instead of the triple
  • Node.js path (node dist/chad-node.js build --target linux-x64) still works

@cs01 cs01 merged commit 2c1828b into main Feb 24, 2026
12 checks passed
@cs01 cs01 deleted the cross-compile branch February 24, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant