Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to compile simple-ish JS file #212

Open
loudar opened this issue Dec 3, 2024 · 4 comments
Open

Error when trying to compile simple-ish JS file #212

loudar opened this issue Dec 3, 2024 · 4 comments

Comments

@loudar
Copy link

loudar commented Dec 3, 2024

was trying to compile this advent of code js for fun:

// d3/d3.1.ts
var script = "d3.1.ts";
var text = "xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))";
function run() {
  const start = performance.now();
  const matches = text.match(/(mul\(\d+,\d+\))/gm);
  let sum = 0;
  for (let i = 0;i < matches.length; i++) {
    const match = matches[i];
    const commaIndex = match.indexOf(",");
    sum += parseInt(match.substring(4, commaIndex)) * parseInt(match.substring(commaIndex + 1, match.length - 1));
  }
  const diff = performance.now() - start;
  return {
    result: sum,
    time: diff
  };
}
console.log(script.replace(".txt", "").split("\\").at(-1));
var { result, time } = run();
console.log(`Result: ${result}`);
console.log("Measuring...");
var sumTime = 0;
var runCount = 1e4;
for (let i = 0;i < runCount; i++) {
  const runTime = run().time;
  sumTime += runTime;
}
console.log((sumTime / runCount).toFixed(2) + "ms per run");

tried running porf native d3.1.js d3.1.exe --no-pgo, but got the following error:

      15ms  parsed                                
     157ms  generated wasm                        
      34ms  optimized                             
      33ms  assembled                             
     105ms  compiled Wasm to C                    
         /  compiling C to native (using clang)...clang: warning: argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same behavior, or '-O3' to enable only conforming optimizations [-Wdeprecated-ofast]
clang: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
C:\Users\ALEXAN~1\AppData\Local\Temp\porffor_tmp-149634.o : fatal error LNK1107: invalid or corrupt file: cannot read at 0xAA780
clang: error: linker command failed with exit code 1107 (use -v to see invocation)
Error: Command failed: clang porffor_tmp.c -o d3.1.exe -Ofast -flto=thin -march=native -s -ffast-math -fno-exceptions -fno-ident -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections

not a big deal, but maybe a fun example to debug on!

@loudar
Copy link
Author

loudar commented Dec 3, 2024

Seems to already fail with a file as simple as this:

var test = 1;
var test2 = test + 1;

@CanadaHonk
Copy link
Owner

Does clang work at all for you?

@loudar
Copy link
Author

loudar commented Dec 3, 2024

I freshly installed it with winget install LLVM and added the respective install path to my PATH. Haven't tested it with anything else. Any idea what would be good for figuring out if it works?

@CanadaHonk
Copy link
Owner

You should be able to look up and try a C hello world

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants