@scriptc/compiler 0.0.31 → 0.0.32
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 +1 -1
- package/dist/backend/cc.d.ts +11 -5
- package/dist/backend/cc.js +38 -7
- package/dist/backend/cc.js.map +1 -1
- package/dist/library/int-infer.js +7 -1
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +69 -0
- package/dist/library/int-infer.test.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1 -1
|
@@ -2378,7 +2378,7 @@ declare module "tls" {
|
|
|
2378
2378
|
/** The CA-store introspection surface (scr_tls_ca.c): per-type cached
|
|
2379
2379
|
* PEM string arrays. The host bundle stands in for Node's compiled-in
|
|
2380
2380
|
* Mozilla roots ('bundled', and rootCertificates) AND the platform
|
|
2381
|
-
* store ('system') — the
|
|
2381
|
+
* store ('system') — the Windows certificate stores or POSIX bundle probe;
|
|
2382
2382
|
* 'extra' reads NODE_EXTRA_CA_CERTS. An unknown type string throws
|
|
2383
2383
|
* Node's ERR_INVALID_ARG_VALUE TypeError. */
|
|
2384
2384
|
export function getCACertificates(type?: string): string[];
|
package/dist/backend/cc.d.ts
CHANGED
|
@@ -186,11 +186,11 @@ export interface CcOptions {
|
|
|
186
186
|
tls?: boolean;
|
|
187
187
|
/** The program uses the CA-store introspection surface (moduleUsesTlsCa
|
|
188
188
|
* on the IR — getCACertificates / rootCertificates /
|
|
189
|
-
* setDefaultCACertificates): compiles scr_tls_ca.c,
|
|
190
|
-
*
|
|
191
|
-
* binary never builds the archive.
|
|
192
|
-
* `tls` does — scr_tls.c consults its
|
|
193
|
-
*
|
|
189
|
+
* setDefaultCACertificates): compiles scr_tls_ca.c, PEM-block bookkeeping
|
|
190
|
+
* plus the platform certificate-store reader on Windows, with NO mbedTLS
|
|
191
|
+
* dependency, so an introspection-only binary never builds the archive.
|
|
192
|
+
* The unit also compiles whenever `tls` does — scr_tls.c consults its
|
|
193
|
+
* default-set override and shared Windows-certificate enumerator. */
|
|
194
194
|
tlsCa?: boolean;
|
|
195
195
|
}
|
|
196
196
|
/** Structured compiler-driver failure. Most callers still let this surface
|
|
@@ -202,6 +202,12 @@ export declare class CcCompileError extends Error {
|
|
|
202
202
|
readonly stderr: string;
|
|
203
203
|
constructor(driver: string, stderr: string, message: string);
|
|
204
204
|
}
|
|
205
|
+
/** Preserve the useful output from a failed compiler/tool invocation. Node's
|
|
206
|
+
* execFile error exposes stderr and stdout independently, but either stream
|
|
207
|
+
* may be present as an empty string. Prefer compiler diagnostics, retain a
|
|
208
|
+
* non-standard stdout diagnostic when that is all the tool emitted, and only
|
|
209
|
+
* then fall back to the process error itself. */
|
|
210
|
+
export declare function subprocessFailureDetail(err: unknown): string;
|
|
205
211
|
export declare function runtimeSrcDir(): string;
|
|
206
212
|
export interface CcDriver {
|
|
207
213
|
/** The compiler argv prefix: ["clang"] (default) or ["zig", "cc"]. */
|
package/dist/backend/cc.js
CHANGED
|
@@ -169,6 +169,30 @@ export class CcCompileError extends Error {
|
|
|
169
169
|
this.name = "CcCompileError";
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
/** Preserve the useful output from a failed compiler/tool invocation. Node's
|
|
173
|
+
* execFile error exposes stderr and stdout independently, but either stream
|
|
174
|
+
* may be present as an empty string. Prefer compiler diagnostics, retain a
|
|
175
|
+
* non-standard stdout diagnostic when that is all the tool emitted, and only
|
|
176
|
+
* then fall back to the process error itself. */
|
|
177
|
+
export function subprocessFailureDetail(err) {
|
|
178
|
+
const failure = err;
|
|
179
|
+
const output = (value) => {
|
|
180
|
+
const text = Buffer.isBuffer(value) ? value.toString("utf8") : value ?? "";
|
|
181
|
+
return text.trim().length > 0 ? text.trimEnd() : "";
|
|
182
|
+
};
|
|
183
|
+
const stderr = output(failure.stderr);
|
|
184
|
+
const stdout = output(failure.stdout);
|
|
185
|
+
if (stderr !== "" && stdout !== "")
|
|
186
|
+
return `${stderr}\n\ncompiler stdout:\n${stdout}`;
|
|
187
|
+
if (stderr !== "")
|
|
188
|
+
return stderr;
|
|
189
|
+
if (stdout !== "")
|
|
190
|
+
return `compiler stdout:\n${stdout}`;
|
|
191
|
+
if (typeof failure.message === "string" && failure.message.trim() !== "") {
|
|
192
|
+
return failure.message;
|
|
193
|
+
}
|
|
194
|
+
return String(err);
|
|
195
|
+
}
|
|
172
196
|
export function runtimeSrcDir() {
|
|
173
197
|
const testRoot = process.env["SCRIPTC_TEST_RUNTIME_SRC_DIR"];
|
|
174
198
|
if (testRoot !== undefined)
|
|
@@ -611,7 +635,7 @@ async function ensureEngineArchive(sanitize, driver, buildIdentity, cacheRoot =
|
|
|
611
635
|
"Install cmake (e.g. `brew install cmake`) and retry. Static builds do not need it.");
|
|
612
636
|
}
|
|
613
637
|
throw new Error(`cmake failed configuring the embedded engine (${vendor}).\n\n` +
|
|
614
|
-
|
|
638
|
+
subprocessFailureDetail(err));
|
|
615
639
|
}
|
|
616
640
|
await execFileAsync("cmake", [
|
|
617
641
|
"--build", buildDir,
|
|
@@ -1161,7 +1185,7 @@ export async function compileLibArchive(opts) {
|
|
|
1161
1185
|
await execFileAsync(driver.argv[0] ?? "clang", args);
|
|
1162
1186
|
}
|
|
1163
1187
|
catch (err) {
|
|
1164
|
-
const stderr =
|
|
1188
|
+
const stderr = subprocessFailureDetail(err);
|
|
1165
1189
|
throw new Error(`${driver.argv.join(" ")} failed compiling ${src} for the library archive.\n` +
|
|
1166
1190
|
`This is a scriptc bug (generated/runtime C should always compile) unless the compiler itself is missing/broken.\n\n${stderr}`);
|
|
1167
1191
|
}
|
|
@@ -1343,7 +1367,7 @@ async function localizeLibraryObjects(driver, arArgv, buildDir, programObject, s
|
|
|
1343
1367
|
await execFileAsync(argv[0], [...argv.slice(1)]);
|
|
1344
1368
|
}
|
|
1345
1369
|
catch (err) {
|
|
1346
|
-
const stderr =
|
|
1370
|
+
const stderr = subprocessFailureDetail(err);
|
|
1347
1371
|
throw new Error(`${argv[0]} failed while localizing the library archive's runtime symbols (abi.localize_runtime).\n` +
|
|
1348
1372
|
`Runtime symbol localization needs the ${platform === "darwin" ? "host toolchain's ld" : driver.target === null ? "host toolchain's ld and objcopy" : "cross driver's relocatable link"} beside the C compiler.\n\n${stderr}`);
|
|
1349
1373
|
}
|
|
@@ -2562,6 +2586,7 @@ export async function compileC(opts) {
|
|
|
2562
2586
|
const net = (opts.net ?? false) || nativeFetch || netIsland;
|
|
2563
2587
|
const http = (opts.http ?? false) || nativeFetch || netIsland;
|
|
2564
2588
|
const tls = (opts.tls ?? false) || nativeFetch || netIsland;
|
|
2589
|
+
const tlsCa = (opts.tlsCa ?? false) || tls;
|
|
2565
2590
|
const driver = resolveCc();
|
|
2566
2591
|
// Mobile triples produce library archives, never standalone executables:
|
|
2567
2592
|
// the executable-lane runtime (event loop, sockets, child processes) is
|
|
@@ -2795,19 +2820,23 @@ export async function compileC(opts) {
|
|
|
2795
2820
|
...(opts.nodeTest ? [rt(join(rtDir, "scr_test.c"))] : []),
|
|
2796
2821
|
// The CA-store unit rides its own gate OR the tls one: scr_tls.c
|
|
2797
2822
|
// references its default-set override unconditionally.
|
|
2798
|
-
...(
|
|
2823
|
+
...(tlsCa ? [rt(join(rtDir, "scr_tls_ca.c"))] : []),
|
|
2799
2824
|
...(tlsArchive
|
|
2800
2825
|
? [
|
|
2801
2826
|
"-I", join(vendorTlsDir(), "include"),
|
|
2802
2827
|
rt(join(rtDir, "scr_tls.c")),
|
|
2803
2828
|
tlsArchive,
|
|
2804
|
-
// mbedTLS's win32 entropy poll is BCryptGenRandom (bcrypt.h)
|
|
2805
|
-
//
|
|
2829
|
+
// mbedTLS's win32 entropy poll is BCryptGenRandom (bcrypt.h).
|
|
2830
|
+
// The unconditional win32 libs above do not carry it.
|
|
2806
2831
|
// Never present on the default path, so the historical TLS
|
|
2807
2832
|
// link line cannot change.
|
|
2808
2833
|
...(targetPlatform(driver) === "win32" ? ["-lbcrypt"] : []),
|
|
2809
2834
|
]
|
|
2810
2835
|
: []),
|
|
2836
|
+
// scr_tls_ca.c enumerates and PEM-encodes Windows system-store entries.
|
|
2837
|
+
// This is independent of the mbedTLS archive: getCACertificates-only
|
|
2838
|
+
// programs need crypt32 too, while TLS programs imply the CA unit.
|
|
2839
|
+
...(tlsCa && targetPlatform(driver) === "win32" ? ["-lcrypt32"] : []),
|
|
2811
2840
|
// Static fetch is the engine-free half of scr_fetch.c. Dynamic builds
|
|
2812
2841
|
// compile the same source beside scr_island.c below, where its
|
|
2813
2842
|
// SCR_DYNAMIC half installs the full web surface.
|
|
@@ -2917,7 +2946,7 @@ export async function compileC(opts) {
|
|
|
2917
2946
|
await execFileAsync(driver.argv[0] ?? "clang", [...driver.argv.slice(1), ...args]);
|
|
2918
2947
|
}
|
|
2919
2948
|
catch (err) {
|
|
2920
|
-
const stderr =
|
|
2949
|
+
const stderr = subprocessFailureDetail(err);
|
|
2921
2950
|
const guidance = (opts.linkInputs?.length ?? 0) > 0 ||
|
|
2922
2951
|
(opts.systemLibraries?.length ?? 0) > 0
|
|
2923
2952
|
? "This build includes native FFI link inputs. Check that every symbol and system library exists, " +
|
|
@@ -3000,6 +3029,7 @@ export async function compileC(opts) {
|
|
|
3000
3029
|
? ["-ladvapi32", "-liphlpapi", "-lws2_32"]
|
|
3001
3030
|
: []),
|
|
3002
3031
|
...(tls && targetPlatform(driver) === "win32" ? ["-lbcrypt"] : []),
|
|
3032
|
+
...(tlsCa && targetPlatform(driver) === "win32" ? ["-lcrypt32"] : []),
|
|
3003
3033
|
...(curlFetch && driver.target === null ? ["-lcurl"] : []),
|
|
3004
3034
|
...(dynamic && !driver.linkArgs.includes("-lm") ? ["-lm"] : []),
|
|
3005
3035
|
...(((opts.zlib ?? false) || nativeFetch) && driver.target === null ? ["-lz"] : []),
|
|
@@ -3014,6 +3044,7 @@ export async function compileC(opts) {
|
|
|
3014
3044
|
? ["-ladvapi32", "-liphlpapi", "-lws2_32"]
|
|
3015
3045
|
: []),
|
|
3016
3046
|
...(tls && targetPlatform(driver) === "win32" ? ["-lbcrypt"] : []),
|
|
3047
|
+
...(tlsCa && targetPlatform(driver) === "win32" ? ["-lcrypt32"] : []),
|
|
3017
3048
|
...(curlStubDir !== null ? [`-L${curlStubDir}`] : []),
|
|
3018
3049
|
...(curlFetch && driver.target === null ? ["-lcurl"] : []),
|
|
3019
3050
|
...(dynamic && !driver.linkArgs.includes("-lm") ? ["-lm"] : []),
|