porffor 0.2.0-1afe9b8 → 0.2.0-2ada068
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/compiler/2c.js +316 -71
- package/compiler/builtins.js +26 -0
- package/compiler/codeGen.js +25 -11
- package/compiler/index.js +14 -3
- package/filesize.cmd +2 -0
- package/package.json +1 -1
- package/porf +2 -0
- package/runner/index.js +15 -2
- package/tmp.c +661 -0
- package/r.js +0 -4
package/compiler/index.js
CHANGED
@@ -68,11 +68,17 @@ export default (code, flags) => {
|
|
68
68
|
console.log([...pages.keys()].map(x => `\x1B[36m - ${x}\x1B[0m`).join('\n') + '\n');
|
69
69
|
}
|
70
70
|
|
71
|
-
const out = { wasm: sections, funcs, globals, tags, exceptions, pages };
|
71
|
+
const out = { wasm: sections, funcs, globals, tags, exceptions, pages, data };
|
72
72
|
|
73
73
|
const target = getArg('target') ?? getArg('t') ?? 'wasm';
|
74
74
|
const outFile = getArg('o');
|
75
75
|
|
76
|
+
if (target === 'wasm' && outFile) {
|
77
|
+
writeFileSync(outFile, Buffer.from(sections));
|
78
|
+
|
79
|
+
if (process.version) process.exit();
|
80
|
+
}
|
81
|
+
|
76
82
|
if (target === 'c') {
|
77
83
|
const c = toc(out);
|
78
84
|
out.c = c;
|
@@ -87,11 +93,16 @@ export default (code, flags) => {
|
|
87
93
|
}
|
88
94
|
|
89
95
|
if (target === 'native') {
|
90
|
-
|
96
|
+
let compiler = getArg('compiler') ?? 'clang';
|
91
97
|
const cO = getArg('cO') ?? 'Ofast';
|
92
98
|
|
99
|
+
if (compiler === 'zig') compiler = [ 'zig', 'cc' ];
|
100
|
+
else compiler = [ compiler ];
|
101
|
+
|
93
102
|
const tmpfile = 'tmp.c';
|
94
|
-
const args = [ compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO, '-march=native' ];
|
103
|
+
// const args = [ compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO, '-march=native', '-s', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-ffunction-sections', '-fdata-sections', '-Wl', '-fno-ident', '-fno-exceptions', '-ffast-math' ];
|
104
|
+
// const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO, '-march=native', '-s', '-ffast-math', '-fno-exceptions', '-target', 'x86_64-linux' ];
|
105
|
+
const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO, '-march=native', '-s', '-ffast-math', '-fno-exceptions' ];
|
95
106
|
|
96
107
|
const c = toc(out);
|
97
108
|
writeFileSync(tmpfile, c);
|
package/filesize.cmd
ADDED
package/package.json
CHANGED
package/porf
ADDED
package/runner/index.js
CHANGED
@@ -15,9 +15,22 @@ if (process.argv.includes('-compile-hints')) {
|
|
15
15
|
// --experimental-wasm-return-call (on by default)
|
16
16
|
}
|
17
17
|
|
18
|
-
|
18
|
+
let file = process.argv.slice(2).find(x => x[0] !== '-');
|
19
|
+
if (['run', 'wasm', 'native', 'c'].includes(file)) {
|
20
|
+
if (['wasm', 'native', 'c'].includes(file)) {
|
21
|
+
process.argv.push(`-target=${file}`);
|
22
|
+
}
|
23
|
+
|
24
|
+
file = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
|
25
|
+
|
26
|
+
const nonOptOutFile = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
|
27
|
+
if (nonOptOutFile) {
|
28
|
+
process.argv.push(`-o=${nonOptOutFile}`);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
19
32
|
if (!file) {
|
20
|
-
if (process.argv.includes('-v')) {
|
33
|
+
if (process.argv.includes('-v') || process.argv.includes('--version')) {
|
21
34
|
// just print version
|
22
35
|
console.log((await import('./version.js')).default);
|
23
36
|
process.exit(0);
|