tccbin
tccbin copied to clipboard
libgc.a for macos is built without `-mmacosx-version-min=10.7` breaking macos pre-12.0
Right now, using tcc (built from git) on macos 11 (or anything prior to 12.0) will fail with:
ld: warning: object file (/Users/x/d/v/thirdparty/tcc/lib/libgc.a(gc.o)) was built for newer macOS version (12.0) than being linked (10.7)
Undefined symbols for architecture x86_64:
"____chkstk_darwin", referenced from:
_GC_forward_exception in libgc.a(gc.o)
_GC_mark_thread in libgc.a(gc.o)
ld: symbol(s) not found for architecture x86_64
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
This is resolved by rebuilding libgc.a and passing the -mmacosx-version-min=10.7, which matches what v itself is passing to tcc internally.
This specifically affects https://github.com/vlang/tccbin/tree/thirdparty-macos-amd64
I've worked around this locally by manually rebuilding libgc.a with these commands (from the tcc repo):
cc -mmacosx-version-min=10.7 thirdparty/libgc/gc.c -c -o gc.o
libtool -static -o thirdparty/tcc/lib/libgc.a gc.o
(tangential relation to https://github.com/vlang/v/issues/16386)
@jmesmon , what magic did you use to get tcc compiled on MacOS? :-) I'm struggling with the libc missing. I run the latest MacOS 13.
The build succeeds:
❯ ./configure
Binary directory /usr/local/bin
TinyCC directory /usr/local/lib/tcc
Library directory /usr/local/lib
Include directory /usr/local/include
Manual directory /usr/local/share/man
Info directory /usr/local/share/info
Doc directory /usr/local/share/doc
/usr/include dir /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
Source path /Users/prantlf/Sources/github/tinycc
C compiler clang (14.0)
Target OS Darwin
CPU x86_64
Config OSX
Creating config.mak and config.h
❯ make
...
❯ ls -al tcc
-rwxr-xr-x@ 1 prantlf staff 437016 Jun 11 11:20 tcc
But the tests do not:
❯ make test
------------ hello-exe ------------
tcc: error: library 'c' not found
tcc: error: undefined symbol '_printf'
+ ../tcc -vv
tcc version 0.9.27 2023-05-29 mob@583c3b4 (x86_64 Darwin)
install: /usr/local/lib/tcc
include:
/usr/local/lib/tcc/include
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
libraries:
/usr/local/lib/tcc
/usr/lib
/lib
/usr/local/lib
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
libtcc1:
/usr/local/lib/tcc/libtcc1.a
+ otool -L ../tcc
../tcc:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
+ exit 1
make[2]: *** [hello-exe] Error 1
make[1]: *** [all] Error 2
make: *** [test] Error 2
I get the same "library 'c' not found" error when trying to build examples.ex1.c from the tcc repository. I can compile it to the object file, but I cannot link it.
There's neither /usr/lib/libSystem.B.dylib nor /usr/lib/libSystem.dylib on my system. I found the .tbd files, but they're not enough for tcc:
❯ find /Library/Developer -name libSystem.\*
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libSystem.B.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libSystem.B_asan.tbd
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libSystem.tbd
❯ find /Library/Developer -name libc.\*
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/libc.h
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/lib/libc.tbd
I tried both branches - master and mob. The error is the same...