I already mentioned this issue there https://github.com/Homebrew/homebrew-core/pull/37993#issuecomment-477540922 but I guess it makes sense to open a proper issue about this.
So, to quote myself:
Though the swipl binary is correctly built by CMake now, the swipl-ld one is broken. Indeed, it stores at compile time the name of the compiler that build it (accessed from C_CC and C_CXX https://github.com/SWI-Prolog/swipl/blob/master/src/swipl-ld.c#L139), which results in it trying to call /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang at runtime, when it should only call /usr/bin/clang.
This can be checked by simply running swipl-ld -vh.
Which, on my two 10.14 macs results in:
clang: The build tool has reset ENV; --env=std required.
/usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang returned code 256
*** /usr/local/Cellar/swi-prolog/HEAD-fba80fd/libexec/bin/swipl-ld exit status 1
I don't know anything about how to _not use_ shims when building swipl-ld but if that's at all possible, it would be very nice. Otherwise, overriding the C_CC and C_CXX environment variables might be enough…
Could you fill out the issue template please? It's pretty essential in debugging issues. This issue can be reopened once we have all the information needed to start debugging.
Oops, sorry… here it is:
brew install (or upgrade, reinstall) a single, Homebrew/homebrew-core formula (not cask) on macOS?brew update and can still reproduce the problem?brew doctor, fixed all issues and can still reproduce the problem?brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?And here is the brew gist-logs swi-prolog link: https://gist.github.com/soli/3b5a1c0e04bbc299f05a3d30e7b09076
Unfortunately, due to an unexpected error this message did not reach the intended recipients. Please resubmit the message.
Best regards,
EF Global IT
From: Sean Molenaar notifications@github.com
Sent: Monday, April 1, 2019 9:53 AM
To: Homebrew/homebrew-core homebrew-core@noreply.github.com
Cc: Subscribed subscribed@noreply.github.com
Subject: Re: [Homebrew/homebrew-core] swipl-ld is broken in swi-prolog 8.0.2 (and --HEAD) recipe (#38571)
-
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FHomebrew%2Fhomebrew-core%2Fissues%2F38571%23event-2242589169&data=02%7C01%7C%7C5503a3b34c4e4316b44808d6b67f8339%7Cf0d1c6fddff0486a8e91cfefefc7d98d%7C0%7C0%7C636897056106583531&sdata=8mzyrPXzp0K4Y%2B0wVdLw0SrjIdRBJotZ0vqixf7cIqE%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAsgmqCxpRleSc9FrML3TBfZ6zMZwSXOhks5vcckIgaJpZM4cVIs7&data=02%7C01%7C%7C5503a3b34c4e4316b44808d6b67f8339%7Cf0d1c6fddff0486a8e91cfefefc7d98d%7C0%7C0%7C636897056106593541&sdata=Se3wfD2iiHvIwNsHpQ%2FkpLlCHDzIlfBonMtIL5KRPaI%3D&reserved=0.
Since I don't see many answers, could anyone point me to some kind of docs allowing me to do the last thing I mentioned:
I don't know anything about how to not use shims when building swipl-ld but if that's at all possible, it would be very nice. Otherwise, overriding the C_CC and C_CXX environment variables might be enough…
i.e., how to change the build environment, especially related to shims.
Thanks
I don't know anything about how to _not use_ shims when building
swipl-ldbut if that's at all possible, it would be very nice. Otherwise, overriding the C_CC and C_CXX environment variables might be enough…
We can't avoid using the shims to build the tool but we could/should configure it so at runtime it uses the system /usr/bin/clang or similar.
As far as I understand the source (https://github.com/SWI-Prolog/swipl/blob/master/src/swipl-ld.c) it seems that overriding $C_CC and $C_CXX at build-time might be enough, but then again I don't know how to find the "unshimmed" values nor how to change the build environment (sorry, I've never written any recipe 😭)
I don't know how to find the "unshimmed" values
For git and svn:
$ $(brew --repo)/Library/Homebrew/shims/mac/super/git --homebrew=print-path
/usr/bin/git
For everything else:
$ xcrun -find clang
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
Ok, thanks @sjackman, I'll give a try at patching the recipe and see if I can come up with a pull request if everything works fine.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If I use xcrun -find clang to set-up CMAKE_C_COMPILER (that gets put into C_CC) then when using the tool, clang does not find basic header files like stdio.h and such…
Is there an issue (I guess so, but TBH have no idea) in hardcoding /usr/bin/clang and such?
Does setting C_CC=/usr/bin/clang C_CXX=/usr/bin/clang++ work as you suggested?
Almost… swipl-ld is at least usable, but in one of the scenarios I use it, it does spit an error that I still have to investigate (I'll repost here when I'm fully ok with the result, but I wanted to know if that direction made any sense at all).
BTW, I had to set CMAKE_C_COMPILER to /usr/bin/clang (and same for CXX and clang++) as actually C_CC and C_CXX are variables that are overwritten in Params.cmake with those values…
Ok, I managed to get rid of the error I had by adding -lc++ in some linking phases… But the resulting binary, compiled without issues, _does not work_ (it fails silently), so I'm still trying to figure out what's wrong (since in other examples now everything works well).
Ok, I managed to get rid of the error I had by adding
-lc++in some linking phases…
Adding -lc++ shouldn't be necessary as long as you're linking using clang++ rather than clang or ld.
Thanks, I know, but the point of all this issue is that I'm linking with swipl-ld (which apparently in that case does not properly detect that it should link against the C++ libraries)… So, maybe the fact that I _forced_ the C and C++ compilers at compile-time did change something in the resulting swipl-ld binary… I'm still trying to wrap my head around all this…
Have you tried asking on the SWI-Prolog GitHub?
https://github.com/SWI-Prolog/swipl
https://github.com/SWI-Prolog/swipl-devel
Not yet since I first thought it was a simple issue of using the Homebrew shims at compile time, but since it appears to be more deep, I probably will ^^
Ok, actually this might just be related to some recent changes on SWI-Prolog's side, I've updated the Makefiles of my different projects accordingly and everything now seems to work !!! 👍
I'll have a few coworkers try my patched recipe and if it goes smoothly I'll send a PR 😎
I'm glad to hear that you found a fix! That's great!
thx for the help !