shirok / Gauche

Scheme Scripting Engine
https://practical-scheme.net/gauche
Other
811 stars 81 forks source link

GNU make and libgc dependencies #738

Open lassik opened 3 years ago

lassik commented 3 years ago

I tried compiling Gauche using FreeBSD make yesterday and it did not work. GNU make works fine. Is this a known issue / is this related?

Do you depend on the particular version of libgc included in the Gauche repo, or would an external version of libgc work?

shirok commented 3 years ago

I remember at some point I decided to assume GNU make, for it simplified the build process a lot. I thought I documented it but apparently I didn't.

The issue you pointed, as far as I remember, is to make sure that gmake is used throughout, if the system's make is not gmake.

Regarding libgc, the external one should work but the performance will degrade. The key is that the gc code needs to be compiled with -DDONT_ADD_BYTE_AT_END flag.

To satisfy the C specification, that states a pointer pointing "next" element of the last element of array is a valid pointer (even though you can't dereference it), bdwgc allocates one extra dummy byte than requested.

In Gauche, we want a pair to be exactly 2 words. Using bdwgc default setting, it tries to allocate 2 words plus 1 byte. It effectively makes 4 words per pair, since the allocator rounds up to 2 word boundary. Requesting one less byte won't work, for bdwgc doesn't scan the last word for marking if -DDONT_ADD_BYTE_AT_END isn't given.

I remember once someone maintaining *BSD ports asked me to make it work with external libgc, for their policy didn't like a software having its own version of third-party library, because of the security concern. I told I didn't want it, and pointed out -DDONT_ADD_BYTE_AT_END is an officially allowed configuration option and it'd be unreasonable for them to prohibit using it. However, if they provide a version of libgc compiled with that option now, then I'm willing to use it.

(Or, if -DDONT_ADD_BYTE_AT_END becomes runtime configurable, I can use external libgc and initialize it with the option. As of bdwgc 8.0.4, it's not.)