porffor 0.58.2 → 0.58.3

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.
@@ -1760,7 +1760,7 @@ const getNodeType = (scope, node) => {
1760
1760
  const out = typeof ret === 'number' ? [ number(ret, Valtype.i32) ] : ret;
1761
1761
  if (guess != null) out.guess = typeof guess === 'number' ? [ number(guess, Valtype.i32) ] : guess;
1762
1762
 
1763
- typeUsed(scope, knownType(scope, out));
1763
+ if (!node._doNotMarkTypeUsed) typeUsed(scope, knownType(scope, out));
1764
1764
  return out;
1765
1765
  };
1766
1766
 
@@ -2595,7 +2595,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2595
2595
  args = args.slice(0, paramCount - 1);
2596
2596
  args.push({
2597
2597
  type: 'ArrayExpression',
2598
- elements: restArgs
2598
+ elements: restArgs,
2599
+ _doNotMarkTypeUsed: true
2599
2600
  });
2600
2601
  }
2601
2602
  }
package/compiler/index.js CHANGED
@@ -253,11 +253,19 @@ export default (code, module = undefined) => {
253
253
  const compiler = (Prefs.compiler ?? process.env.CC ?? 'cc').split(' ');
254
254
  const cO = Prefs._cO ?? 'O3';
255
255
 
256
- const tmpfile = 'porffor_tmp.c';
257
- const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO ];
256
+ const args = [
257
+ ...compiler,
258
+ '-xc', '-', // use stdin as c source in
259
+ '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), // set path for output
258
260
 
259
- // todo: redo how default cc args work
260
- if (compiler.includes('clang')) args.push('-lm', '-flto=thin', '-march=native', '-ffast-math', '-fno-exceptions', '-fno-ident', '-fno-asynchronous-unwind-tables', '-ffunction-sections', '-fdata-sections');
261
+ // default cc args, always
262
+ '-lm', // link math.h
263
+ '-fno-exceptions', // disable exceptions
264
+ '-fno-ident', '-ffunction-sections', '-fdata-sections', // remove unneeded binary sections
265
+ '-' + cO
266
+ ];
267
+
268
+ if (Prefs.clangFast) args.push('-flto=thin', '-march=native', '-ffast-math', '-fno-asynchronous-unwind-tables');
261
269
 
262
270
  if (Prefs.s) args.push('-s');
263
271
 
@@ -269,12 +277,12 @@ export default (code, module = undefined) => {
269
277
  if (logProgress) progressStart(`compiling C to native (using ${compiler})...`);
270
278
  const t5 = performance.now();
271
279
 
272
- fs.writeFileSync(tmpfile, c);
273
-
274
280
  // obvious command escape is obvious
275
- execSync(args.join(' '), { stdio: 'inherit' });
276
-
277
- fs.unlinkSync(tmpfile);
281
+ execSync(args.join(' '), {
282
+ stdio: [ 'pipe', 'inherit', 'inherit' ],
283
+ input: c,
284
+ encoding: 'utf8'
285
+ });
278
286
 
279
287
  if (logProgress) progressStart(`compiled C to native (using ${compiler})`, t5);
280
288
 
package/jsr.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honk/porffor",
3
- "version": "0.58.2",
3
+ "version": "0.58.3",
4
4
  "exports": "./compiler/wrap.js",
5
5
  "publish": {
6
6
  "exclude": [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "An ahead-of-time JavaScript compiler",
4
- "version": "0.58.2",
4
+ "version": "0.58.3",
5
5
  "author": "Oliver Medhurst <honk@goose.icu>",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runtime/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.58.2';
3
+ globalThis.version = '0.58.3';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {