koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.16k stars 151 forks source link

fail to compile samples #472

Closed lengyijun closed 3 months ago

lengyijun commented 4 months ago
koka --compile /usr/local/share/koka/v3.1.0/lib/samples/basic/fibonacci.kk
load    : std/core
load    : std/core/types
load    : std/core/undiv
load    : std/core/vector
load    : std/core/unsafe
load    : std/core/exn
load    : std/core/order
load    : std/core/hnd
load    : std/core/list
load    : std/core/bool
load    : std/core/int
load    : std/core/string
load    : std/core/char
load    : std/core/either
load    : std/core/maybe
load    : std/core/tuple
load    : std/core/sslice
load    : std/core/debug
load    : std/core/console
load    : std/core/delayed
load    : std/core/show
parse   : .../fibonacci.kk
check   : fibonacci
linking : fibonacci/@main
/usr/bin/ld: .koka/v3.1.0/gcc-debug-6a8962/std_core_string.o: in function `kk_bits_clz64':
/home/daan/dev/koka/kklib/include/kklib/bits.h:174:(.text+0x82): undefined reference to `kk_bits_clz32'
/usr/bin/ld: /home/daan/dev/koka/kklib/include/kklib/bits.h:176:(.text+0xb0): undefined reference to `kk_bits_clz32'
/usr/bin/ld: .koka/v3.1.0/gcc-debug-6a8962/std_core_sslice.o: in function `kk_bits_clz64':
/home/daan/dev/koka/kklib/include/kklib/bits.h:174:(.text+0xb1): undefined reference to `kk_bits_clz32'
/usr/bin/ld: /home/daan/dev/koka/kklib/include/kklib/bits.h:176:(.text+0xe1): undefined reference to `kk_bits_clz32'
/usr/bin/ld: /home/daan/dev/koka/kklib/include/kklib/bits.h:174:(.text+0x10e9): undefined reference to `kk_bits_clz32'
/usr/bin/ld: .koka/v3.1.0/gcc-debug-6a8962/std_core_sslice.o:/home/daan/dev/koka/kklib/include/kklib/bits.h:176: more undefined references to `kk_bits_clz32' follow
collect2: error: ld returned 1 exit status
fibonacci/@main(1, 1): build error: user error (error  : command failed (exit code 1)
command: /usr/bin/gcc -g -Og -o .koka/v3.1.0/gcc-debug-6a8962/fibonacci__main .koka/v3.1.0/gcc-debug-6a8962/kklib.o .koka/v3.1.0/gcc-debug-6a8962/std_core_types.o .koka/v3.1.0/gcc-debug-6a8962/std_core_undiv.o .koka/v3.1.0/gcc-debug-6a8962/std_core_unsafe.o .koka/v3.1.0/gcc-debug-6a8962/std_core_hnd.o .koka/v3.1.0/gcc-debug-6a8962/std_core_exn.o .koka/v3.1.0/gcc-debug-6a8962/std_core_bool.o .koka/v3.1.0/gcc-debug-6a8962/std_core_int.o .koka/v3.1.0/gcc-debug-6a8962/std_core_order.o .koka/v3.1.0/gcc-debug-6a8962/std_core_char.o .koka/v3.1.0/gcc-debug-6a8962/std_core_vector.o .koka/v3.1.0/gcc-debug-6a8962/std_core_string.o .koka/v3.1.0/gcc-debug-6a8962/std_core_sslice.o .koka/v3.1.0/gcc-debug-6a8962/std_core_list.o .koka/v3.1.0/gcc-debug-6a8962/std_core_maybe.o .koka/v3.1.0/gcc-debug-6a8962/std_core_either.o .koka/v3.1.0/gcc-debug-6a8962/std_core_tuple.o .koka/v3.1.0/gcc-debug-6a8962/std_core_show.o .koka/v3.1.0/gcc-debug-6a8962/std_core_console.o .koka/v3.1.0/gcc-debug-6a8962/std_core_debug.o .koka/v3.1.0/gcc-debug-6a8962/std_core_delayed.o .koka/v3.1.0/gcc-debug-6a8962/std_core.o .koka/v3.1.0/gcc-debug-6a8962/fibonacci.o .koka/v3.1.0/gcc-debug-6a8962/fibonacci__main.o -lm -lpthread)

Failed to compile /usr/local/share/koka/v3.1.0/lib/samples/basic/fibonacci.kk
TimWhiting commented 4 months ago

This looks like it has Daans paths in it. Really weird. This is on the command line? Can you try removing the .koka build directory and compiling from scratch - (unlikely to help, but worth a try)?

Also can you give a bit more information (which platform - macos/linux/windows), anything custom you have set up, do you have a development environment set up or are you just doing a fresh install / upgrade, are you using docker or something else, etc...

The samples compile with the 3.1.0 compiler for me.

lengyijun commented 4 months ago

I can reproduce the issue on new ubuntu machines

I install koka by curl instead of vscode

daanx commented 4 months ago

That is so strange that my path is in there.. how can that be? (I guess because I built a binary and the .o files contain debug information about header files). The error is strange too as it works on my ubuntu. Can you try passing the flag --cc=clang to koka and see if that works?

daanx commented 4 months ago

Ah, I can repro it -- it works with --cc=clang so it is some problem with gcc; I'll look into it further tomorrow

daanx commented 4 months ago

It is fixed in dev now -- it was because I built on Ubuntu 18 (so libs are compatible) but that has gcc 7.4 which doesn't have __has_builtin, causing link errors on any system with gcc >= 10 (like Ubuntu 22). I'll push a new release soon :-)