@scriptc/compiler 0.0.25 → 0.0.27
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 +15 -7
- package/dist/backend/cc.d.ts +22 -0
- package/dist/backend/cc.js +128 -10
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-exprs.js +81 -10
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +14 -1
- package/dist/backend/emission/emitter.js +126 -13
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/emission/may-throw.js +11 -1
- package/dist/backend/emission/may-throw.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +11 -0
- package/dist/backend/ffi-callbacks.js +33 -0
- package/dist/backend/ffi-callbacks.js.map +1 -0
- package/dist/backend/llvm/classes.js +21 -21
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +7 -4
- package/dist/backend/llvm/dyn.js +145 -141
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +7 -1
- package/dist/backend/llvm/emitter.js +961 -303
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +4 -0
- package/dist/backend/llvm/shapes.js +26 -24
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/unsupported.js +1 -1
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -0
- package/dist/backend/llvm/walkers.js +50 -46
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.js +3 -2
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/ffi/profile.d.ts +20 -2
- package/dist/ffi/profile.js +130 -6
- package/dist/ffi/profile.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +58 -22
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +17 -7
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +5 -0
- package/dist/frontend/lowering/lower-server.js +129 -37
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +8 -1
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +3 -2
- package/dist/frontend/lowering/surfaces.js +4 -3
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm.d.ts +16 -0
- package/dist/frontend/npm.js +257 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +188 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +54 -13
- package/dist/ir/nodes.js +49 -7
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +10 -22
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/profile.d.ts +11 -0
- package/dist/library/profile.js +74 -2
- package/dist/library/profile.js.map +1 -1
- package/dist/wasi-paths.d.ts +5 -0
- package/dist/wasi-paths.js +22 -0
- package/dist/wasi-paths.js.map +1 -0
- package/package.json +2 -2
- package/surface-manifest.json +2 -2
|
@@ -2118,25 +2118,33 @@ declare module "node:net" {
|
|
|
2118
2118
|
* connection per call (no agent pooling) with Node's exact wire head. */
|
|
2119
2119
|
declare module "http" {
|
|
2120
2120
|
import { Server as NetServer, Socket } from "net";
|
|
2121
|
-
export
|
|
2121
|
+
export interface Server extends NetServer {
|
|
2122
|
+
timeout: number;
|
|
2123
|
+
keepAliveTimeout: number;
|
|
2124
|
+
keepAliveTimeoutBuffer: number;
|
|
2125
|
+
headersTimeout: number;
|
|
2126
|
+
requestTimeout: number;
|
|
2127
|
+
}
|
|
2122
2128
|
export type RequestListener =
|
|
2123
2129
|
(req: IncomingMessage, res: ServerResponse) => void;
|
|
2124
2130
|
/* The Server VALUE — Node's constructor works with and without `new`
|
|
2125
2131
|
* (test/parallel's http.Server(fn) spelling); both route to the
|
|
2126
2132
|
* createServer lowering. */
|
|
2127
2133
|
export const Server: {
|
|
2128
|
-
new (requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2129
|
-
new (options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2130
|
-
(requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2131
|
-
(options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2134
|
+
new (requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2135
|
+
new (options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2136
|
+
(requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2137
|
+
(options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2132
2138
|
};
|
|
2133
2139
|
/* The options-record stance (the RequestOptions precedent): every
|
|
2134
2140
|
* documented key typechecks; the lowering's option walk decides per
|
|
2135
|
-
* key — requireHostHeader: false
|
|
2141
|
+
* key — requireHostHeader: false, joinDuplicateHeaders, and
|
|
2142
|
+
* keepAliveTimeoutBuffer lower,
|
|
2136
2143
|
* documented-but-unlowered keys fence by name, unknown keys drop. */
|
|
2137
2144
|
export interface ServerOptions {
|
|
2138
2145
|
requireHostHeader?: boolean;
|
|
2139
2146
|
joinDuplicateHeaders?: boolean;
|
|
2147
|
+
keepAliveTimeoutBuffer?: number;
|
|
2140
2148
|
[option: string]: unknown;
|
|
2141
2149
|
}
|
|
2142
2150
|
/* The outgoing-header shape, @types/node's matrix: numbers format via
|
|
@@ -2392,7 +2400,7 @@ declare module "node:tls" {
|
|
|
2392
2400
|
* self-signed probe shape). With neither, /etc/ssl/cert.pem stands in
|
|
2393
2401
|
* for Node's bundled roots. */
|
|
2394
2402
|
declare module "https" {
|
|
2395
|
-
import { Server } from "
|
|
2403
|
+
import { Server } from "http";
|
|
2396
2404
|
import { Agent, ClientRequest, IncomingMessage, ServerResponse } from "http";
|
|
2397
2405
|
export { Agent, Server };
|
|
2398
2406
|
export interface ServerOptions {
|
package/dist/backend/cc.d.ts
CHANGED
|
@@ -214,6 +214,9 @@ export interface CcDriver {
|
|
|
214
214
|
linkArgs: string[];
|
|
215
215
|
}
|
|
216
216
|
export declare function resolveCc(env?: NodeJS.ProcessEnv, hostPlatform?: NodeJS.Platform): CcDriver;
|
|
217
|
+
/** Musl intentionally has no predefined libc macro. The explicit Zig target
|
|
218
|
+
* is therefore the source of truth for selecting its small runtime shim. */
|
|
219
|
+
export declare function isMuslTarget(driver: Pick<CcDriver, "target">): boolean;
|
|
217
220
|
/** The OS the produced binary runs on: the triple's OS under SCRIPTC_TARGET,
|
|
218
221
|
* the host's otherwise — so platform-conditional link flags follow the
|
|
219
222
|
* TARGET, not the machine running the compiler. Exported for compile()/
|
|
@@ -245,6 +248,25 @@ export interface LibArchiveOptions {
|
|
|
245
248
|
* matching compileC's arbitrary-input safety boundary. */
|
|
246
249
|
cacheIdentity?: string;
|
|
247
250
|
sanitize?: boolean;
|
|
251
|
+
/** Multi-instance library mode (the profile's abi.localize_runtime): the
|
|
252
|
+
* external symbols to KEEP global — every other scriptc external
|
|
253
|
+
* definition in the archive (the runtime's internals, the program TU's
|
|
254
|
+
* mangled functions and globals, vendor objects) is demoted to a local
|
|
255
|
+
* symbol. Toolchain sanitizer ABI remains external as required,
|
|
256
|
+
* so N archives built under pairwise-distinct prefixes link into one
|
|
257
|
+
* process with no symbol collisions and no shared mutable runtime state.
|
|
258
|
+
* Undefined references (libc/libm, plus sanitizer ABI in instrumented
|
|
259
|
+
* builds) keep their global binding. Omitted = the classic archive,
|
|
260
|
+
* byte-for-byte. Host-native builds only. */
|
|
261
|
+
localizeSymbols?: readonly string[];
|
|
262
|
+
/** Thread-instanced state (the profile's abi.instance_per_thread): every
|
|
263
|
+
* TU of the archive compiles with -DSCR_THREAD_INSTANCES, moving the
|
|
264
|
+
* runtime units' mutable statics into thread-local storage (SCR_TL in
|
|
265
|
+
* scr_runtime.h) to match the program TU's thread-local globals — one
|
|
266
|
+
* complete instance per embedder thread. The define rides cflags, so
|
|
267
|
+
* every cache tier keys it automatically; omitted = the classic
|
|
268
|
+
* archive, byte-for-byte. */
|
|
269
|
+
threadInstances?: boolean;
|
|
248
270
|
/** IR-detected link gates (the compileC precedent, refusal-narrowed). */
|
|
249
271
|
regex?: boolean;
|
|
250
272
|
assert?: boolean;
|
package/dist/backend/cc.js
CHANGED
|
@@ -197,14 +197,34 @@ export function resolveCc(env = process.env, hostPlatform = process.platform) {
|
|
|
197
197
|
}
|
|
198
198
|
if (target === "")
|
|
199
199
|
return { argv: ["zig", "cc"], target: null, ...hostArgs };
|
|
200
|
+
if (target.includes("wasi") && target !== "wasm32-wasi") {
|
|
201
|
+
throw new Error(`unsupported WASI target '${target}' (supported: wasm32-wasi)`);
|
|
202
|
+
}
|
|
200
203
|
const linux = target.includes("linux");
|
|
204
|
+
const wasi = target.includes("wasi");
|
|
205
|
+
const musl = target.includes("linux-musl");
|
|
201
206
|
return {
|
|
202
207
|
argv: ["zig", "cc"],
|
|
203
208
|
target,
|
|
204
|
-
targetArgs: [
|
|
205
|
-
|
|
209
|
+
targetArgs: [
|
|
210
|
+
"-target",
|
|
211
|
+
target,
|
|
212
|
+
...(linux || wasi ? ["-D_GNU_SOURCE"] : []),
|
|
213
|
+
...(musl ? ["-DSCR_MUSL"] : []),
|
|
214
|
+
...(wasi ? ["-D_WASI_EMULATED_SIGNAL", "-D_WASI_EMULATED_PROCESS_CLOCKS"] : []),
|
|
215
|
+
],
|
|
216
|
+
linkArgs: linux
|
|
217
|
+
? ["-lm"]
|
|
218
|
+
: wasi
|
|
219
|
+
? ["-lwasi-emulated-signal", "-lwasi-emulated-process-clocks"]
|
|
220
|
+
: [],
|
|
206
221
|
};
|
|
207
222
|
}
|
|
223
|
+
/** Musl intentionally has no predefined libc macro. The explicit Zig target
|
|
224
|
+
* is therefore the source of truth for selecting its small runtime shim. */
|
|
225
|
+
export function isMuslTarget(driver) {
|
|
226
|
+
return driver.target?.includes("linux-musl") ?? false;
|
|
227
|
+
}
|
|
208
228
|
/** The OS the produced binary runs on: the triple's OS under SCRIPTC_TARGET,
|
|
209
229
|
* the host's otherwise — so platform-conditional link flags follow the
|
|
210
230
|
* TARGET, not the machine running the compiler. Exported for compile()/
|
|
@@ -214,6 +234,8 @@ export function resolveCc(env = process.env, hostPlatform = process.platform) {
|
|
|
214
234
|
export function targetPlatform(driver) {
|
|
215
235
|
if (driver.target === null)
|
|
216
236
|
return process.platform;
|
|
237
|
+
if (driver.target.includes("wasi"))
|
|
238
|
+
return "wasi";
|
|
217
239
|
if (driver.target.includes("linux"))
|
|
218
240
|
return "linux";
|
|
219
241
|
if (driver.target.includes("windows"))
|
|
@@ -715,6 +737,9 @@ export async function compileLibArchive(opts) {
|
|
|
715
737
|
// carries no -l flags. Never present off win32, so host archives
|
|
716
738
|
// cannot change by a byte.
|
|
717
739
|
...(targetPlatform(driver) === "win32" ? ["scr_win.c"] : []),
|
|
740
|
+
// Zig's musl sysroot does not provide arc4random_buf. Keep the fallback
|
|
741
|
+
// inside the archive so library embedders need no extra system library.
|
|
742
|
+
...(isMuslTarget(driver) ? ["scr_musl.c"] : []),
|
|
718
743
|
...(regex ? ["scr_regex.c"] : []),
|
|
719
744
|
...(opts.assert || regex || opts.symbol ? ["scr_assert.c"] : []),
|
|
720
745
|
...(opts.inspect ? ["scr_inspect.c"] : []),
|
|
@@ -732,6 +757,7 @@ export async function compileLibArchive(opts) {
|
|
|
732
757
|
"-fno-strict-aliasing", // the emitted object model type-puns — see compileC's buildArgs
|
|
733
758
|
"-Wno-deprecated-declarations",
|
|
734
759
|
"-DSCR_LIB",
|
|
760
|
+
...(opts.threadInstances ? ["-DSCR_THREAD_INSTANCES"] : []),
|
|
735
761
|
...(opts.textDecoderLegacy ? ["-DSCR_TEXT_DECODER_LEGACY"] : []),
|
|
736
762
|
"-I", rtDir,
|
|
737
763
|
...(regex ? ["-I", vendorEngineDir()] : []),
|
|
@@ -790,7 +816,12 @@ export async function compileLibArchive(opts) {
|
|
|
790
816
|
}
|
|
791
817
|
}
|
|
792
818
|
const vendorBuildIdentity = await currentVendorCacheBuildIdentity(driver, `${toolchainEnv}\0${implicitToolchain ?? "<uncached>"}`);
|
|
793
|
-
|
|
819
|
+
// Runtime-localized archives skip the completed-archive tier: their bytes
|
|
820
|
+
// additionally depend on the host's ld/objcopy identities, which the
|
|
821
|
+
// archive key does not fingerprint. The runtime-object tier still serves
|
|
822
|
+
// them (localization consumes the same per-flavor objects).
|
|
823
|
+
const cacheCompleteArchive = opts.localizeSymbols === undefined &&
|
|
824
|
+
root !== null && await archiverSupportsPersistentCache(arArgv, driver);
|
|
794
825
|
let cachedArchive = null;
|
|
795
826
|
let compilerVersion = "";
|
|
796
827
|
let archiverVersion = "";
|
|
@@ -943,17 +974,29 @@ export async function compileLibArchive(opts) {
|
|
|
943
974
|
}
|
|
944
975
|
}
|
|
945
976
|
const objects = [programObject, ...runtimeObjects, ...lreObjects, ...zlibObjects];
|
|
946
|
-
//
|
|
947
|
-
//
|
|
948
|
-
//
|
|
949
|
-
const
|
|
977
|
+
// Multi-instance library mode: the archive's one member becomes the
|
|
978
|
+
// combined, symbol-localized object (cached vendor/runtime objects
|
|
979
|
+
// are read-only inputs here — the combine step never mutates them).
|
|
980
|
+
const archiveMembers = opts.localizeSymbols === undefined
|
|
981
|
+
? objects
|
|
982
|
+
: [
|
|
983
|
+
await localizeLibraryObjects(driver, arArgv, buildDir, programObject, [...runtimeObjects, ...lreObjects, ...zlibObjects], opts.localizeSymbols, stem),
|
|
984
|
+
];
|
|
985
|
+
// A cacheable or runtime-localized build owns a private archive from
|
|
986
|
+
// `ar` through publication. Localized archives deliberately bypass the
|
|
987
|
+
// completed-artifact cache, but still need atomic installation so two
|
|
988
|
+
// invocations sharing a caller-visible output cannot race `rm`/`ar` on
|
|
989
|
+
// that path.
|
|
990
|
+
const archiveOutput = cachedArchive === null && opts.localizeSymbols === undefined
|
|
991
|
+
? opts.outPath
|
|
992
|
+
: join(buildDir, "artifact.lib.a");
|
|
950
993
|
await rm(archiveOutput, { force: true }); // `ar r` would append into a stale archive
|
|
951
994
|
await mkdir(dirname(archiveOutput), { recursive: true });
|
|
952
995
|
await execFileAsync(arArgv[0] ?? "ar", [
|
|
953
996
|
...arArgv.slice(1),
|
|
954
997
|
"rcs",
|
|
955
998
|
archiveOutput,
|
|
956
|
-
...
|
|
999
|
+
...archiveMembers,
|
|
957
1000
|
]);
|
|
958
1001
|
if (archiveOutput !== opts.outPath)
|
|
959
1002
|
await installArtifact(archiveOutput, opts.outPath);
|
|
@@ -1004,6 +1047,73 @@ export async function compileLibArchive(opts) {
|
|
|
1004
1047
|
if (root !== null)
|
|
1005
1048
|
await pruneCache(root).catch(() => undefined);
|
|
1006
1049
|
}
|
|
1050
|
+
/* Multi-instance library mode's localization step: combine the program
|
|
1051
|
+
* object with exactly the runtime/vendor members it reaches into ONE
|
|
1052
|
+
* relocatable object, then demote every scriptc external definition except
|
|
1053
|
+
* the profile-declared symbols to a local symbol. The internals are not
|
|
1054
|
+
* renamed apart — they stop being visible to the embedder's linker at all,
|
|
1055
|
+
* so a second archive built under a different prefix brings its own private
|
|
1056
|
+
* copy of the whole runtime (allocator, collector, arena, panic sink) into
|
|
1057
|
+
* the same process. Undefined references (libc/libm, plus sanitizer ABI in
|
|
1058
|
+
* instrumented builds) keep their global binding: the C library and
|
|
1059
|
+
* sanitizer are the embedder's, shared by design.
|
|
1060
|
+
*
|
|
1061
|
+
* Member selection matters: a classic archive's unused members (and their
|
|
1062
|
+
* undefined references to units library mode excludes, like the
|
|
1063
|
+
* fs-promises unit's fiber symbols) never reach an embedder's link. A
|
|
1064
|
+
* blind merge of every object would carry those references into the one
|
|
1065
|
+
* combined member. Staging the support objects into an intermediate
|
|
1066
|
+
* archive keeps the linker's own member semantics: `ld -r` pulls only the
|
|
1067
|
+
* members the program object transitively needs.
|
|
1068
|
+
*
|
|
1069
|
+
* darwin — one ld64 invocation: -r merges program + needed members,
|
|
1070
|
+
* -exported_symbols_list demotes every unlisted global to
|
|
1071
|
+
* private extern, and -r without -keep_private_externs writes
|
|
1072
|
+
* private externs out as non-external symbols. Apple ASan's
|
|
1073
|
+
* image-registration COMMON remains shared so the final Mach-O
|
|
1074
|
+
* image registers its globals once.
|
|
1075
|
+
* linux — ld -r merges with --force-group-allocation (ASan's
|
|
1076
|
+
* instrumented globals ride ELF section groups whose signatures
|
|
1077
|
+
* repeat across archives sharing runtime objects; resolving the
|
|
1078
|
+
* groups into the combined member keeps a later multi-archive
|
|
1079
|
+
* link from discarding one archive's copies), then binutils
|
|
1080
|
+
* objcopy --keep-global-symbols localizes every other DEFINED
|
|
1081
|
+
* global (objcopy leaves undefined symbols global by its own
|
|
1082
|
+
* rule).
|
|
1083
|
+
*
|
|
1084
|
+
* Host-native only: compileLibrary refuses localization for cross targets
|
|
1085
|
+
* before emission (this step runs the host's ld/objcopy over host-format
|
|
1086
|
+
* objects). */
|
|
1087
|
+
async function localizeLibraryObjects(driver, arArgv, buildDir, programObject, supportObjects, keepSymbols, stem) {
|
|
1088
|
+
const platform = targetPlatform(driver);
|
|
1089
|
+
const combined = join(buildDir, `${stem}.localized.o`);
|
|
1090
|
+
const staging = join(buildDir, `${stem}.localize-staging.a`);
|
|
1091
|
+
const keepFile = join(buildDir, "localize-keep.syms");
|
|
1092
|
+
const run = async (argv) => {
|
|
1093
|
+
try {
|
|
1094
|
+
await execFileAsync(argv[0], [...argv.slice(1)]);
|
|
1095
|
+
}
|
|
1096
|
+
catch (err) {
|
|
1097
|
+
const stderr = err.stderr ?? String(err);
|
|
1098
|
+
throw new Error(`${argv[0]} failed while localizing the library archive's runtime symbols (abi.localize_runtime).\n` +
|
|
1099
|
+
`Runtime symbol localization needs the host toolchain's ${platform === "darwin" ? "ld" : "ld and objcopy"} beside the C compiler.\n\n${stderr}`);
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
await run([arArgv[0] ?? "ar", ...arArgv.slice(1), "rcs", staging, ...supportObjects]);
|
|
1103
|
+
if (platform === "darwin") {
|
|
1104
|
+
await writeFile(keepFile, keepSymbols.map((s) => `_${s}\n`).join(""));
|
|
1105
|
+
await run(["ld", "-r", programObject, staging, "-o", combined, "-exported_symbols_list", keepFile]);
|
|
1106
|
+
}
|
|
1107
|
+
else if (platform === "linux") {
|
|
1108
|
+
await writeFile(keepFile, keepSymbols.map((s) => `${s}\n`).join(""));
|
|
1109
|
+
await run(["ld", "-r", "--force-group-allocation", programObject, staging, "-o", combined]);
|
|
1110
|
+
await run(["objcopy", `--keep-global-symbols=${keepFile}`, combined]);
|
|
1111
|
+
}
|
|
1112
|
+
else {
|
|
1113
|
+
throw new Error(`runtime symbol localization (abi.localize_runtime) supports darwin and linux host builds; this build targets ${platform}`);
|
|
1114
|
+
}
|
|
1115
|
+
return combined;
|
|
1116
|
+
}
|
|
1007
1117
|
/* -------------------------- persistent build cache ---------------------------
|
|
1008
1118
|
* Content-addressed caches that let repeat builds of unchanged programs skip
|
|
1009
1119
|
* payload code generation/linking — the test lanes' dominant cost. Executable
|
|
@@ -2167,9 +2277,14 @@ export async function compileC(opts) {
|
|
|
2167
2277
|
const http = (opts.http ?? false) || nativeFetch || netIsland;
|
|
2168
2278
|
const tls = (opts.tls ?? false) || nativeFetch || netIsland;
|
|
2169
2279
|
const driver = resolveCc();
|
|
2280
|
+
const runtimeSources = targetPlatform(driver) === "wasi"
|
|
2281
|
+
? RUNTIME_SOURCES.filter((source) => source !== "scr_child.c")
|
|
2282
|
+
: RUNTIME_SOURCES;
|
|
2170
2283
|
// scr_async.c submits callback-style filesystem work to a native worker.
|
|
2171
2284
|
// POSIX drivers need the thread compile/link mode; win32 uses CreateThread.
|
|
2172
|
-
const threadArgs = targetPlatform(driver) === "win32"
|
|
2285
|
+
const threadArgs = targetPlatform(driver) === "win32" || targetPlatform(driver) === "wasi"
|
|
2286
|
+
? []
|
|
2287
|
+
: ["-pthread"];
|
|
2173
2288
|
if (driver.target !== null) {
|
|
2174
2289
|
// See the resolveCc block: these inputs are built on and for the HOST
|
|
2175
2290
|
// (vendored archives, system libs). Regex, zlib, and the engine archive
|
|
@@ -2314,7 +2429,7 @@ export async function compileC(opts) {
|
|
|
2314
2429
|
"-fno-strict-aliasing",
|
|
2315
2430
|
"-Wno-deprecated-declarations", // ucontext fibers (scr_async.c)
|
|
2316
2431
|
"-I", rtDir,
|
|
2317
|
-
...
|
|
2432
|
+
...runtimeSources.map((f) => rt(join(rtDir, f))),
|
|
2318
2433
|
...(opts.copying ? [rt(join(rtDir, "scr_copying.c"))] : []),
|
|
2319
2434
|
...(opts.fileHandle ? [rt(join(rtDir, "scr_file_handle.c"))] : []),
|
|
2320
2435
|
// win32 targets compile the libc-shim TU (stpcpy, arc4random_buf,
|
|
@@ -2327,6 +2442,9 @@ export async function compileC(opts) {
|
|
|
2327
2442
|
...(targetPlatform(driver) === "win32"
|
|
2328
2443
|
? [rt(join(rtDir, "scr_win.c")), "-ladvapi32", "-liphlpapi", "-lws2_32"]
|
|
2329
2444
|
: []),
|
|
2445
|
+
// musl deliberately has no libc-identification predefine; resolveCc's
|
|
2446
|
+
// SCR_MUSL flag and this target-selected TU travel together.
|
|
2447
|
+
...(isMuslTarget(driver) ? [rt(join(rtDir, "scr_musl.c"))] : []),
|
|
2330
2448
|
...(regex
|
|
2331
2449
|
? ["-I", vendorEngineDir(), rt(join(rtDir, "scr_regex.c")), ...lreObjects]
|
|
2332
2450
|
: []),
|