Neat-Lang / neat

The Neat Language compiler. Early beta?
BSD 3-Clause "New" or "Revised" License
111 stars 9 forks source link

v0.2.2 build error #25

Closed ghost closed 1 year ago

ghost commented 1 year ago

I'm trying to build v0.2.2-gcc and get this error:

ule_FF9AE93DC6BF49A7.o src/runtime.o
+ cat
+ '[' 64 == 32 ']'
+ ./neat_bootstrap -j src/main.nt -O -o neat
# stageM addQuasiQuotingMacro
$ gcc -c -fpic -fno-strict-aliasing .obj/module_A533D8106D4B4F61.c -o .obj/A533D8106D4B4F61.o [&28241]
./build.sh: line 56: 28230 Segmentation fault      ./neat_bootstrap -j src/main.nt -O -o neat

Edit: I get the same error with the llvm version:

+ ./neat_bootstrap -j -macro-backend=c src/main.nt -I/an/duyum/include -L-L/an/duyum/lib -O -version=LLVMBackend -o neat
# stageM addQuasiQuotingMacro
$ gcc -c -fpic -fno-strict-aliasing .obj/module_D4A1D9B6ECA5412D.c -o .obj/D4A1D9B6ECA5412D.o [&1852]
./build.sh: line 54:  1843 Segmentation fault      ./neat_bootstrap -j -macro-backend=c src/main.nt ${LLVM_NTFLAGS} -O -version=LLVMBackend -o neat

My system is based on musl libc, a custom x64 linux distro.

FeepingCreature commented 1 year ago

Uh. Good question, I have no idea what's happening there offhand. The bootstrap compiler seems to be segfaulting. Any chance you could get a backtrace of that command? (./neat_bootstrap -j src/main.nt -O -o neat)

Also you can put triple backticks before and after your paste to get proper formatting.

ghost commented 1 year ago

here is the output:

Reading symbols from neat_bootstrap...
(gdb) run -j src/main.nt -O -o neat
Starting program: /ev/çizeylemcil/neat-v0.2.2-gcc/neat_bootstrap -j src/main.nt -O -o neat
[Detaching after vfork from child process 5808]
[New LWP 5809]
[New LWP 5810]
[New LWP 5811]
[New LWP 5812]
# stageM addQuasiQuotingMacro

Thread 4 "neat_bootstrap" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 5811]
0x000055555573ceef in compiler130_module_neat_parser_ParserImpl_verify_void_0_ ()
FeepingCreature commented 1 year ago

Idea! Can you check if this happens in alpine docker? If so, that'd be an easy way to get something I can actually reproduce.

edit: Alright. hm. That helps less than I'd hoped...

ghost commented 1 year ago

alpine 3.17 chroot gives same error:

+ cat
+ '[' 64 == 32 ']'
+ ./neat_bootstrap -j src/main.nt -O -o neat
./build.sh: line 56: 12832 Segmentation fault      ./neat_bootstrap -j src/main.nt -O -o neat
ghost commented 1 year ago

alpine gdb gives more info:

(gdb) run -j src/main.nt -O -o neat
Starting program: /neat-v0.2.2-gcc/neat_bootstrap -j src/main.nt -O -o neat
[Detaching after vfork from child process 21205]
[New LWP 21206]
[New LWP 21207]
[New LWP 21208]
[New LWP 21209]
# stageM addQuasiQuotingMacro
[Detaching after fork from child process 21210]
$ gcc -c -fpic -fno-strict-aliasing .obj/module_A533D8106D4B4F61.c -o .obj/A533D8106D4B4F61.o [&21210]

Thread 4 "neat_bootstrap" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 21208]
0x000055555587f020 in compiler130_module_neat_stuff_Resolver_resolve_either_void_compiler130_module_neat_base_class_Error_3_compiler130_module_neat_base_struct_Context_compiler130_module_neat_base_struct_LocRange_int ()
FeepingCreature commented 1 year ago

Well that's a completely different location for no reason...

Let me have a look.

ghost commented 1 year ago

well now it gives this info:

(gdb) run -j src/main.nt -O -o neat
Starting program: /neat-v0.2.2-gcc/neat_bootstrap -j src/main.nt -O -o neat
[Detaching after vfork from child process 23613]
[New LWP 23614]
[New LWP 23615]
[New LWP 23616]
[New LWP 23617]

Thread 2 "neat_bootstrap" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 23614]
0x00005555557e567e in compiler130_module_neat_stuff_parseExpressionLeaf_either_nullable_compiler130_module_neat_base_class_ASTSymbol_compiler130_module_neat_base_class_Error_2_compiler130_module_neat_base_class_Parser_compiler130_module_neat_base_class_LexicalContext ()
FeepingCreature commented 1 year ago

Ah. musl's stack size is too small for the compiler.

You can work around this by adding -Wl,-z,stack-size=8388608 to the "gcc" line in build.sh.

How can I detect your system? I don't think I should always set that flag.

edit: Alternately, you can remove the -j flag. I think this only happens cause neat is trying to do a threaded compile without specifying a stack size..... Which I should probably fix.

ghost commented 1 year ago

ok the stack size fixed the segfault. You could check if "/lib/ld-musl-x86_64.so.1" is present in the system inside the build.sh file then you could add "-Wl,-z,stack-size=8388608" to the CFLAGS option.

FeepingCreature commented 1 year ago

Released 0.2.3 which should fix it without any changes to build scripts. Can you please confirm?

ghost commented 1 year ago

Well it works fine with the new release, thanks for the time and effort!