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

Build failure on MacOS #367

Open
thobe opened this issue Oct 20, 2021 · 4 comments
Open

Build failure on MacOS #367

thobe opened this issue Oct 20, 2021 · 4 comments
Labels

Comments

@thobe
Copy link

thobe commented Oct 20, 2021

I was getting the following error when building on MacOS (version 11.6), using bmake (version stable 20211001) installed from homebrew:

...
ld -o build/lib/libfsm.dylib -dylib -flat_namespace -undefined dynamic_lookup -macosx_version_min 10.6  build/lib/adt.opic build/lib/print.opic build/lib/libfsm.opic
ld: warning: building for macOS 10.6 is deprecated
ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
*** Error code 1

I was able to resolve this by making the following change to share/mk/so.mk

diff --git a/share/mk/so.mk b/share/mk/so.mk
index 633b1a2..ddf37fd 100644
--- a/share/mk/so.mk
+++ b/share/mk/so.mk
@@ -30,7 +30,7 @@ LDSFLAGS ?= -shared
 
 .if ${CC:T:Mgcc*} || ${CC:T:Mclang*}
 .if ${SYSTEM} == Darwin
-LDSFLAGS += -macosx_version_min ${MACOSX_VERSION_MIN}
+LDSFLAGS += -macosx_version_min ${MACOSX_VERSION_MIN} -lSystem -L$$(xcode-select -p)/SDKs/MacOSX.sdk/usr/lib
 .endif
 .endif

I'm not going to claim that this solution is my original invention, I simply searched for other people having similar problems with ld on MacOS, and found this which explained the problem and provided a solution: https://stackoverflow.com/questions/52830484/nasm-cant-link-object-file-with-ld-on-macos-mojave
Because of that, I am not confident that I understand the implications of these changes on other versions of MacOS well enough to submit a pull request with this change. However, I felt it useful to report the issue for someone more capable to take it from here, and provide the solution that worked for me in case others have the same issue and could benefit from the workaround.

@katef
Copy link
Owner

katef commented Oct 24, 2021

oh this is new. thank you!

@fgsch
Copy link

fgsch commented Feb 6, 2022

Just ran into the same issue with 12.2 (Big Sur)

@katef
Copy link
Owner

katef commented Feb 24, 2022

I (temporarily) disabled CI for MacOS in #371 because I have no way to work on this locally. But we'll need to figure out something here.

For github's CI, i found xcode-select -p gives no output. I couldn't figure out why!

@katef katef added the bug label Apr 26, 2022
@dsifriend
Copy link

I'd like to note that @thobe 's solution is still right in principle, although the suffix to the path given by xcode-select -p has changed. I suspect that will continue to be the case with new macOS releases if Apple hasn't settled on a new convention yet, but should that not be the case (and as a matter of record), what worked for me on Monterey was:

LDSFLAGS += -macosx_version_min ${MACOSX_VERSION_MIN} -L$$(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib -lSystem

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

No branches or pull requests

4 participants