-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Linker warnings in Mac OS Ventura #13846
Comments
This seems to be related to a "new linker" in Xcode 15, see https://projects.blender.org/blender/blender/pulls/110243 for example. I couldn't reproduce this warning but it looks like you could try passing |
|
1 similar comment
|
@PascalLeMerrer in order to pass parameters to the
|
It works much better indeed! Thanks @beta-ziliani |
Just an observation: |
You should be able to do |
Just to note that macOS Sonoma (14) is also affected (as one might expect) by the same issue, and that setting the Out of interest: I happened to notice that binaries created with the "new linker" are about 10% smaller than when using these flags. |
Same problem |
See crystal-lang/crystal#13846 Unclear right now on if this is Crystal issue, LLVM issue, or something else
FYI, I upgraded to Sonoma today and was getting linker warnings like this: object file (H-ash5858E-ntry40S-tring4432S-tring41.o) was built for newer macOS version (14.0) than being linked (13.3) There is also an update for xcode-tools that once installed resolved the linker warnings. |
This works for me. I'm running macOS Sonoma 14 and XCode 15.0 (15A240d). |
CRYSTAL_OPTS="--link-flags=-Wl,-ld_classic" crystal run hello.cr works for me . I'm on: |
Yes even better is to just put this export in your bashrc or .zshrc
then crystal build, crystal run etc all work without the ld warnings. |
I've been investigating this and it's related to the default target triple produced by Crystal during compilation. It seems like in order to fix a bug back in 2015, we stripped the minimum deployment target from the target triple in this commit. Since then, further work has been put into place to normalize target triples from different architectures. Lines 91 to 109 in 1675145
With the release of Xcode 15, a new linker was introduced and with it came these warning messages. It appears that the new linker is stricter in which target triples it considers valid. Specifically, it looks like the minimum deployment target is required. E.g., Before I go ahead and submit the pull request, I'd love to discuss what the correct path forward is. We could change the behaviour of $ cd /Library/Developer/CommandLineTools/SDKs
$ find . -maxdepth 1 ! -type l ! -path . -exec bash -c 'echo {} && gojq ".SupportedTargets.macosx | { MinimumDeploymentTarget, MaximumDeploymentTarget, RecommendedDeploymentTarget }" {}/SDKSettings.json' \;
./MacOSX13.3.sdk
{
"MaximumDeploymentTarget": "13.3.99",
"MinimumDeploymentTarget": "10.13",
"RecommendedDeploymentTarget": "10.14.6"
}
./MacOSX14.4.sdk
{
"MaximumDeploymentTarget": "14.4.99",
"MinimumDeploymentTarget": "10.13",
"RecommendedDeploymentTarget": "10.14.6"
}
|
Does this also explain why I couldn't reproduce this on my M2 since the normalization fails due to #14052? |
It does, yes. I'm seeing the same behaviour on my machine since the default triple returned by LLVM is crystal/src/compiler/crystal/codegen/target.cr Lines 22 to 34 in 1675145
but the new linker seem to accept that anyway. |
It turns out we hard-code the target in the distribution-scripts. This is definitely also an issue. I'm also not entirely sure that comment is correct (at least not any more). Running
I've also confirmed that the following all compile without any warnings: $ clang -Xclang '-triple=arm64-apple-macosx14.0.0' hello.c -o hello
$ clang -Xclang '-triple=aarch64-apple-macosx14.0.0' heloc.c -o hello
$ clang -Xclang '-triple=arm64-apple-darwin23.2.0' hello.c -o hello
$ clang -Xclang '-triple=aarch64-apple-darwin23.2.0' hello.c -o hello while the following does not: $ clang -Xclang '-triple=arm64-apple-darwin' hello.c -o hello
$ clang -Xclang '-triple=aarch64-apple-darwin' hello.c -o hello
$ clang -Xclang '-triple=arm64-apple-macosx' hello.c -o hello
$ clang -Xclang '-triple=aarch64-apple-macosx' hello.c -o hello they all produce a warning like the following:
|
With the release of Xcode 15, a new linker was introduced and with it came warnings from the linker on macOS specifically. It appears that the new linker is stricter in which target triples it considers valid. Specifically, it looks like the minimum deployment target is required. E.g., `aarch64-apple-darwin23.3.0` is valid, while `aarch64-apple-darwin` is not. See also: * https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking * crystal-lang/crystal#13846
With the release of Xcode 15, a new linker was introduced and with it came warnings from the linker. It appears that the new linker is stricter in which target triples it considers valid. Specifically, it looks like the minimum deployment target is required. E.g., `aarch64-apple-darwin23.3.0` is valid, while `aarch64-apple-darwin` is not. See also: * https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking * crystal-lang/crystal#13846
This is great work, thanks Kevin for digging into this 🚀 I guess there's a reason why LLVM doesn't normalize target triples. Our normalization is quite significant in some places. Before we make changes that bring back version numbers, we need to check where these triples are used and whether some use cases may depend on normalized values. We may have to offer both, the full raw triple as well as a normalized version. |
With the release of Xcode 15, a new linker was introduced and with it came warnings from the linker. It appears that the new linker is stricter in which target triples it considers valid. Specifically, it looks like the minimum deployment target is required. E.g., `aarch64-apple-darwin23.3.0` is valid, while `aarch64-apple-darwin` is not. See also: * https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking * crystal-lang/crystal#13846
I am running into this issue when I use Intel macs on GitHub Actions since this week.
https://github.com/oprypin/crystal-chipmunk/actions/runs/8859208139/job/24329593971 |
The warnings are now always reproducible on GitHub Actions with |
Back to the C library troubles-
https://github.com/oprypin/crystal-chipmunk/actions/runs/8859789088/job/24329985809 |
I met the same warnings on GitHub Actions, with the full warning message here. https://github.com/yanecc/MockGPT/actions/runs/8913041997/job/24477764716#step:4:24 |
Those warnings should be gone whenever #14466 gets merged. |
I am also getting errors in GitHub Actions when using MacOS based runners. Builds on Linux work fine: [14/13] Codegen (linking)
cc _main.o3.o -o /Users/runner/work/runway/runway/bin/runway -rdynamic -L/Users/runner/work/_temp/crystal-latest-true-undefined/embedded/lib -lssh2 -lxml2 -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -L/opt/homebrew/Cellar/libyaml/0.2.5/lib -lyaml -lpcre2-8 -lgc -L/opt/homebrew/Cellar/libevent/2.1.12_1/lib -levent_pthreads -levent -L/opt/homebrew/Cellar/libevent/2.1.12_1/lib -levent -liconv
E: Error target runway failed to compile:
ld: warning: ignoring duplicate libraries: '-levent'
ld: library 'ssh2' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with exit status 1: cc "${@}" -o /Users/runner/work/runway/runway/bin/runway -rdynamic -L/Users/runner/work/_temp/crystal-latest-true-undefined/embedded/lib -lssh2 -lxml2 -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -L/opt/homebrew/Cellar/libyaml/0.2.5/lib -lyaml -lpcre2-8 -lgc -L/opt/homebrew/Cellar/libevent/2.1.12_1/lib -levent_pthreads -levent -L/opt/homebrew/Cellar/libevent/2.1.12_1/lib -levent -liconv UpdateI swapped from |
Starting with Xcode 15, the minimum deployment target is required in the target triple. With the release of Xcode 15, a [new linker was introduced](https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking) and with it came warning messages like this: ld: warning: no platform load command found in '/Users/pascal/.cache/crystal/Users-pascal-Documents-tutorials-crystal-hello_world.cr/F-loat32.o', assuming: macOS It appears that the new linker is stricter in which target triples it considers valid. Specifically, it looks like the minimum deployment target is required. E.g., `aarch64-apple-darwin23.3.0` is valid, while `aarch64-apple-darwin` is not. See #13846 (comment) for details. This patch removes code which strips the minimum deployment target in `LLVM.default_target_triple` as an effort for standardization. See also: crystal-lang/distribution-scripts#296
Bug Report
I installed Crystal on MacOS Ventura, using Homebrew.
It worked, however compiling a simple hello world generates 280 warnings like:
Crystal version: 1.9.2
OS Version: Ventura, then Sonoma (I upgraded it, but it did not change anything)
Brew doctor does not signal anything wrong.
The steps I followed:
The text was updated successfully, but these errors were encountered: