buzz-lang / BittyBuzz

BittyBuzz is an implementation of Buzz for microcrontrollers.
MIT License
8 stars 7 forks source link

Tests not compiling #4

Closed xgroleau closed 3 years ago

xgroleau commented 3 years ago

I wanted to run the tests since I have an issue with swarm.exec and the closure being NIL, but I cannot compile the tests. To build I've followed the instructions in the README

mkdir build
cd build
cmake ../src
make

I get this error:

... PREVIOUS COMPILATION OUTPUT...
Scanning dependencies of target testneighbors
[ 96%] Building C object testing/CMakeFiles/testneighbors.dir/testneighbors.c.o
[ 97%] Linking C executable testneighbors
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: ../bittybuzz/libbittybuzz.a(bbzvm.c.o):(.bss+0x0): multiple definition of `vm'; CMakeFiles/testneighbors.dir/testneighbors.c.o:/home/xavier/Documents/Builds/BittyBuzz/src/testing/testneighbors.c:8: first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [testing/CMakeFiles/testneighbors.dir/build.make:104: testing/testneighbors] Error 1
make[1]: *** [CMakeFiles/Makefile2:1426: testing/CMakeFiles/testneighbors.dir/all] Error 2
make: *** [Makefile:114: all] Error 2

Seems like a redefinition of symbol.

beltrame commented 3 years ago

It seems to be a problem with gcc 10 on OpenSuse, as with gcc 9.3 on Ubuntu everything works fine. I reproduced the issue on an OpenSuse and I'm investigating.

xgroleau commented 3 years ago

It seems that gcc 10 uses -fno-common by default, I've added -fcommon locally in the cmake file and it now compiles.

beltrame commented 3 years ago

It was indeed a variable redefinition in two test cases. Even if defined already as extern, it is best to just use the vm variable instead of trying to redefine it. The last commit fixes the issue.