koka-lang/libhandler

Trouble running tests

mattgreen opened this issue · 3 comments

Hi! I loved your technical paper on this and wanted to play around with it. Unfortunately, however, I wasn't able to get it to run. I get a linker error even when trying out the test suite:

~/Projects/cpltest/libs/libhandler on master
❯ ./configure
--- Configuring build ---
use '--help' for help on configuation options.

--- Check system ---
Found gcc  (at /usr/bin)
C compiler 'gcc' found
Compiler target: x86_64-apple-darwin15.6.0
Normalize target ABI from x86_64 to amd64 (used on Linux, etc)

Configure for target: gcc, amd64-apple-darwin15.6.0

Found ar  (at /usr/bin)
found archiver: ar
The C compiler is C99 compliant.
The C++ compiler is C++11 compliant.
Assembly setjmp found for this ABI: 'asm/setjmp_amd64.s'
Jump buffer size: 72
Do not use linked exception frames for C++
Function strncat_s: not found
Function alloca: found
Header stdbool.h: found

--- Configuration summary ---
System:
  target      : amd64-apple-darwin15.6.0
Build:
  c compiler  : gcc -std=c99 -pedantic -Wall
  c++ compiler: g++ -std=c++11 -Wall
  assembler   : gcc -Wall
  linker      : gcc
  archiver    : ar rcs

Use the following commands to build:
> make depend
> make

To run tests:
> make tests

Test release version:
> make tests VARIANT=release


~/Projects/cpltest/libs/libhandler on master
❯ make depend
use 'make help' for help
build variant: debug, configuration: gcc-amd64-apple-darwin15.6.0
gcc -MM  -Iinc -Iout/gcc-amd64-apple-darwin15.6.0 src/*.c > out/gcc-amd64-apple-darwin15.6.0/temp.depend
sed -e "s|\(.*\.o\)|out/gcc-amd64-apple-darwin15.6.0/\$(VARIANT)/\1|g" out/gcc-amd64-apple-darwin15.6.0/temp.depend > out/gcc-amd64-apple-darwin15.6.0/makefile.depend
gcc -MM  -Iinc -Iout/gcc-amd64-apple-darwin15.6.0 test/*.c > out/gcc-amd64-apple-darwin15.6.0/temp.depend
test/perf.c:37:3: warning: "no high resolution timer" [-W#warnings]
# warning "no high resolution timer"
  ^
1 warning generated.
sed -e "s|\(.*\.o\)|out/gcc-amd64-apple-darwin15.6.0/\$(VARIANT)/\1|g" out/gcc-amd64-apple-darwin15.6.0/temp.depend >> out/gcc-amd64-apple-darwin15.6.0/makefile.depend
rm -f out/gcc-amd64-apple-darwin15.6.0/temp.depend

~/Projects/cpltest/libs/libhandler on master
❯ make
use 'make help' for help
build variant: debug, configuration: gcc-amd64-apple-darwin15.6.0
gcc -Wall  -g -Iinc -Iout/gcc-amd64-apple-darwin15.6.0 -std=c99 -pedantic -o out/gcc-amd64-apple-darwin15.6.0/debug/libhandler.o -c src/libhandler.c
gcc -Wall   -o out/gcc-amd64-apple-darwin15.6.0/debug/asm/setjmp_amd64.o -c src/asm/setjmp_amd64.s
ar rcs  out/gcc-amd64-apple-darwin15.6.0/debug/libhandler.lib out/gcc-amd64-apple-darwin15.6.0/debug/libhandler.o out/gcc-amd64-apple-darwin15.6.0/debug/asm/setjmp_amd64.o

~/Projects/cpltest/libs/libhandler on master
❯ make tests
use 'make help' for help
build variant: debug, configuration: gcc-amd64-apple-darwin15.6.0
gcc -Wall  -g -Iinc -Iout/gcc-amd64-apple-darwin15.6.0  -o out/gcc-amd64-apple-darwin15.6.0/debug/libh-tests.exe test/main-tests.c test/tests.c test/test-exn.c test/test-state.c test/test-amb.c test/test-dynamic.c test/test-raise.c test/test-general.c test/test-tailops.c test/test-state-alloc.c test/test-yieldn.c  out/gcc-amd64-apple-darwin15.6.0/debug/libhandler.lib
Undefined symbols for architecture x86_64:
  "__lh_longjmp", referenced from:
      _jumpto in libhandler.lib(libhandler.o)
      __jumpto_stack in libhandler.lib(libhandler.o)
  "__lh_setjmp", referenced from:
      _handle_with in libhandler.lib(libhandler.o)
      _capture_resume_yield in libhandler.lib(libhandler.o)
      _capture_resume_call in libhandler.lib(libhandler.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [out/gcc-amd64-apple-darwin15.6.0/debug/libh-tests.exe] Error 1

Using nm to peek into setjmp_amd64.o, we can see that the functions it wants do indeed exist, but with a single underscore:

❯ nm out/gcc-amd64-apple-darwin15.6.0/debug/asm/setjmp_amd64.o
0000000000000033 T _lh_longjmp
0000000000000000 T _lh_setjmp
0000000000000061 t ok

I think I need to walk away from this to think about it for a bit. I don't know if it is a MacOS thing or not (I'm on El Cap). Have you seen anything like it?

Thank you for your time.

Edit: sorry, I didn't see that macOS isn't a tested platform. However, it looks like these linking errors are the only real thing standing in the way, hopefully.

It just occurred to me to try mucking with setjmp_amd64.s a bit. Adding an extra underscore to the functions fixed it! Now I need to figure out why libhandler.o is expecting double underscores for the assembly functions.

daanx commented

Thanks Matt -- sorry for the late reply; somehow I don't get github notifications. Anyway, I'll fix this in the assembly files by adding extra entry points.

daanx commented

I think the entry points were added in the wrong assembly files at first. Should be fixed now by
0f1e367