Build issues on macOS
Builiding the top of the tree on macOS I ran into a couple issues that needed manual intervention.
-
In engine/getopt.sh, there's an
#if defined(__GNU_LIBRARY)check around the proper extern declaration ofgetopt, which is incorrect; it's not true that only systems using the GNU libc need the correct declaration. Even under real gcc this fails to compile on macOS. I just removed that#ifand the#elseclause entirely. -
In the generated unix/x-fsi.c (and still in x-fsi-fixed.c) there are several lines in a row that are missing semicolon terminators. I'm not sure if this is a problem with the swig-forth installation or an input template, but all of these
iflines should have a trailing semicolon after the final 0:
swigComment("--===< function pointers >===---\n");
if(offsetof(struct _XExtData, free_private) >= 0) 0
if(offsetof(struct funcs, create_image) >= 0) 0
if(offsetof(struct funcs, destroy_image) >= 0) 0
if(offsetof(struct funcs, get_pixel) >= 0) 0
if(offsetof(struct funcs, put_pixel) >= 0) 0
if(offsetof(struct funcs, sub_image) >= 0) 0
if(offsetof(struct funcs, add_pixel) >= 0) 0
If you look in the corresponding x.i file, you will see a sed script. These are run during the build.
// prep: sed -e 's/swigFunctionPointer.*{((\([^*]*\)\*)ptr)->\([^}]*\)}.*/if(offsetof(\1, \2) >= 0) \0/g'
As far as I can work out, the strategy is used in quite a few *.I files. Adding a semi-colon:
// prep: sed -e 's/swigFunctionPointer.*{((\([^*]*\)\*)ptr)->\([^}]*\)}.*/if(offsetof(\1, \2) >= 0) \0 ; /g'
fixes the compilation problems with no harm done if the extra semi-colon is unnecessary.
Actually, the problem seems to be that MacOS sed isn't replacing \0 with the overall pattern, but 0 instead.
Thank you. That would explain why the problem occurs on my Mac systems but not on linux. Does the HomeBrew build on a Mac suffer from the problem as well?
On MacPorts, I installed gsed and added export SED=gsed to my build script. I removed the ';' that I added to X.i and tested the build. Again the build works but still ./gforth minos2/gl-sample.fs results in a large number of redefinition warnings and then a permissions error as described in #46.