Open Dieken opened 1 year ago
Thanks for your notes.
The computed goto removal is actually needed for clang support rather than specifically Mac. fbc will not generate the computed gotos if you compile without -e
(error checking). Or if you compile with -ex
then it will take the address of some labels for RESUME support and clang won't throw an error either. The problem is just when using -e
. (A workaround for the clang error is described here: adding crap: void *pcrap = &&crap;
at the top of every generated function). Converting the goto to a function call seems to be the correct solution in the case of compiling with -e
, but shouldn't be done with -ex
, because I think it would break RESUME. (Yeah, noone should ever use RESUME and it's technically undefined behaviour with -gen gcc. But I think it does still work if it's within the same function.)
The hardcoded obsolete -macosx_version_min
is definitely bad and should be replaced with a new fbc commandline arg. I'm not sure how to decide whether to link libgcc or not.
I almost successfully build FreeBasic on macOS 13.1, record the steps for your reference, hope FreeBasic can support macOS soon.
patch FreeBASIC-1.09.0-source:
@@ -3745,7 +3741,6 @@ private sub hAddDefaultLibs( ) end if
generate
bootstrap/darwin-x86_64
on Linux and copy this directory to macOSfix non-local goto, notice non-local goto is undefined behaviour even in GCC.
To fully build the final fbc, subroutines
rtlErrorCheck
andrtlErrorThrow
insrc/compiler/rtl-error.bas
must be changed to not use non-local goto, I'm not familiar with FreeBasic code, don't have enough skill to patch that.