Closed jcalve closed 1 month ago
Ok, I checked the source of gc-8.2.4
and we can get it to build with Cosmopolitan Libc with the following steps
./configure --disable-cplusplus --disable-shared --enable-static --without-pic --disable-dynamic-loading
-fexceptions
seems GCC-specific, and removing that from the Makefile or the ./configure
starts off the build fineinclude/private/gcconfig.h
, so add the following lines in include/private/gcconfig.h
after the EMSCRIPTEN check (around line 715):#if defined(__COSMOPOLITAN__)
#if defined(__x86_64__)
#define mach_type_known
#define X86_64
#define LINUX // optional?
#elif defined(__aarch64__)
#define mach_type_known
#define AARCH64
#define LINUX // optional?
#endif
#endif
with these above changes make
runs successfully, and make check
passes 10 of the 11 tests provided.
Congratulations on getting libgc to mostly work. I didn't think we were there yet. C++ exceptions is a huge ask, a jupetarian ask. So I've changed the focus of this issue to be a small achievable victory if anyone wants to take it on. Let's get 100% of make check
passing for libgc if possible!
Thanks @ahgamut, that worked. @jart just to provide some more context, I was trying to see if it's possible to compile guile and libgc is one of the dependencies.
We have c++ exception support now. Is this still an issue?
I've tried to build the latest version of libgc myself without disabling C++ and while I didn't encounter any issues with C++ exceptions the build failed fairly early here:
make[1]: Entering directory '/home/gravier/tmp/tmp-libboehm-gc-for-cosmo-test/bdwgc'
depbase=`echo os_dep.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CC --mode=compile /home/gravier/src/libraries/programming/languages-implementations/standard-libraries/c/implementations/cosmopolitan-libc/built-cosmocc-toolchain/bin/cosmocc -DHAVE_CONFIG_H -I./include -I./include -fexceptions -Wall -Wextra -Wpedantic -Wno-long-long -g -O2 -fno-strict-aliasing -Wno-frame-address -MT os_dep.lo -MD -MP -MF $depbase.Tpo -c -o os_dep.lo os_dep.c &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: /home/gravier/src/libraries/programming/languages-implementations/standard-libraries/c/implementations/cosmopolitan-libc/built-cosmocc-toolchain/bin/cosmocc -DHAVE_CONFIG_H -I./include -I./include -fexceptions -Wall -Wextra -Wpedantic -Wno-long-long -g -O2 -fno-strict-aliasing -Wno-frame-address -MT os_dep.lo -MD -MP -MF .deps/os_dep.Tpo -c os_dep.c -o os_dep.o
os_dep.c: In function 'block_unmap_inner':
os_dep.c:2673:17: error: implicit declaration of function 'madvise'; did you mean 'raise'? [-Wimplicit-function-declaration]
2673 | if (madvise(start_addr, len, MADV_DONTNEED) == -1)
| ^~~~~~~
| raise
make[1]: *** [Makefile:1688: os_dep.lo] Error 1
make[1]: Leaving directory '/home/gravier/tmp/tmp-libboehm-gc-for-cosmo-test/bdwgc'
make: *** [Makefile:1954: all-recursive] Error 1
...it looks like libgc simply assumes madvise
is always defined by sys/mman.h
on Linux (this is pretty true on e.g. glibc - madvise
is defined by default there) even though it's non-standard and cosmopolitan requires _COSMO_SOURCE
or _GNU_SOURCE
to be defined for it to be available.
with this patch I got libgc to build, and now the tests appear to pass on both x86_64 and aarch64
Mission accomplished.
I was trying to build: libgc from https://www.hboehm.info/gc/ but the compiler throws this error:
I tried to compile it as: