ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.72k stars 2.53k forks source link

Linenoise not working on M1/Ventura #13985

Closed kimmolinna closed 1 year ago

kimmolinna commented 1 year ago

Zig Version

0.11.0-dev.829+68d2f68ed

Steps to Reproduce and Observed Behavior

  1. git clone --branch basic https://github.com/kimmolinna/duckdb-zig-build
  2. zig build -Drelease-fast
  3. ./zig-out/bin/duckdb
  4. select '
select 'libc++abi: terminating due to uncaught exception of type std::runtime_error: parser error : unterminated quoted string at or near "'"
zsh: abort      ./zig-out/bin/duckdb

Expected Behavior

Linenoise is working nicely if you compile with make so the problem is not M1/Ventura. zig build -Drelease-fast is also working on Linux/Ubuntu 22.04.1

kubkon commented 1 year ago

Does it work fine in debug?

kimmolinna commented 1 year ago

No. It's exactly the same thing if I use zig build.

kubkon commented 1 year ago

I have a sneaky suspicion that this due to a missing feature in the MachO linker to do with emitting compact unwind info. FWIW it's on my todo list. In the meantime, I'll play with this example a little more and see if I can reduce it further.

kimmolinna commented 1 year ago

I tested this also with make CC="zig cc" CXX="zig c++" after you merged #13991 and I will get the same error with that compiled application. For me this is really good thing. The error is consistent. :)

kubkon commented 1 year ago

I tested this also with make CC="zig cc" CXX="zig c++" after you merged #13991 and I will get the same error with that compiled application. For me this is really good thing. The error is consistent. :)

If my hunch is correct, it will take a little longer for me to provide a fix as I need to do some research and reverse engineering but it will be done!

kimmolinna commented 1 year ago

Timing is not a problem. I just comment a couple of lines and everything is working nicely but without color-coding and predictive code input.

kubkon commented 1 year ago

Timing is not a problem. I just comment a couple of lines and everything is working nicely but without color-coding and predictive code input.

Oh, would you mind posting which lines need to be commented out?

kimmolinna commented 1 year ago
shell.addCSourceFile( 
    "tools/shell/linenoise.cpp",&.{});
shell.defineCMacro("HAVE_LINENOISE", "1");
kubkon commented 1 year ago
shell.addCSourceFile( 
    "tools/shell/linenoise.cpp",&.{});
shell.defineCMacro("HAVE_LINENOISE", "1");

Nice, thank you so much! This will aid me in working out a fix for sure!

kimmolinna commented 1 year ago

I made a test. Working compilation:

D select 42:;
Error: Parser Error: syntax error at or near ":"
LINE 1: select 42:;

And a buggy one:

D select 42:;
libc++abi: terminating due to uncaught exception of type std::runtime_error: parser error : syntax error at or near ":"
zsh: abort      ./duckdb-zig-build/zig-out/bin/duckdb
kimmolinna commented 1 year ago

Thank you very much @kubkon. Excellent work.