@scriptc/compiler 0.0.35 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +14 -11
- package/ambient/scriptc-overrides.d.ts +0 -7
- package/ambient/scriptc.d.ts +1 -1
- package/dist/backend/build-cache.d.ts +44 -0
- package/dist/backend/build-cache.js +241 -0
- package/dist/backend/build-cache.js.map +1 -0
- package/dist/backend/{emission/emit-async.d.ts → c/async.d.ts} +21 -30
- package/dist/backend/{emission/emit-async.js → c/async.js} +270 -286
- package/dist/backend/c/async.js.map +1 -0
- package/dist/backend/{emission/emitter.d.ts → c/c-emitter.d.ts} +6 -23
- package/dist/backend/{emission/emitter.js → c/c-emitter.js} +53 -107
- package/dist/backend/c/c-emitter.js.map +1 -0
- package/dist/backend/c/exprs.d.ts +8 -0
- package/dist/backend/c/exprs.js +7937 -0
- package/dist/backend/c/exprs.js.map +1 -0
- package/dist/backend/{emission/emit-island.d.ts → c/island.d.ts} +5 -5
- package/dist/backend/{emission/emit-island.js → c/island.js} +24 -22
- package/dist/backend/c/island.js.map +1 -0
- package/dist/backend/{emission → c}/may-throw.d.ts +1 -1
- package/dist/backend/{emission → c}/may-throw.js +4 -1
- package/dist/backend/c/may-throw.js.map +1 -0
- package/dist/backend/{emission/emit-shapes.d.ts → c/shapes.d.ts} +19 -19
- package/dist/backend/{emission/emit-shapes.js → c/shapes.js} +78 -87
- package/dist/backend/c/shapes.js.map +1 -0
- package/dist/backend/{emission/emit-stmts.d.ts → c/stmts.d.ts} +12 -12
- package/dist/backend/{emission/emit-stmts.js → c/stmts.js} +395 -343
- package/dist/backend/c/stmts.js.map +1 -0
- package/dist/backend/{emission/emit-types.d.ts → c/types.d.ts} +1 -1
- package/dist/backend/{emission/emit-types.js → c/types.js} +42 -286
- package/dist/backend/c/types.js.map +1 -0
- package/dist/backend/c/types.test.js +25 -0
- package/dist/backend/c/types.test.js.map +1 -0
- package/dist/backend/{emission/emit-walkers.d.ts → c/walkers.d.ts} +19 -41
- package/dist/backend/{emission/emit-walkers.js → c/walkers.js} +242 -304
- package/dist/backend/c/walkers.js.map +1 -0
- package/dist/backend/external-c.d.ts +33 -0
- package/dist/backend/external-c.js +51 -0
- package/dist/backend/external-c.js.map +1 -0
- package/dist/backend/ffi-callbacks.d.ts +1 -1
- package/dist/backend/ffi-callbacks.js +4 -3
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/{library-identity.d.ts → library-identity-markers.d.ts} +0 -4
- package/dist/backend/{library-identity.js → library-identity-markers.js} +10 -9
- package/dist/backend/library-identity-markers.js.map +1 -0
- package/dist/backend/link-plan.d.ts +37 -0
- package/dist/backend/link-plan.js +26 -0
- package/dist/backend/link-plan.js.map +1 -0
- package/dist/backend/linker.d.ts +22 -0
- package/dist/backend/linker.js +236 -0
- package/dist/backend/linker.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +4 -0
- package/dist/backend/llvm/blocks.js +29 -0
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +2 -19
- package/dist/backend/llvm/classes.js +20 -52
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +4 -0
- package/dist/backend/llvm/common.js +27 -0
- package/dist/backend/llvm/common.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +3 -8
- package/dist/backend/llvm/dyn.js +159 -224
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +4 -1
- package/dist/backend/llvm/emitter.js +548 -9988
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.d.ts +4 -0
- package/dist/backend/llvm/expr-async.js +726 -0
- package/dist/backend/llvm/expr-async.js.map +1 -0
- package/dist/backend/llvm/expr-bytes.d.ts +13 -0
- package/dist/backend/llvm/expr-bytes.js +456 -0
- package/dist/backend/llvm/expr-bytes.js.map +1 -0
- package/dist/backend/llvm/expr-callbacks.d.ts +22 -0
- package/dist/backend/llvm/expr-callbacks.js +520 -0
- package/dist/backend/llvm/expr-callbacks.js.map +1 -0
- package/dist/backend/llvm/expr-calls.d.ts +2 -0
- package/dist/backend/llvm/expr-calls.js +618 -0
- package/dist/backend/llvm/expr-calls.js.map +1 -0
- package/dist/backend/llvm/expr-containers.d.ts +25 -0
- package/dist/backend/llvm/expr-containers.js +637 -0
- package/dist/backend/llvm/expr-containers.js.map +1 -0
- package/dist/backend/llvm/expr-context.d.ts +255 -0
- package/dist/backend/llvm/expr-context.js +2 -0
- package/dist/backend/llvm/expr-context.js.map +1 -0
- package/dist/backend/llvm/expr-control.d.ts +2 -0
- package/dist/backend/llvm/expr-control.js +473 -0
- package/dist/backend/llvm/expr-control.js.map +1 -0
- package/dist/backend/llvm/expr-dispatch.d.ts +4 -0
- package/dist/backend/llvm/expr-dispatch.js +153 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -0
- package/dist/backend/llvm/expr-dynamic.d.ts +2 -0
- package/dist/backend/llvm/expr-dynamic.js +810 -0
- package/dist/backend/llvm/expr-dynamic.js.map +1 -0
- package/dist/backend/llvm/expr-island.d.ts +15 -0
- package/dist/backend/llvm/expr-island.js +690 -0
- package/dist/backend/llvm/expr-island.js.map +1 -0
- package/dist/backend/llvm/expr-primitives.d.ts +6 -0
- package/dist/backend/llvm/expr-primitives.js +642 -0
- package/dist/backend/llvm/expr-primitives.js.map +1 -0
- package/dist/backend/llvm/expr-records.d.ts +9 -0
- package/dist/backend/llvm/expr-records.js +299 -0
- package/dist/backend/llvm/expr-records.js.map +1 -0
- package/dist/backend/llvm/expr-stream-bridges.d.ts +13 -0
- package/dist/backend/llvm/expr-stream-bridges.js +420 -0
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -0
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +12 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +360 -0
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.d.ts +5 -0
- package/dist/backend/llvm/lib-dispatch.js +267 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -0
- package/dist/backend/llvm/lib-filesystem.d.ts +6 -0
- package/dist/backend/llvm/lib-filesystem.js +594 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -0
- package/dist/backend/llvm/lib-network.d.ts +2 -0
- package/dist/backend/llvm/lib-network.js +429 -0
- package/dist/backend/llvm/lib-network.js.map +1 -0
- package/dist/backend/llvm/lib-process.d.ts +5 -0
- package/dist/backend/llvm/lib-process.js +585 -0
- package/dist/backend/llvm/lib-process.js.map +1 -0
- package/dist/backend/llvm/lib-shared.d.ts +6 -0
- package/dist/backend/llvm/lib-shared.js +687 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -0
- package/dist/backend/llvm/lib-stream.d.ts +2 -0
- package/dist/backend/llvm/lib-stream.js +470 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +12 -2
- package/dist/backend/llvm/shapes.js +66 -307
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +52 -0
- package/dist/backend/llvm/shapes.test.js.map +1 -0
- package/dist/backend/llvm/unsupported.d.ts +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -3
- package/dist/backend/llvm/walkers.js +195 -222
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +45 -0
- package/dist/backend/native-codegen.js +275 -0
- package/dist/backend/native-codegen.js.map +1 -0
- package/dist/backend/native-codegen.test.js +226 -0
- package/dist/backend/native-codegen.test.js.map +1 -0
- package/dist/backend/native-link-info.d.ts +96 -0
- package/dist/backend/native-link-info.js +243 -0
- package/dist/backend/native-link-info.js.map +1 -0
- package/dist/backend/native-link-info.test.d.ts +1 -0
- package/dist/backend/native-link-info.test.js +134 -0
- package/dist/backend/native-link-info.test.js.map +1 -0
- package/dist/backend/{cc.d.ts → native-toolchain.d.ts} +54 -34
- package/dist/backend/{cc.js → native-toolchain.js} +231 -810
- package/dist/backend/native-toolchain.js.map +1 -0
- package/dist/backend/native-toolchain.test.d.ts +1 -0
- package/dist/backend/{cc-cache.test.js → native-toolchain.test.js} +219 -7
- package/dist/backend/native-toolchain.test.js.map +1 -0
- package/dist/backend/object-localize.js +1 -1
- package/dist/backend/runtime-abi.d.ts +10 -0
- package/dist/backend/runtime-abi.js +11 -0
- package/dist/backend/runtime-abi.js.map +1 -0
- package/dist/backend/runtime-pack-targets.test.d.ts +1 -0
- package/dist/backend/runtime-pack-targets.test.js +54 -0
- package/dist/backend/runtime-pack-targets.test.js.map +1 -0
- package/dist/backend/runtime-pack.d.ts +112 -0
- package/dist/backend/runtime-pack.js +305 -0
- package/dist/backend/runtime-pack.js.map +1 -0
- package/dist/backend/runtime-pack.test.d.ts +1 -0
- package/dist/backend/runtime-pack.test.js +473 -0
- package/dist/backend/runtime-pack.test.js.map +1 -0
- package/dist/backend/targets.d.ts +76 -0
- package/dist/backend/targets.js +262 -0
- package/dist/backend/targets.js.map +1 -0
- package/dist/backend/targets.test.d.ts +1 -0
- package/dist/backend/targets.test.js +41 -0
- package/dist/backend/targets.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +41 -0
- package/dist/backend/vendor-archives.js +462 -0
- package/dist/backend/vendor-archives.js.map +1 -0
- package/dist/compat/fetch-profile.d.ts +0 -1
- package/dist/compat/fetch-profile.js +0 -1
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/coverage/report.js +3 -3
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +35 -33
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +11 -12
- package/dist/diagnostics/diagnostic.js +19 -17
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/render.d.ts +1 -1
- package/dist/diagnostics/render.js +1 -1
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/executable/{early-cache.d.ts → executable-cache.d.ts} +2 -2
- package/dist/executable/{early-cache.js → executable-cache.js} +36 -98
- package/dist/executable/executable-cache.js.map +1 -0
- package/dist/executable/executable-cache.test.d.ts +1 -0
- package/dist/executable/{early-cache.test.js → executable-cache.test.js} +3 -3
- package/dist/executable/executable-cache.test.js.map +1 -0
- package/dist/ffi/{profile.js → ffi-manifest.js} +1 -1
- package/dist/ffi/ffi-manifest.js.map +1 -0
- package/dist/frontend/builtin-modules.d.ts +21 -0
- package/dist/frontend/builtin-modules.js +82 -0
- package/dist/frontend/builtin-modules.js.map +1 -0
- package/dist/frontend/cjs-lexer.d.ts +7 -0
- package/dist/frontend/cjs-lexer.js +15 -17
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/dts-paths.d.ts +26 -0
- package/dist/frontend/dts-paths.js +41 -0
- package/dist/frontend/dts-paths.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +0 -2
- package/dist/frontend/input-tracker.js +1 -4
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/lib-contract.d.ts +1 -5
- package/dist/frontend/lib-contract.js +1 -1
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/lib-exports.d.ts +1 -1
- package/dist/frontend/lowering/array-values.d.ts +8 -0
- package/dist/frontend/lowering/array-values.js +60 -0
- package/dist/frontend/lowering/array-values.js.map +1 -0
- package/dist/frontend/lowering/call-position.d.ts +4 -0
- package/dist/frontend/lowering/call-position.js +7 -0
- package/dist/frontend/lowering/call-position.js.map +1 -0
- package/dist/frontend/lowering/callback-arg.d.ts +20 -0
- package/dist/frontend/lowering/callback-arg.js +44 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +1 -1
- package/dist/frontend/lowering/lib-boundary.js +34 -34
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.d.ts +22 -0
- package/dist/frontend/lowering/lower-array-sort.js +619 -0
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -0
- package/dist/frontend/lowering/lower-assert.d.ts +3 -3
- package/dist/frontend/lowering/lower-assert.js +214 -241
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +74 -146
- package/dist/frontend/lowering/lower-builtins.js +1285 -1233
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +59 -192
- package/dist/frontend/lowering/lower-calls.js +1644 -1506
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +62 -125
- package/dist/frontend/lowering/lower-classes.js +832 -866
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +5 -12
- package/dist/frontend/lowering/lower-comptime.js +32 -31
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +35 -135
- package/dist/frontend/lowering/lower-containers.js +1984 -2227
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.d.ts +3 -7
- package/dist/frontend/lowering/lower-dgram.js +97 -111
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.d.ts +4 -4
- package/dist/frontend/lowering/lower-enums.js +30 -30
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/{lower-emitter.d.ts → lower-event-emitter.d.ts} +7 -18
- package/dist/frontend/lowering/{lower-emitter.js → lower-event-emitter.js} +172 -174
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -0
- package/dist/frontend/lowering/lower-expando.d.ts +5 -5
- package/dist/frontend/lowering/lower-expando.js +40 -40
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +60 -264
- package/dist/frontend/lowering/lower-exprs.js +2361 -1765
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +6 -6
- package/dist/frontend/lowering/lower-generators.js +73 -72
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +5 -17
- package/dist/frontend/lowering/lower-inspect.js +273 -261
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +39 -49
- package/dist/frontend/lowering/lower-island.js +447 -513
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +7 -10
- package/dist/frontend/lowering/lower-mixins.js +85 -85
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +12 -18
- package/dist/frontend/lowering/lower-modules.js +284 -283
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +23 -49
- package/dist/frontend/lowering/lower-namespaces.js +123 -115
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +18 -25
- package/dist/frontend/lowering/lower-server.js +909 -899
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +30 -149
- package/dist/frontend/lowering/lower-stmts.js +1463 -1285
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +12 -12
- package/dist/frontend/lowering/lower-stream.js +300 -301
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.d.ts +5 -5
- package/dist/frontend/lowering/lower-test.js +82 -82
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +134 -22
- package/dist/frontend/lowering/lowerer.js +1277 -126
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.d.ts +11 -0
- package/dist/frontend/lowering/pairs-snapshot.js +85 -0
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -0
- package/dist/frontend/lowering/static-this.d.ts +6 -0
- package/dist/frontend/lowering/static-this.js +24 -0
- package/dist/frontend/lowering/static-this.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +24 -35
- package/dist/frontend/lowering/surfaces.js +78 -66
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm-static-rewrite.js +6 -28
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +0 -10
- package/dist/frontend/npm-static.js +4 -7
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +0 -24
- package/dist/frontend/npm.js +11 -85
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/program.d.ts +3 -1
- package/dist/frontend/program.js +9 -4
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-registry.d.ts +0 -2
- package/dist/frontend/provenance-registry.js +0 -10
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/provenance.js +4 -7
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/resolve.d.ts +7 -2
- package/dist/frontend/resolve.js +12 -17
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.d.ts +1 -0
- package/dist/frontend/resolve.test.js +29 -0
- package/dist/frontend/resolve.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +2 -2
- package/dist/frontend/ts7/adapter.js +1 -1
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/checker.js +2 -36
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/enums.js +2 -1
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/{program.js → program-adapter.js} +7 -6
- package/dist/frontend/ts7/program-adapter.js.map +1 -0
- package/dist/frontend/ts7/world-check.d.ts +1 -3
- package/dist/frontend/ts7/world-check.js +3 -1
- package/dist/frontend/ts7/world-check.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +8 -0
- package/dist/frontend/tsc-codes.js +109 -0
- package/dist/frontend/tsc-codes.js.map +1 -0
- package/dist/frontend/{types.d.ts → type-mapper.d.ts} +2 -25
- package/dist/frontend/{types.js → type-mapper.js} +12 -11
- package/dist/frontend/type-mapper.js.map +1 -0
- package/dist/frontend/workspace-registry.d.ts +26 -0
- package/dist/frontend/workspace-registry.js +71 -0
- package/dist/frontend/workspace-registry.js.map +1 -0
- package/dist/index.d.ts +113 -31
- package/dist/index.js +536 -128
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +37 -0
- package/dist/ir/analysis.js +118 -0
- package/dist/ir/analysis.js.map +1 -0
- package/dist/ir/analysis.test.d.ts +1 -0
- package/dist/ir/analysis.test.js +21 -0
- package/dist/ir/analysis.test.js.map +1 -0
- package/dist/ir/build.d.ts +9 -0
- package/dist/ir/build.js +33 -0
- package/dist/ir/build.js.map +1 -0
- package/dist/ir/integer-loops.d.ts +1 -1
- package/dist/ir/{nodes.d.ts → ir.d.ts} +119 -37
- package/dist/ir/{nodes.js → ir.js} +170 -166
- package/dist/ir/ir.js.map +1 -0
- package/dist/ir/ir.test.d.ts +1 -0
- package/dist/ir/ir.test.js +17 -0
- package/dist/ir/ir.test.js.map +1 -0
- package/dist/ir/serialize.d.ts +2 -2
- package/dist/ir/serialize.js +3 -2
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.d.ts +1 -1
- package/dist/ir/validate.js +93 -41
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/cache-primitives.d.ts +24 -0
- package/dist/library/cache-primitives.js +83 -0
- package/dist/library/cache-primitives.js.map +1 -0
- package/dist/library/cache-reset.test.d.ts +1 -0
- package/dist/library/cache-reset.test.js +47 -0
- package/dist/library/cache-reset.test.js.map +1 -0
- package/dist/library/{implementation-identity.js → compiler-self-identity.js} +1 -1
- package/dist/library/compiler-self-identity.js.map +1 -0
- package/dist/library/fence-eval.d.ts +3 -1
- package/dist/library/fence-eval.js +8 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.d.ts +1 -36
- package/dist/library/int-infer.js +29 -18
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/{early-cache.d.ts → library-cache.d.ts} +1 -1
- package/dist/library/{early-cache.js → library-cache.js} +34 -89
- package/dist/library/library-cache.js.map +1 -0
- package/dist/library/library-cache.test.d.ts +1 -0
- package/dist/library/{early-cache.test.js → library-cache.test.js} +7 -7
- package/dist/library/library-cache.test.js.map +1 -0
- package/dist/library/{profile.d.ts → library-profile.d.ts} +4 -7
- package/dist/library/{profile.js → library-profile.js} +18 -11
- package/dist/library/library-profile.js.map +1 -0
- package/dist/library/semantic-source.js +2 -1
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/sidecar.d.ts +5 -2
- package/dist/library/sidecar.js +11 -5
- package/dist/library/sidecar.js.map +1 -1
- package/dist/startup-cache.d.ts +11 -3
- package/dist/startup-cache.js +17 -2
- package/dist/startup-cache.js.map +1 -1
- package/package.json +19 -2
- package/surface-manifest.json +5 -5
- package/dist/backend/cc-cache.test.js.map +0 -1
- package/dist/backend/cc.js.map +0 -1
- package/dist/backend/emission/emit-async.js.map +0 -1
- package/dist/backend/emission/emit-exprs.d.ts +0 -13
- package/dist/backend/emission/emit-exprs.js +0 -7407
- package/dist/backend/emission/emit-exprs.js.map +0 -1
- package/dist/backend/emission/emit-island.js.map +0 -1
- package/dist/backend/emission/emit-shapes.js.map +0 -1
- package/dist/backend/emission/emit-stmts.js.map +0 -1
- package/dist/backend/emission/emit-types.js.map +0 -1
- package/dist/backend/emission/emit-walkers.js.map +0 -1
- package/dist/backend/emission/emitter.js.map +0 -1
- package/dist/backend/emission/may-throw.js.map +0 -1
- package/dist/backend/library-identity.js.map +0 -1
- package/dist/executable/early-cache.js.map +0 -1
- package/dist/executable/early-cache.test.js.map +0 -1
- package/dist/ffi/profile.js.map +0 -1
- package/dist/frontend/lowering/lower-emitter.js.map +0 -1
- package/dist/frontend/shared.d.ts +0 -82
- package/dist/frontend/shared.js +0 -308
- package/dist/frontend/shared.js.map +0 -1
- package/dist/frontend/ts7/program.js.map +0 -1
- package/dist/frontend/types.js.map +0 -1
- package/dist/ir/nodes.js.map +0 -1
- package/dist/library/early-cache.js.map +0 -1
- package/dist/library/early-cache.test.js.map +0 -1
- package/dist/library/implementation-identity.js.map +0 -1
- package/dist/library/profile.js.map +0 -1
- /package/dist/backend/{cc-cache.test.d.ts → c/types.test.d.ts} +0 -0
- /package/dist/{executable/early-cache.test.d.ts → backend/llvm/shapes.test.d.ts} +0 -0
- /package/dist/{library/early-cache.test.d.ts → backend/native-codegen.test.d.ts} +0 -0
- /package/dist/ffi/{profile.d.ts → ffi-manifest.d.ts} +0 -0
- /package/dist/frontend/ts7/{program.d.ts → program-adapter.d.ts} +0 -0
- /package/dist/library/{implementation-identity.d.ts → compiler-self-identity.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,57 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InternalCompilerError } from "./errors.js";
|
|
2
|
+
import { mkdir, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
2
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
+
import { clearCcCaches, configuredTargetPlatform } from "./backend/native-toolchain.js";
|
|
6
|
+
import { buildCacheRoot, prepareBuildCacheRoot, pruneBuildCache } from "./backend/build-cache.js";
|
|
7
|
+
import { assertLegacyCExecutablePipelineEnabled, CcCompileError, compileExternalC, compileExternalCLibrary, executableNativeEnvironmentFingerprint, legacyCExecutablePathRequested, mobileLibraryTarget, mobileTargetRefusal, resolveCc, targetPlatform, } from "./backend/external-c.js";
|
|
8
|
+
import { emitCModule } from "./backend/c/c-emitter.js";
|
|
5
9
|
import { emitLlvmModule, LlvmUnsupportedError } from "./backend/llvm/emitter.js";
|
|
10
|
+
import { emitNativeArtifact, NativeCodegenError } from "./backend/native-codegen.js";
|
|
11
|
+
import { privateSiblingPath } from "./backend/build-cache.js";
|
|
12
|
+
import { nativeCodegenTarget, nativeCodegenTargetRefusal } from "./backend/targets.js";
|
|
13
|
+
import { createNativeLinkInfo } from "./backend/native-link-info.js";
|
|
14
|
+
import { RuntimePackError } from "./backend/runtime-pack.js";
|
|
15
|
+
import { createNativeLinkPlan } from "./backend/link-plan.js";
|
|
16
|
+
import { executableLinkerEnvironmentFingerprint, linkNativeExecutable, platformLinkerSupportsPersistentCache, resolvePlatformLinker, } from "./backend/linker.js";
|
|
6
17
|
import { splitLlvmLibraryProgram, splitLlvmProgram } from "./backend/llvm/split.js";
|
|
7
|
-
import { rebaseLibrarySourceComments, replaceLibraryIdentity, stripLibraryIdentity, stripLibrarySourceComments } from "./backend/library-identity.js";
|
|
8
|
-
import { checkerPanicDiag, ffiNativeBuildDiag, libAsyncExportDiag, libAsyncSurfaceDiag, libExportUnresolvedDiag, libGenericExportDiag, libIntBoundaryDiag, libNpmIneligibleDiag, libSidecarDiag, libUnmappableSignatureDiag, iceDiag, isCheckerPanic, LIB_INBOUND_BYTES_TRAP_CODE, LIB_RUNTIME_TRAP_CODES } from "./diagnostics/diagnostic.js";
|
|
18
|
+
import { rebaseLibrarySourceComments, replaceLibraryIdentity, stripLibraryIdentity, stripLibrarySourceComments } from "./backend/library-identity-markers.js";
|
|
19
|
+
import { checkerPanicDiag, ffiNativeBuildDiag, libAsyncExportDiag, libAsyncSurfaceDiag, libExportUnresolvedDiag, libGenericExportDiag, libIntBoundaryDiag, libNpmIneligibleDiag, libSidecarDiag, libUnmappableSignatureDiag, iceDiag, isCheckerPanic, LIB_INBOUND_BYTES_TRAP_CODE, LIB_RUNTIME_TRAP_CODES, nativeCodegenDiag } from "./diagnostics/diagnostic.js";
|
|
9
20
|
import { checkLibraryIntegerSlots, classSeed, hasIntSlots, numberCarrierKind } from "./library/int-infer.js";
|
|
10
|
-
import { loadLibraryProfile, profileRemediation, profileTeaching } from "./library/profile.js";
|
|
11
|
-
import { decorateLibraryRefusals, evaluateLibraryFences } from "./library/fence-eval.js";
|
|
21
|
+
import { loadLibraryProfile, profileRemediation, profileTeaching } from "./library/library-profile.js";
|
|
22
|
+
import { clearFenceEvalCaches, decorateLibraryRefusals, evaluateLibraryFences } from "./library/fence-eval.js";
|
|
12
23
|
import { assembleTrapTeaching } from "./library/trap-teaching.js";
|
|
13
|
-
import { buildSidecar, canonicalModuleGraph, canonicalPath, compilerReleaseVersion, libraryIdentityHashes, updateSidecarIdentity, } from "./library/sidecar.js";
|
|
24
|
+
import { buildSidecar, canonicalModuleGraph, canonicalPath, clearSidecarCaches, compilerReleaseVersion, libraryIdentityHashes, updateSidecarIdentity, } from "./library/sidecar.js";
|
|
14
25
|
import { validateSidecar } from "./library/sidecar-validate.js";
|
|
15
26
|
import { entryFunctionExports } from "./frontend/lib-exports.js";
|
|
16
27
|
import { entryContractFacts } from "./frontend/lib-contract.js";
|
|
17
|
-
import { moduleLibAsyncSurface, moduleLibNondeterministicSurface, moduleEmbedsBuiltin, moduleEmbedsCompressedNpm, moduleUsesAssert, moduleUsesCopying, moduleUsesDc, moduleUsesDgram, moduleUsesDynAsync, moduleUsesDynInvoke, moduleUsesEmitter, moduleUsesFetch, moduleUsesFileHandle, moduleUsesFsWatch, moduleUsesHttp2, moduleUsesHttpServer, moduleUsesInspect, moduleUsesLegacyTextDecoder, moduleUsesNet, moduleUsesNodeTest, moduleUsesParseArgs, moduleUsesProcessEvents, moduleUsesQs, moduleUsesRegex, moduleUsesSearchParams, moduleUsesStream, moduleUsesSymbol, moduleUsesTls, moduleUsesTlsCa, moduleUsesZlib } from "./ir/
|
|
28
|
+
import { moduleLibAsyncSurface, moduleLibNondeterministicSurface, moduleEmbedsBuiltin, moduleEmbedsCompressedNpm, moduleUsesAssert, moduleUsesCopying, moduleUsesDc, moduleUsesDgram, moduleUsesDynAsync, moduleUsesDynInvoke, moduleUsesEmitter, moduleUsesFetch, moduleUsesFileHandle, moduleUsesFsWatch, moduleUsesHttp2, moduleUsesHttpServer, moduleUsesInspect, moduleUsesLegacyTextDecoder, moduleUsesNet, moduleUsesNodeTest, moduleUsesParseArgs, moduleUsesProcessEvents, moduleUsesQs, moduleUsesRegex, moduleUsesSearchParams, moduleUsesStream, moduleUsesSymbol, moduleUsesTls, moduleUsesTlsCa, moduleUsesZlib } from "./ir/ir.js";
|
|
18
29
|
import { serializeModule } from "./ir/serialize.js";
|
|
19
30
|
import { validateModule } from "./ir/validate.js";
|
|
20
31
|
import { canonicalBuiltinModule, checkPreflight, isNodeTypesPath, loadProgram, locOf, requiresOf, resolveNpmImport } from "./frontend/program.js";
|
|
21
32
|
import { npmStaticIneligibleReason, npmStaticOffenders, npmStaticPackageOfPath } from "./frontend/npm-static.js";
|
|
22
33
|
import { provenanceSources } from "./frontend/provenance-registry.js";
|
|
23
34
|
import { clearResolveCaches, resolveBareModule } from "./frontend/resolve.js";
|
|
24
|
-
import { isJsSourceFileName
|
|
35
|
+
import { isJsSourceFileName } from "./frontend/tsc-codes.js";
|
|
36
|
+
import { isRelativeSpecifier, packageNameOfSpecifier } from "./frontend/workspace-registry.js";
|
|
25
37
|
import { lowerToIr } from "./frontend/lowering/lowerer.js";
|
|
26
|
-
import { loadFfiProfile } from "./ffi/
|
|
38
|
+
import { loadFfiProfile } from "./ffi/ffi-manifest.js";
|
|
27
39
|
import { hasForeignFfiCallback } from "./backend/ffi-callbacks.js";
|
|
28
40
|
import { FrontendInputTracker, trackedReadFile } from "./frontend/input-tracker.js";
|
|
29
|
-
import { libraryFrontendImplementationFingerprint, publishEarlyLibraryCache, readEarlyLibraryCache, readSemanticLibraryCache } from "./library/
|
|
41
|
+
import { libraryFrontendImplementationFingerprint, publishEarlyLibraryCache, readEarlyLibraryCache, readSemanticLibraryCache } from "./library/library-cache.js";
|
|
30
42
|
import { createSourceLineRebaser } from "./library/semantic-source.js";
|
|
31
|
-
import { publishEarlyExecutableCache, publishEarlyExecutableRoute, readEarlyExecutableCache } from "./executable/
|
|
32
|
-
import { compilerImplementationIdentity } from "./library/
|
|
43
|
+
import { publishEarlyExecutableCache, publishEarlyExecutableRoute, readEarlyExecutableCache } from "./executable/executable-cache.js";
|
|
44
|
+
import { compilerImplementationIdentity } from "./library/compiler-self-identity.js";
|
|
33
45
|
export const VERSION = "0.0.1";
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
46
|
+
export { EXTERNAL_OBJECT_ABI_STABILITY, RUNTIME_ABI_MARKER, RUNTIME_ABI_VERSION, } from "./backend/runtime-abi.js";
|
|
47
|
+
export { InternalCompilerError } from "./errors.js";
|
|
48
|
+
export { compileExternalC as compileC, compileExternalC, runtimeSrcDir, warmNativeCaches, } from "./backend/external-c.js";
|
|
49
|
+
export { ANDROID_MIN_API, IPHONEOS_MIN_VERSION, isAndroidTarget, isIosTarget, isMobileTarget, mobileLibraryTarget, mobileTargetRefusal } from "./backend/external-c.js";
|
|
50
|
+
export { emitCModule, emitCModule as emitModule, } from "./backend/c/c-emitter.js";
|
|
51
|
+
export { renderDiagnostics, renderDiagnostics as renderAll, renderDiagnostic, } from "./diagnostics/render.js";
|
|
38
52
|
export { renderCoverage } from "./coverage/report.js";
|
|
39
53
|
export { generateSurfaceManifest, renderSurfaceManifest, MANIFEST_SCHEMA_VERSION, } from "./coverage/surface-manifest.js";
|
|
40
54
|
export { NODE24_FETCH_COMPAT_PROFILE, } from "./compat/fetch-profile.js";
|
|
41
55
|
export { LIB_FN_SIGS, validateModule } from "./ir/validate.js";
|
|
56
|
+
export { deserializeModule, IR_VERSION, serializeModule } from "./ir/serialize.js";
|
|
42
57
|
export { resolveLibraryFences } from "./library/fence-eval.js";
|
|
43
|
-
export { loadLibraryProfile, profileTeaching, profileRemediation, LIB_PARAM_CLASSES, LIB_RETURN_CLASSES, } from "./library/profile.js";
|
|
44
|
-
export { loadFfiProfile, FFI_CALLBACK_PARAM_CLASSES, FFI_PARAM_CLASSES, FFI_RETURN_CLASSES, } from "./ffi/
|
|
58
|
+
export { loadLibraryProfile, profileTeaching, profileRemediation, LIB_PARAM_CLASSES, LIB_RETURN_CLASSES, } from "./library/library-profile.js";
|
|
59
|
+
export { loadFfiProfile, FFI_CALLBACK_PARAM_CLASSES, FFI_PARAM_CLASSES, FFI_RETURN_CLASSES, } from "./ffi/ffi-manifest.js";
|
|
45
60
|
export { assembleTrapTeaching, TRAP_TEACHING_MARKER, TRAP_TEACHING_SEP, } from "./library/trap-teaching.js";
|
|
46
61
|
export { abiExportSuffixes, buildSidecar, canonicalModuleGraph, canonicalPath, compilerReleaseVersion, libraryIdentityHashes, SIDECAR_FORMAT, } from "./library/sidecar.js";
|
|
47
62
|
export { validateSidecar } from "./library/sidecar-validate.js";
|
|
48
63
|
export { BUILD_ID_SEED, SOURCE_HASH_SEED, hex16, lengthPrefixedStream, wyhash64 } from "./library/wyhash.js";
|
|
49
|
-
export { ISLAND_SURFACE } from "./frontend/lowering/surfaces.js";
|
|
64
|
+
export { ISLAND_SURFACE, STATIC_MATH_PROPS } from "./frontend/lowering/surfaces.js";
|
|
50
65
|
export { ambientDtsPath, isExactExternalTypeSpecifier, overridesDtsPath } from "./frontend/program.js";
|
|
51
66
|
export { resolveProvenanceSources } from "./frontend/provenance.js";
|
|
52
67
|
export { wasiGuestPath } from "./wasi-paths.js";
|
|
53
68
|
export { setProvenanceSources, } from "./frontend/provenance-registry.js";
|
|
54
|
-
export * as ir from "./ir/
|
|
69
|
+
export * as ir from "./ir/ir.js";
|
|
55
70
|
/** The LLVM backend's tier refusal as a diagnostic. SC3xxx = backend
|
|
56
71
|
* coverage (the program is fine — this backend doesn't compile it yet);
|
|
57
72
|
* the parenthesized kind tag is machine-readable for the differential
|
|
@@ -200,6 +215,12 @@ export function buildTargetPlatform(env = process.env) {
|
|
|
200
215
|
return process.platform;
|
|
201
216
|
}
|
|
202
217
|
}
|
|
218
|
+
/** Target-platform classification without compiler or SDK discovery. Source
|
|
219
|
+
* artifacts need target semantics for lowering, but do not need a native
|
|
220
|
+
* toolchain merely to decide whether that target is Windows, WASI, etc. */
|
|
221
|
+
export function sourceTargetPlatform(env = process.env) {
|
|
222
|
+
return configuredTargetPlatform(env);
|
|
223
|
+
}
|
|
203
224
|
/** --npm-static=auto (and library mode's mandatory twin): one throwaway
|
|
204
225
|
* load finds every bare npm import the program's own modules make, then
|
|
205
226
|
* the eligibility heuristics (npm-static.ts) pick the packages whose
|
|
@@ -297,8 +318,7 @@ function packagesNamedByDiag(message, optedIn) {
|
|
|
297
318
|
const hits = new Set();
|
|
298
319
|
for (const m of message.matchAll(/Module '"([^"]+)"'/g)) {
|
|
299
320
|
const spec = m[1];
|
|
300
|
-
const
|
|
301
|
-
const prefix = spec.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
321
|
+
const prefix = packageNameOfSpecifier(spec);
|
|
302
322
|
if (optedIn.has(prefix))
|
|
303
323
|
hits.add(prefix);
|
|
304
324
|
}
|
|
@@ -309,13 +329,6 @@ function packagesNamedByDiag(message, optedIn) {
|
|
|
309
329
|
}
|
|
310
330
|
return hits;
|
|
311
331
|
}
|
|
312
|
-
/** The package-wide --npm-static name containing an exact bare specifier.
|
|
313
|
-
* External mappings are exact (subpaths included), while npm-static owns a
|
|
314
|
-
* whole package, so any mapped subpath conflicts with that package opt-in. */
|
|
315
|
-
function packageNameOfBareSpecifier(specifier) {
|
|
316
|
-
const parts = specifier.split("/");
|
|
317
|
-
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
318
|
-
}
|
|
319
332
|
/** The one frontend, three npm postures: `undefined`/explicit package
|
|
320
333
|
* lists and `"auto"` are the executable lane's (--npm-static; fallback =
|
|
321
334
|
* island). `"lib"` is library mode's mandatory auto twin — the same
|
|
@@ -370,7 +383,7 @@ function runFrontend(entryPath, npmStatic, externalTypes) {
|
|
|
370
383
|
if (requested.length > 0 && externalTypes !== undefined) {
|
|
371
384
|
const externalSpecifiersByPackage = new Map();
|
|
372
385
|
for (const specifier of Object.keys(externalTypes)) {
|
|
373
|
-
const pkg =
|
|
386
|
+
const pkg = packageNameOfSpecifier(specifier);
|
|
374
387
|
const specs = externalSpecifiersByPackage.get(pkg) ?? [];
|
|
375
388
|
specs.push(specifier);
|
|
376
389
|
externalSpecifiersByPackage.set(pkg, specs);
|
|
@@ -631,10 +644,35 @@ export function analyze(entryPath, opts = {}) {
|
|
|
631
644
|
}
|
|
632
645
|
}
|
|
633
646
|
/** The whole pipeline: load → preflight → lower → validate → emit C → clang. */
|
|
647
|
+
function clearCompileSessionCaches() {
|
|
648
|
+
clearResolveCaches();
|
|
649
|
+
clearCcCaches();
|
|
650
|
+
clearSidecarCaches();
|
|
651
|
+
clearFenceEvalCaches();
|
|
652
|
+
}
|
|
634
653
|
export async function compile(entryPath, opts) {
|
|
654
|
+
clearCompileSessionCaches();
|
|
635
655
|
const frontendInputs = new FrontendInputTracker();
|
|
636
656
|
return frontendInputs.run(() => compileTracked(entryPath, opts, frontendInputs));
|
|
637
657
|
}
|
|
658
|
+
/** Build-time API compatibility fence: a caller's existing CompileOptions
|
|
659
|
+
* variable must retain the executable result aliases without narrowing. */
|
|
660
|
+
async function assertCompileOptionsCompatibility(entryPath, opts) {
|
|
661
|
+
const result = await compile(entryPath, opts);
|
|
662
|
+
if (result.ok) {
|
|
663
|
+
const binaryPath = result.binaryPath;
|
|
664
|
+
void binaryPath;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
void assertCompileOptionsCompatibility;
|
|
668
|
+
/** The historical exported CompileResult itself remains executable-shaped. */
|
|
669
|
+
function assertCompileResultCompatibility(result) {
|
|
670
|
+
if (result.ok) {
|
|
671
|
+
const binaryPath = result.binaryPath;
|
|
672
|
+
void binaryPath;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
void assertCompileResultCompatibility;
|
|
638
676
|
function executableNativeFeatures(mod, backend, dynamic, optimization, llvmRefusal) {
|
|
639
677
|
return {
|
|
640
678
|
backend,
|
|
@@ -674,60 +712,156 @@ function executableNativeFeatures(mod, backend, dynamic, optimization, llvmRefus
|
|
|
674
712
|
tlsCa: moduleUsesTlsCa(mod),
|
|
675
713
|
};
|
|
676
714
|
}
|
|
677
|
-
async function compileExecutableNative(features, cPath, outPath, sanitize, ffi, programSplit = null, onArtifactReady) {
|
|
715
|
+
async function compileExecutableNative(features, cPath, outPath, sanitize, ffi, programSplit = null, programObjectDependencies = [], onArtifactReady) {
|
|
716
|
+
const programIsObject = /\.(?:o|obj)$/.test(cPath);
|
|
717
|
+
const runtimePackTarget = programIsObject && !sanitize && process.env["SCRIPTC_RUNTIME_PACK"] !== "0"
|
|
718
|
+
? nativeCodegenTarget()
|
|
719
|
+
: null;
|
|
720
|
+
if (runtimePackTarget !== null) {
|
|
721
|
+
const plan = await createNativeLinkPlan({
|
|
722
|
+
target: runtimePackTarget,
|
|
723
|
+
programObject: cPath,
|
|
724
|
+
outPath,
|
|
725
|
+
features,
|
|
726
|
+
ffi,
|
|
727
|
+
optimization: features.optimization ?? "release",
|
|
728
|
+
programObjectDependencies,
|
|
729
|
+
});
|
|
730
|
+
const cacheableLinker = onArtifactReady !== undefined && ffi === null && platformLinkerSupportsPersistentCache(process.env, runtimePackTarget);
|
|
731
|
+
await linkNativeExecutable(plan, {
|
|
732
|
+
// A caller-selected linker can be a mutable wrapper with hidden inputs,
|
|
733
|
+
// and a PATH-selected `clang` can be one too. FFI profiles and mutable
|
|
734
|
+
// linker search environments likewise name transitive files that the
|
|
735
|
+
// top-level dependency snapshot cannot prove. Only a direct driver in a
|
|
736
|
+
// stable link environment may publish a reusable final executable.
|
|
737
|
+
...(cacheableLinker ? { onArtifactReady } : {}),
|
|
738
|
+
});
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
678
741
|
const effectiveProgramSplit = programSplit ??
|
|
679
|
-
(features.optimization === "dev" && features.backend === "llvm" && !sanitize
|
|
742
|
+
(!programIsObject && features.optimization === "dev" && features.backend === "llvm" && !sanitize
|
|
680
743
|
? splitLlvmProgram(await readFile(cPath, "utf8"))
|
|
681
744
|
: null);
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
:
|
|
727
|
-
|
|
745
|
+
const objectLinkDir = programIsObject
|
|
746
|
+
? await mkdtemp(join(tmpdir(), "scriptc-object-link-"))
|
|
747
|
+
: null;
|
|
748
|
+
const linkDriverSource = objectLinkDir === null
|
|
749
|
+
? cPath
|
|
750
|
+
: join(objectLinkDir, "driver.c");
|
|
751
|
+
if (objectLinkDir !== null)
|
|
752
|
+
await writeFile(linkDriverSource, "/* scriptc object link driver */\n");
|
|
753
|
+
try {
|
|
754
|
+
assertLegacyCExecutablePipelineEnabled();
|
|
755
|
+
await compileExternalC({
|
|
756
|
+
cPath: linkDriverSource,
|
|
757
|
+
outPath,
|
|
758
|
+
cacheIdentity: "scriptc-generated-v1",
|
|
759
|
+
...(features.optimization === "dev" ? { optimization: "dev" } : {}),
|
|
760
|
+
...(effectiveProgramSplit === null
|
|
761
|
+
? {}
|
|
762
|
+
: {
|
|
763
|
+
programShards: effectiveProgramSplit.shards,
|
|
764
|
+
programPublicSymbols: effectiveProgramSplit.publicSymbols,
|
|
765
|
+
}),
|
|
766
|
+
sanitize,
|
|
767
|
+
dynamic: features.dynamic,
|
|
768
|
+
regex: features.regex,
|
|
769
|
+
copying: features.copying,
|
|
770
|
+
textDecoderLegacy: features.textDecoderLegacy,
|
|
771
|
+
fileHandle: features.fileHandle,
|
|
772
|
+
fetch: features.fetch,
|
|
773
|
+
netIsland: features.netIsland,
|
|
774
|
+
zlib: features.zlib,
|
|
775
|
+
assert: features.assert,
|
|
776
|
+
inspect: features.inspect,
|
|
777
|
+
dynInvoke: features.dynInvoke,
|
|
778
|
+
dc: features.dc,
|
|
779
|
+
dynAsync: features.dynAsync,
|
|
780
|
+
events: features.events,
|
|
781
|
+
emitter: features.emitter,
|
|
782
|
+
symbol: features.symbol,
|
|
783
|
+
searchParams: features.searchParams,
|
|
784
|
+
qs: features.qs,
|
|
785
|
+
parseArgs: features.parseArgs,
|
|
786
|
+
stream: features.stream,
|
|
787
|
+
net: features.net,
|
|
788
|
+
http: features.http,
|
|
789
|
+
http2: features.http2,
|
|
790
|
+
dgram: features.dgram,
|
|
791
|
+
watch: features.watch,
|
|
792
|
+
foreignFfi: features.foreignFfi,
|
|
793
|
+
nodeTest: features.nodeTest,
|
|
794
|
+
tls: features.tls,
|
|
795
|
+
tlsCa: features.tlsCa,
|
|
796
|
+
...(onArtifactReady === undefined ? {} : { onArtifactReady }),
|
|
797
|
+
...(ffi === null && !programIsObject
|
|
798
|
+
? {}
|
|
799
|
+
: {
|
|
800
|
+
linkInputs: [
|
|
801
|
+
...(programIsObject ? [cPath] : []),
|
|
802
|
+
...(ffi?.libraries ?? []),
|
|
803
|
+
],
|
|
804
|
+
...(ffi === null ? {} : { systemLibraries: ffi.systemLibraries }),
|
|
805
|
+
}),
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
finally {
|
|
809
|
+
if (objectLinkDir !== null) {
|
|
810
|
+
await rm(objectLinkDir, { recursive: true, force: true }).catch(() => undefined);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
async function emitNativeProgramObject(entryPath, opts, llvm) {
|
|
815
|
+
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
816
|
+
const artifactPath = join(opts.outDir, `${stem}.helper.o`);
|
|
817
|
+
// compileExecutableNative recognizes object inputs by suffix. The random
|
|
818
|
+
// private name isolates concurrent builds; retain .o so the driver links
|
|
819
|
+
// it rather than attempting to compile it as source.
|
|
820
|
+
const linkPath = `${privateSiblingPath(artifactPath, "native-program-object")}.o`;
|
|
821
|
+
try {
|
|
822
|
+
const artifact = await emitNativeArtifact({
|
|
823
|
+
outputPath: linkPath,
|
|
824
|
+
llvm,
|
|
825
|
+
outputKind: "obj",
|
|
826
|
+
sourcePath: entryPath,
|
|
827
|
+
optimization: opts.optimization === "dev" ? "0" : "2",
|
|
828
|
+
...(opts.sanitize === undefined ? {} : { sanitize: opts.sanitize }),
|
|
829
|
+
});
|
|
830
|
+
return { linkPath, artifactPath, dependencies: artifact.dependencies };
|
|
831
|
+
}
|
|
832
|
+
catch (error) {
|
|
833
|
+
await rm(linkPath, { force: true }).catch(() => undefined);
|
|
834
|
+
throw error;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
function usesPrecompiledRuntimePack(opts, backend) {
|
|
838
|
+
if (backend !== "llvm" || opts.sanitize === true ||
|
|
839
|
+
process.env["SCRIPTC_RUNTIME_PACK"] === "0" ||
|
|
840
|
+
process.env["SCRIPTC_FETCH_CURL"] === "1" || legacyCExecutablePathRequested())
|
|
841
|
+
return false;
|
|
842
|
+
return nativeCodegenTarget() !== null;
|
|
843
|
+
}
|
|
844
|
+
function runtimePackDiagnostic(error, entryPath) {
|
|
845
|
+
return nativeCodegenDiag(error.code === "unsupported" ? "SC3002" : "SC3003", error.message, entryPath);
|
|
728
846
|
}
|
|
729
847
|
async function compileTracked(entryPath, opts, frontendInputs) {
|
|
730
848
|
entryPath = resolve(entryPath);
|
|
849
|
+
const outputKind = opts.outputKind ?? "exe";
|
|
850
|
+
if (opts.nativeLinkInfo === true && outputKind !== "obj") {
|
|
851
|
+
return {
|
|
852
|
+
ok: false,
|
|
853
|
+
diagnostics: [nativeCodegenDiag("SC3002", "native link info is available only for object output", entryPath)],
|
|
854
|
+
sourceTexts: new Map(),
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
if (opts.nativeProgramObject === true &&
|
|
858
|
+
(outputKind !== "exe" || opts.backend !== "llvm")) {
|
|
859
|
+
return {
|
|
860
|
+
ok: false,
|
|
861
|
+
diagnostics: [nativeCodegenDiag("SC3002", "native program-object validation requires an executable build with backend explicitly set to llvm", entryPath)],
|
|
862
|
+
sourceTexts: new Map(),
|
|
863
|
+
};
|
|
864
|
+
}
|
|
731
865
|
let ffi = null;
|
|
732
866
|
let ffiProfileBytes = null;
|
|
733
867
|
if (opts.ffiProfilePath !== undefined) {
|
|
@@ -739,12 +873,64 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
739
873
|
ffi = loaded.profile;
|
|
740
874
|
ffiProfileBytes = loaded.profileBytes;
|
|
741
875
|
}
|
|
742
|
-
|
|
876
|
+
let buildPlatform;
|
|
877
|
+
if (outputKind === "exe") {
|
|
878
|
+
// Target semantics are needed before choosing the helper/runtime-pack
|
|
879
|
+
// path. Do not make them contingent on the legacy C-driver resolver:
|
|
880
|
+
// an LLVM-owned WASI build deliberately needs no SCRIPTC_CC.
|
|
881
|
+
try {
|
|
882
|
+
buildPlatform = sourceTargetPlatform();
|
|
883
|
+
}
|
|
884
|
+
catch (err) {
|
|
885
|
+
return {
|
|
886
|
+
ok: false,
|
|
887
|
+
diagnostics: [{
|
|
888
|
+
code: "SC3002",
|
|
889
|
+
message: err instanceof Error ? err.message : String(err),
|
|
890
|
+
loc: { file: entryPath, start: 0, end: 0 },
|
|
891
|
+
}],
|
|
892
|
+
sourceTexts: new Map(),
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
else {
|
|
897
|
+
try {
|
|
898
|
+
buildPlatform = sourceTargetPlatform();
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
return {
|
|
902
|
+
ok: false,
|
|
903
|
+
diagnostics: [{
|
|
904
|
+
code: "SC3002",
|
|
905
|
+
message: err instanceof Error ? err.message : String(err),
|
|
906
|
+
loc: { file: entryPath, start: 0, end: 0 },
|
|
907
|
+
}],
|
|
908
|
+
sourceTexts: new Map(),
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
if (outputKind === "asm" || outputKind === "obj") {
|
|
912
|
+
const refusal = nativeCodegenTargetRefusal();
|
|
913
|
+
if (refusal !== null) {
|
|
914
|
+
return {
|
|
915
|
+
ok: false,
|
|
916
|
+
diagnostics: [nativeCodegenDiag("SC3002", refusal, entryPath)],
|
|
917
|
+
sourceTexts: new Map(),
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
if (opts.sanitize === true) {
|
|
921
|
+
return {
|
|
922
|
+
ok: false,
|
|
923
|
+
diagnostics: [nativeCodegenDiag("SC3002", `--sanitize is not supported with --emit=${outputKind}; AddressSanitizer instrumentation parity is not available in the LLVM native helper yet`, entryPath)],
|
|
924
|
+
sourceTexts: new Map(),
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
743
929
|
// Mobile triples are library-mode targets: the archive an embedding app
|
|
744
930
|
// links is the artifact, and only the library-admissible runtime surface
|
|
745
931
|
// is verified on those device classes. The executable lane refuses before
|
|
746
932
|
// any frontend work — a pure env check, so the refusal needs no toolchain.
|
|
747
|
-
{
|
|
933
|
+
if (outputKind === "exe") {
|
|
748
934
|
const entryLoc = { file: entryPath, start: 0, end: 0 };
|
|
749
935
|
const mobileTarget = mobileLibraryTarget();
|
|
750
936
|
if (mobileTarget !== null) {
|
|
@@ -766,40 +952,72 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
766
952
|
};
|
|
767
953
|
}
|
|
768
954
|
}
|
|
769
|
-
const cacheRoot = provenanceSources() === null
|
|
955
|
+
const cacheRoot = outputKind === "exe" && provenanceSources() === null
|
|
770
956
|
? await prepareBuildCacheRoot(buildCacheRoot())
|
|
771
957
|
: null;
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
958
|
+
let earlyCacheOptions = null;
|
|
959
|
+
if (outputKind === "exe") {
|
|
960
|
+
const implementation = await compilerImplementationIdentity();
|
|
961
|
+
const helperObjectRoute = opts.nativeProgramObject === true ||
|
|
962
|
+
(opts.backend !== "c" && usesPrecompiledRuntimePack(opts, "llvm"));
|
|
963
|
+
earlyCacheOptions = {
|
|
964
|
+
entryPath,
|
|
965
|
+
outDir: opts.outDir,
|
|
966
|
+
outPath: opts.outPath,
|
|
967
|
+
emitIr: opts.emitIr ?? false,
|
|
968
|
+
sanitize: opts.sanitize ?? false,
|
|
969
|
+
dynamic: opts.dynamic ?? false,
|
|
970
|
+
backend: opts.backend ?? "auto",
|
|
971
|
+
...(opts.optimization === "dev" ? { optimization: "dev" } : {}),
|
|
972
|
+
npmStatic: opts.npmStatic ?? null,
|
|
973
|
+
ffiProfile: opts.ffiProfilePath === undefined || ffiProfileBytes === null
|
|
974
|
+
? null
|
|
975
|
+
: { path: opts.ffiProfilePath, bytes: ffiProfileBytes },
|
|
976
|
+
target: `${process.env["SCRIPTC_TARGET"] ?? "native"}:${buildPlatform}:${process.arch}:${opts.nativeProgramObject === true
|
|
977
|
+
? "helper-object"
|
|
978
|
+
: helperObjectRoute ? "runtime-pack" : "driver-tu"}`,
|
|
979
|
+
compiler: [
|
|
980
|
+
helperObjectRoute
|
|
981
|
+
? resolvePlatformLinker(process.env, nativeCodegenTarget()?.defaultLinker)
|
|
982
|
+
: (process.env["SCRIPTC_CC"] ?? "clang"),
|
|
983
|
+
],
|
|
984
|
+
nativeEnvironment: helperObjectRoute
|
|
985
|
+
? await executableLinkerEnvironmentFingerprint(process.env, nativeCodegenTarget()?.defaultLinker)
|
|
986
|
+
: await executableNativeEnvironmentFingerprint(),
|
|
987
|
+
nodeVersion: process.version,
|
|
988
|
+
implementation: implementation.digest,
|
|
989
|
+
implementationDependencies: implementation.dependencies,
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
const earlyHit = earlyCacheOptions === null
|
|
993
|
+
? null
|
|
994
|
+
: await readEarlyExecutableCache(cacheRoot, earlyCacheOptions);
|
|
794
995
|
if (earlyHit !== null) {
|
|
996
|
+
if (earlyCacheOptions === null) {
|
|
997
|
+
throw new InternalCompilerError("executable cache hit without executable cache options");
|
|
998
|
+
}
|
|
999
|
+
const executableCacheOptions = earlyCacheOptions;
|
|
1000
|
+
if (!opts.emitIr) {
|
|
1001
|
+
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
1002
|
+
await rm(join(opts.outDir, `${stem}.ir.json`), { force: true });
|
|
1003
|
+
}
|
|
795
1004
|
// Route/proof metadata is independently evictable. A full-compiler
|
|
796
1005
|
// fallback that still finds the validated payload repairs that lightweight
|
|
797
1006
|
// index so the next identical CLI invocation can avoid this module graph.
|
|
798
|
-
await publishEarlyExecutableRoute(cacheRoot,
|
|
1007
|
+
await publishEarlyExecutableRoute(cacheRoot, executableCacheOptions).catch(() => undefined);
|
|
799
1008
|
if (earlyHit.executableRestored) {
|
|
800
1009
|
await pruneBuildCache(cacheRoot);
|
|
801
1010
|
return {
|
|
802
1011
|
ok: true,
|
|
1012
|
+
artifact: {
|
|
1013
|
+
kind: "exe",
|
|
1014
|
+
path: opts.outPath,
|
|
1015
|
+
translationUnitPath: earlyHit.cPath,
|
|
1016
|
+
backend: earlyHit.native.backend,
|
|
1017
|
+
...(earlyHit.native.llvmRefusal === undefined
|
|
1018
|
+
? {}
|
|
1019
|
+
: { llvmRefusal: earlyHit.native.llvmRefusal }),
|
|
1020
|
+
},
|
|
803
1021
|
binaryPath: opts.outPath,
|
|
804
1022
|
cPath: earlyHit.cPath,
|
|
805
1023
|
backend: earlyHit.native.backend,
|
|
@@ -809,17 +1027,45 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
809
1027
|
: { llvmRefusal: earlyHit.native.llvmRefusal }),
|
|
810
1028
|
};
|
|
811
1029
|
}
|
|
1030
|
+
let nativeInputPath = earlyHit.cPath;
|
|
1031
|
+
let nativeProgramObject = null;
|
|
1032
|
+
const useRuntimePack = opts.nativeProgramObject === true ||
|
|
1033
|
+
usesPrecompiledRuntimePack(opts, earlyHit.native.backend);
|
|
1034
|
+
if (useRuntimePack) {
|
|
1035
|
+
if (earlyHit.native.backend !== "llvm") {
|
|
1036
|
+
throw new InternalCompilerError("native program-object cache hit restored a non-LLVM translation unit");
|
|
1037
|
+
}
|
|
1038
|
+
try {
|
|
1039
|
+
nativeProgramObject = await emitNativeProgramObject(entryPath, opts, await readFile(earlyHit.cPath, "utf8"));
|
|
1040
|
+
nativeInputPath = nativeProgramObject.linkPath;
|
|
1041
|
+
}
|
|
1042
|
+
catch (err) {
|
|
1043
|
+
if (!(err instanceof NativeCodegenError))
|
|
1044
|
+
throw err;
|
|
1045
|
+
return {
|
|
1046
|
+
ok: false,
|
|
1047
|
+
diagnostics: [nativeCodegenDiag(err.diagnosticCode, err.message, entryPath)],
|
|
1048
|
+
sourceTexts: new Map(),
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
812
1052
|
try {
|
|
813
|
-
await compileExecutableNative(earlyHit.native,
|
|
814
|
-
await publishEarlyExecutableCache(cacheRoot,
|
|
1053
|
+
await compileExecutableNative(earlyHit.native, nativeInputPath, opts.outPath, opts.sanitize ?? false, ffi, null, nativeProgramObject?.dependencies, opts.nativeProgramObject === true ? undefined : async ({ dependencies }) => {
|
|
1054
|
+
await publishEarlyExecutableCache(cacheRoot, executableCacheOptions, {
|
|
815
1055
|
...earlyHit,
|
|
816
1056
|
executableRestored: true,
|
|
817
1057
|
nativeDependencies: dependencies,
|
|
818
1058
|
frontend: earlyHit.frontend,
|
|
819
1059
|
});
|
|
820
1060
|
});
|
|
1061
|
+
if (nativeProgramObject !== null && opts.nativeProgramObject === true) {
|
|
1062
|
+
await rename(nativeProgramObject.linkPath, nativeProgramObject.artifactPath);
|
|
1063
|
+
}
|
|
821
1064
|
}
|
|
822
1065
|
catch (err) {
|
|
1066
|
+
if (err instanceof RuntimePackError) {
|
|
1067
|
+
return { ok: false, diagnostics: [runtimePackDiagnostic(err, entryPath)], sourceTexts: new Map() };
|
|
1068
|
+
}
|
|
823
1069
|
if (ffi !== null && err instanceof CcCompileError) {
|
|
824
1070
|
return {
|
|
825
1071
|
ok: false,
|
|
@@ -829,9 +1075,23 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
829
1075
|
}
|
|
830
1076
|
throw err;
|
|
831
1077
|
}
|
|
1078
|
+
finally {
|
|
1079
|
+
if (nativeProgramObject !== null) {
|
|
1080
|
+
await rm(nativeProgramObject.linkPath, { force: true }).catch(() => undefined);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
832
1083
|
await pruneBuildCache(cacheRoot);
|
|
833
1084
|
return {
|
|
834
1085
|
ok: true,
|
|
1086
|
+
artifact: {
|
|
1087
|
+
kind: "exe",
|
|
1088
|
+
path: opts.outPath,
|
|
1089
|
+
translationUnitPath: earlyHit.cPath,
|
|
1090
|
+
backend: earlyHit.native.backend,
|
|
1091
|
+
...(earlyHit.native.llvmRefusal === undefined
|
|
1092
|
+
? {}
|
|
1093
|
+
: { llvmRefusal: earlyHit.native.llvmRefusal }),
|
|
1094
|
+
},
|
|
835
1095
|
binaryPath: opts.outPath,
|
|
836
1096
|
cPath: earlyHit.cPath,
|
|
837
1097
|
backend: earlyHit.native.backend,
|
|
@@ -890,7 +1150,7 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
890
1150
|
if (unavailable !== null) {
|
|
891
1151
|
return fail([targetRefusalDiag("wasm32-wasi", unavailable.surface, unavailable.loc)]);
|
|
892
1152
|
}
|
|
893
|
-
if (opts.backend === "c") {
|
|
1153
|
+
if (opts.backend === "c" || outputKind === "c") {
|
|
894
1154
|
const asyncSurface = moduleLibAsyncSurface(lowered.module);
|
|
895
1155
|
if (asyncSurface !== null) {
|
|
896
1156
|
return fail([
|
|
@@ -905,14 +1165,114 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
905
1165
|
finally {
|
|
906
1166
|
fe.dispose();
|
|
907
1167
|
}
|
|
1168
|
+
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
1169
|
+
const defaultSourcePaths = {
|
|
1170
|
+
ir: join(opts.outDir, `${stem}.ir.json`),
|
|
1171
|
+
c: join(opts.outDir, `${stem}.c`),
|
|
1172
|
+
llvm: join(opts.outDir, `${stem}.ll`),
|
|
1173
|
+
asm: join(opts.outDir, `${stem}.s`),
|
|
1174
|
+
obj: join(opts.outDir, `${stem}.o`),
|
|
1175
|
+
};
|
|
1176
|
+
const defaultExecutablePaths = [
|
|
1177
|
+
join(opts.outDir, stem),
|
|
1178
|
+
join(opts.outDir, `${stem}.exe`),
|
|
1179
|
+
join(opts.outDir, `${stem}.wasm`),
|
|
1180
|
+
];
|
|
1181
|
+
const removeStaleSourceArtifacts = async (keep) => {
|
|
1182
|
+
const kept = new Set(keep.map((path) => resolve(path)));
|
|
1183
|
+
const candidates = outputKind === "exe"
|
|
1184
|
+
// Executable builds can generate only these compatibility/translation
|
|
1185
|
+
// unit siblings. Assembly and object outputs are independent primary
|
|
1186
|
+
// artifacts, so an executable build must never claim or delete them.
|
|
1187
|
+
? [defaultSourcePaths.ir, defaultSourcePaths.c, defaultSourcePaths.llvm]
|
|
1188
|
+
: opts.defaultOutputPath === true
|
|
1189
|
+
? [...Object.values(defaultSourcePaths), ...defaultExecutablePaths]
|
|
1190
|
+
: [];
|
|
1191
|
+
await Promise.all(candidates
|
|
1192
|
+
.filter((path) => !kept.has(resolve(path)))
|
|
1193
|
+
.map((path) => rm(path, { force: true })));
|
|
1194
|
+
};
|
|
1195
|
+
if (outputKind === "ir") {
|
|
1196
|
+
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1197
|
+
await writeFile(opts.outPath, serializeModule(lowered.module));
|
|
1198
|
+
await removeStaleSourceArtifacts([opts.outPath]);
|
|
1199
|
+
return { ok: true, artifact: { kind: "ir", path: opts.outPath } };
|
|
1200
|
+
}
|
|
1201
|
+
if (outputKind === "c") {
|
|
1202
|
+
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1203
|
+
await writeFile(opts.outPath, emitCModule(lowered.module, entryText));
|
|
1204
|
+
await removeStaleSourceArtifacts([opts.outPath]);
|
|
1205
|
+
return { ok: true, artifact: { kind: "c", path: opts.outPath } };
|
|
1206
|
+
}
|
|
1207
|
+
if (outputKind === "llvm" || outputKind === "asm" || outputKind === "obj") {
|
|
1208
|
+
let llvm;
|
|
1209
|
+
try {
|
|
1210
|
+
llvm = emitLlvmModule(lowered.module, {
|
|
1211
|
+
pointerBits: buildPlatform === "wasi" ? 32 : 64,
|
|
1212
|
+
wasi: buildPlatform === "wasi",
|
|
1213
|
+
runtimeAbiMarker: outputKind === "obj",
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
catch (err) {
|
|
1217
|
+
if (!(err instanceof LlvmUnsupportedError))
|
|
1218
|
+
throw err;
|
|
1219
|
+
return { ok: false, diagnostics: [llvmRefusalDiag(err, entryPath)], sourceTexts };
|
|
1220
|
+
}
|
|
1221
|
+
if (outputKind === "llvm") {
|
|
1222
|
+
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1223
|
+
await writeFile(opts.outPath, llvm);
|
|
1224
|
+
}
|
|
1225
|
+
else {
|
|
1226
|
+
try {
|
|
1227
|
+
await emitNativeArtifact({
|
|
1228
|
+
outputPath: opts.outPath,
|
|
1229
|
+
llvm,
|
|
1230
|
+
outputKind,
|
|
1231
|
+
sourcePath: entryPath,
|
|
1232
|
+
optimization: opts.optimization === "dev" ? "0" : "2",
|
|
1233
|
+
...(opts.sanitize === undefined ? {} : { sanitize: opts.sanitize }),
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
catch (err) {
|
|
1237
|
+
if (!(err instanceof NativeCodegenError))
|
|
1238
|
+
throw err;
|
|
1239
|
+
return {
|
|
1240
|
+
ok: false,
|
|
1241
|
+
diagnostics: [nativeCodegenDiag(err.diagnosticCode, err.message, entryPath)],
|
|
1242
|
+
sourceTexts,
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
await removeStaleSourceArtifacts([opts.outPath]);
|
|
1247
|
+
if (outputKind === "obj" && opts.nativeLinkInfo === true) {
|
|
1248
|
+
const target = nativeCodegenTarget();
|
|
1249
|
+
if (target === null) {
|
|
1250
|
+
throw new InternalCompilerError("native object emitted without a native target");
|
|
1251
|
+
}
|
|
1252
|
+
return {
|
|
1253
|
+
ok: true,
|
|
1254
|
+
artifact: {
|
|
1255
|
+
kind: "obj",
|
|
1256
|
+
path: opts.outPath,
|
|
1257
|
+
nativeLinkInfo: await createNativeLinkInfo({
|
|
1258
|
+
programObject: opts.outPath,
|
|
1259
|
+
target,
|
|
1260
|
+
features: executableNativeFeatures(lowered.module, "llvm", opts.dynamic ?? false, opts.optimization ?? "release"),
|
|
1261
|
+
ffi,
|
|
1262
|
+
optimization: opts.optimization ?? "release",
|
|
1263
|
+
}),
|
|
1264
|
+
},
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
return { ok: true, artifact: { kind: outputKind, path: opts.outPath } };
|
|
1268
|
+
}
|
|
908
1269
|
await mkdir(opts.outDir, { recursive: true });
|
|
909
|
-
const stem = basename(entryPath).replace(/\.(ts|js|mjs|cjs)$/, "");
|
|
910
1270
|
// Both backends hang off the same in-memory IrModule (never the JSON
|
|
911
1271
|
// dump); the LLVM backend's .ll takes the .c's seat on the exact clang
|
|
912
1272
|
// command line below — compileC accepts either. The default lane tries
|
|
913
1273
|
// LLVM first; a tier refusal retries ONLY the emit with the C backend
|
|
914
1274
|
// (the frontend ran once, the IR is backend-agnostic — nothing recompiles).
|
|
915
|
-
let cPath =
|
|
1275
|
+
let cPath = defaultSourcePaths.c;
|
|
916
1276
|
let backend = "c";
|
|
917
1277
|
let llvmSource = null;
|
|
918
1278
|
let llvmRefusal;
|
|
@@ -921,8 +1281,10 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
921
1281
|
const ll = emitLlvmModule(lowered.module, {
|
|
922
1282
|
pointerBits: buildPlatform === "wasi" ? 32 : 64,
|
|
923
1283
|
wasi: buildPlatform === "wasi",
|
|
1284
|
+
runtimeAbiMarker: opts.nativeProgramObject === true ||
|
|
1285
|
+
usesPrecompiledRuntimePack(opts, "llvm"),
|
|
924
1286
|
});
|
|
925
|
-
cPath =
|
|
1287
|
+
cPath = defaultSourcePaths.llvm;
|
|
926
1288
|
await writeFile(cPath, ll);
|
|
927
1289
|
llvmSource = ll;
|
|
928
1290
|
backend = "llvm";
|
|
@@ -939,28 +1301,55 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
939
1301
|
}
|
|
940
1302
|
}
|
|
941
1303
|
if (backend === "c") {
|
|
942
|
-
await writeFile(cPath,
|
|
1304
|
+
await writeFile(cPath, emitCModule(lowered.module, entryText));
|
|
943
1305
|
}
|
|
944
1306
|
// Kept-TU honesty: outDir persists across builds (the CLI's .scriptc/),
|
|
945
1307
|
// so a lane change would leave the PREVIOUS lane's TU beside the fresh
|
|
946
1308
|
// one — remove the loser so the surviving TU is always the one the
|
|
947
1309
|
// binary below was linked from.
|
|
948
|
-
await rm(join(opts.outDir, `${stem}${backend === "llvm" ? ".c" : ".ll"}`), { force: true });
|
|
949
1310
|
let irPath;
|
|
950
1311
|
if (opts.emitIr) {
|
|
951
|
-
irPath =
|
|
1312
|
+
irPath = defaultSourcePaths.ir;
|
|
952
1313
|
await writeFile(irPath, serializeModule(lowered.module));
|
|
953
1314
|
}
|
|
1315
|
+
await removeStaleSourceArtifacts([
|
|
1316
|
+
cPath,
|
|
1317
|
+
...(irPath === undefined ? [] : [irPath]),
|
|
1318
|
+
]);
|
|
954
1319
|
const nativeFeatures = executableNativeFeatures(lowered.module, backend, opts.dynamic ?? false, opts.optimization ?? "release", llvmRefusal);
|
|
955
1320
|
const programSplit = backend === "llvm" && (opts.optimization ?? "release") === "dev" &&
|
|
956
1321
|
!(opts.sanitize ?? false) && llvmSource !== null
|
|
957
1322
|
? splitLlvmProgram(llvmSource)
|
|
958
1323
|
: null;
|
|
959
1324
|
await mkdir(dirname(opts.outPath), { recursive: true });
|
|
1325
|
+
if (earlyCacheOptions === null) {
|
|
1326
|
+
throw new InternalCompilerError("executable emission without executable cache options");
|
|
1327
|
+
}
|
|
1328
|
+
const executableCacheOptions = earlyCacheOptions;
|
|
960
1329
|
let publishedExecutable = false;
|
|
1330
|
+
let nativeProgramObject = null;
|
|
961
1331
|
try {
|
|
962
|
-
|
|
963
|
-
|
|
1332
|
+
const useRuntimePack = opts.nativeProgramObject === true ||
|
|
1333
|
+
usesPrecompiledRuntimePack(opts, backend);
|
|
1334
|
+
if (useRuntimePack) {
|
|
1335
|
+
if (backend !== "llvm" || llvmSource === null) {
|
|
1336
|
+
throw new InternalCompilerError("native program-object validation requires the LLVM backend");
|
|
1337
|
+
}
|
|
1338
|
+
try {
|
|
1339
|
+
nativeProgramObject = await emitNativeProgramObject(entryPath, opts, llvmSource);
|
|
1340
|
+
}
|
|
1341
|
+
catch (err) {
|
|
1342
|
+
if (!(err instanceof NativeCodegenError))
|
|
1343
|
+
throw err;
|
|
1344
|
+
return {
|
|
1345
|
+
ok: false,
|
|
1346
|
+
diagnostics: [nativeCodegenDiag(err.diagnosticCode, err.message, entryPath)],
|
|
1347
|
+
sourceTexts,
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
await compileExecutableNative(nativeFeatures, nativeProgramObject?.linkPath ?? cPath, opts.outPath, opts.sanitize ?? false, ffi, programSplit, nativeProgramObject?.dependencies, opts.nativeProgramObject === true ? undefined : async ({ dependencies }) => {
|
|
1352
|
+
await publishEarlyExecutableCache(cacheRoot, executableCacheOptions, {
|
|
964
1353
|
cPath,
|
|
965
1354
|
native: nativeFeatures,
|
|
966
1355
|
executableRestored: true,
|
|
@@ -970,8 +1359,14 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
970
1359
|
});
|
|
971
1360
|
publishedExecutable = true;
|
|
972
1361
|
});
|
|
1362
|
+
if (nativeProgramObject !== null && opts.nativeProgramObject === true) {
|
|
1363
|
+
await rename(nativeProgramObject.linkPath, nativeProgramObject.artifactPath);
|
|
1364
|
+
}
|
|
973
1365
|
}
|
|
974
1366
|
catch (err) {
|
|
1367
|
+
if (err instanceof RuntimePackError) {
|
|
1368
|
+
return { ok: false, diagnostics: [runtimePackDiagnostic(err, entryPath)], sourceTexts };
|
|
1369
|
+
}
|
|
975
1370
|
if (ffi !== null && err instanceof CcCompileError) {
|
|
976
1371
|
return {
|
|
977
1372
|
ok: false,
|
|
@@ -983,8 +1378,13 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
983
1378
|
}
|
|
984
1379
|
throw err;
|
|
985
1380
|
}
|
|
1381
|
+
finally {
|
|
1382
|
+
if (nativeProgramObject !== null) {
|
|
1383
|
+
await rm(nativeProgramObject.linkPath, { force: true }).catch(() => undefined);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
986
1386
|
if (!publishedExecutable) {
|
|
987
|
-
await publishEarlyExecutableCache(cacheRoot,
|
|
1387
|
+
await publishEarlyExecutableCache(cacheRoot, executableCacheOptions, {
|
|
988
1388
|
cPath,
|
|
989
1389
|
native: nativeFeatures,
|
|
990
1390
|
executableRestored: false,
|
|
@@ -995,6 +1395,13 @@ async function compileTracked(entryPath, opts, frontendInputs) {
|
|
|
995
1395
|
await pruneBuildCache(cacheRoot);
|
|
996
1396
|
return {
|
|
997
1397
|
ok: true,
|
|
1398
|
+
artifact: {
|
|
1399
|
+
kind: "exe",
|
|
1400
|
+
path: opts.outPath,
|
|
1401
|
+
translationUnitPath: cPath,
|
|
1402
|
+
backend,
|
|
1403
|
+
...(llvmRefusal !== undefined ? { llvmRefusal } : {}),
|
|
1404
|
+
},
|
|
998
1405
|
binaryPath: opts.outPath,
|
|
999
1406
|
cPath,
|
|
1000
1407
|
backend,
|
|
@@ -1360,10 +1767,10 @@ async function compileLibraryNative(profile, cPath, archivePath, sanitize, featu
|
|
|
1360
1767
|
}
|
|
1361
1768
|
if (profile.sidecar !== null) {
|
|
1362
1769
|
if (features.buildId === undefined)
|
|
1363
|
-
throw new
|
|
1770
|
+
throw new InternalCompilerError("library identity TU has no build id");
|
|
1364
1771
|
const withoutIdentity = stripLibraryIdentity(programSource, profile.emission);
|
|
1365
1772
|
if (withoutIdentity === programSource) {
|
|
1366
|
-
throw new
|
|
1773
|
+
throw new InternalCompilerError("generated public library TU has no identity region");
|
|
1367
1774
|
}
|
|
1368
1775
|
programSource = withoutIdentity;
|
|
1369
1776
|
identityCSource = [
|
|
@@ -1380,7 +1787,7 @@ async function compileLibraryNative(profile, cPath, archivePath, sanitize, featu
|
|
|
1380
1787
|
const llvmSplit = profile.emission === "llvm" && profile.optimization === "dev" && !sanitize && programSource !== undefined
|
|
1381
1788
|
? splitLlvmLibraryProgram(programSource)
|
|
1382
1789
|
: null;
|
|
1383
|
-
await
|
|
1790
|
+
await compileExternalCLibrary({
|
|
1384
1791
|
cPath,
|
|
1385
1792
|
...(programSource !== undefined ? { programSource } : {}),
|
|
1386
1793
|
...(identityCSource !== undefined ? { identityCSource } : {}),
|
|
@@ -1413,7 +1820,7 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1413
1820
|
let sidecarJson = hit.sidecarJson;
|
|
1414
1821
|
if (profile.sidecar !== null) {
|
|
1415
1822
|
if (mod.lib?.identity === undefined || sidecarJson === null) {
|
|
1416
|
-
throw new
|
|
1823
|
+
throw new InternalCompilerError("semantic library cache lost sidecar identity metadata");
|
|
1417
1824
|
}
|
|
1418
1825
|
const modules = canonicalModuleGraph(rootDir, hit.sourceTexts);
|
|
1419
1826
|
const { buildId, sourceHash } = libraryIdentityHashes(compilerReleaseVersion(), profile.profileBytes, modules);
|
|
@@ -1430,7 +1837,7 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1430
1837
|
};
|
|
1431
1838
|
}
|
|
1432
1839
|
await mkdir(opts.outDir, { recursive: true });
|
|
1433
|
-
const stem = basename(profile.entry).replace(/\.(ts|js|mjs|cjs)$/, "");
|
|
1840
|
+
const stem = basename(profile.entry).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
1434
1841
|
const cPath = join(opts.outDir, `${stem}.lib.${profile.emission === "llvm" ? "ll" : "c"}`);
|
|
1435
1842
|
let translationUnit = hit.translationUnit;
|
|
1436
1843
|
if (profile.sidecar !== null) {
|
|
@@ -1443,7 +1850,7 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1443
1850
|
const previous = hit.previousSources.get(mod.sourceFile);
|
|
1444
1851
|
const current = hit.sourceTexts.get(mod.sourceFile);
|
|
1445
1852
|
if (previous === undefined || current === undefined) {
|
|
1446
|
-
throw new
|
|
1853
|
+
throw new InternalCompilerError("semantic library cache lost the entry source text");
|
|
1447
1854
|
}
|
|
1448
1855
|
translationUnit = rebaseLibrarySourceComments(translationUnit, mod.sourceFile, createSourceLineRebaser(mod.sourceFile, previous, current));
|
|
1449
1856
|
await writeFile(cPath, translationUnit);
|
|
@@ -1485,6 +1892,7 @@ async function emitSemanticLibraryHit(hit, profile, opts, archivePath, cacheRoot
|
|
|
1485
1892
|
};
|
|
1486
1893
|
}
|
|
1487
1894
|
export async function compileLibrary(opts) {
|
|
1895
|
+
clearCompileSessionCaches();
|
|
1488
1896
|
const frontendInputs = new FrontendInputTracker();
|
|
1489
1897
|
return frontendInputs.run(() => compileLibraryTracked(opts, frontendInputs));
|
|
1490
1898
|
}
|
|
@@ -1527,7 +1935,7 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1527
1935
|
if (directory === profileDir || dirname(directory) === directory)
|
|
1528
1936
|
break;
|
|
1529
1937
|
}
|
|
1530
|
-
const archivePath = opts.outPath ?? join(opts.outDir, `${basename(entryPath).replace(/\.(ts|js|mjs|cjs)$/, "")}.lib.a`);
|
|
1938
|
+
const archivePath = opts.outPath ?? join(opts.outDir, `${basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "")}.lib.a`);
|
|
1531
1939
|
// Mobile-target admission first — a pure env/host check, so a refused
|
|
1532
1940
|
// pairing never reaches toolchain discovery. iOS targets (device and
|
|
1533
1941
|
// simulator) build on darwin hosts only: the Apple SDK sysroot and the
|
|
@@ -1547,7 +1955,7 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1547
1955
|
// Multi-instance library mode (abi.localize_runtime) localizes per
|
|
1548
1956
|
// OBJECT FORMAT: ELF and COFF archives localize from any host (cross
|
|
1549
1957
|
// ELF merges through the cross driver's own lld; COFF merges and
|
|
1550
|
-
// demotes in process — see
|
|
1958
|
+
// demotes in process — see native-toolchain.ts's localizeLibraryObjects), and Mach-O
|
|
1551
1959
|
// localization runs the macOS host linker, so macos and ios targets
|
|
1552
1960
|
// admit darwin hosts only (the mobile admission above already refused
|
|
1553
1961
|
// an ios triple off darwin). Everything else refuses before frontend/
|
|
@@ -1844,7 +2252,7 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1844
2252
|
return fail(validation.map((v) => iceDiag(v.message, v.loc)));
|
|
1845
2253
|
timing("ir-validate");
|
|
1846
2254
|
await mkdir(opts.outDir, { recursive: true });
|
|
1847
|
-
const stem = basename(entryPath).replace(/\.(ts|js|mjs|cjs)$/, "");
|
|
2255
|
+
const stem = basename(entryPath).replace(/\.(ts|mts|cts|js|mjs|cjs)$/, "");
|
|
1848
2256
|
let cPath;
|
|
1849
2257
|
if (profile.emission === "llvm") {
|
|
1850
2258
|
try {
|
|
@@ -1863,7 +2271,7 @@ async function compileLibraryTracked(opts, frontendInputs) {
|
|
|
1863
2271
|
}
|
|
1864
2272
|
else {
|
|
1865
2273
|
cPath = join(opts.outDir, `${stem}.lib.c`);
|
|
1866
|
-
await writeFile(cPath,
|
|
2274
|
+
await writeFile(cPath, emitCModule(mod, entryText));
|
|
1867
2275
|
}
|
|
1868
2276
|
await rm(join(opts.outDir, `${stem}.lib.${profile.emission === "llvm" ? "c" : "ll"}`), { force: true });
|
|
1869
2277
|
let irPath;
|