Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libgc.a for macos is built without -mmacosx-version-min=10.7 breaking macos pre-12.0 #31

Open
codyps opened this issue Mar 6, 2023 · 1 comment

Comments

@codyps
Copy link

codyps commented Mar 6, 2023

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 vlang/v#16386)

@prantlf
Copy link

prantlf commented Jun 11, 2023

@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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants