Question about make std_spec

tried lastest commit on master

make && make std_spec          
Using /usr/local/opt/llvm/bin/llvm-config [version= 17.0.6]
c++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/local/Cellar/llvm/17.0.6/include -std=c++17 -stdlib=libc++   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
CRYSTAL_CONFIG_BUILD_COMMIT="0b57b6cc8" CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal/src' SOURCE_DATE_EPOCH="1704818267"  CRYSTAL_CONFIG_LIBRARY_PATH='$ORIGIN/../lib/crystal' ./bin/crystal build -D strict_multi_assign -D preview_overload_order -Dwithout_interpreter  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib -D use_pcre2
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
Using /usr/local/opt/llvm/bin/llvm-config [version= 17.0.6]
./bin/crystal build -D strict_multi_assign -D preview_overload_order -Dwithout_interpreter  --exclude-warnings spec/std --exclude-warnings spec/compiler --exclude-warnings spec/primitives -o .build/std_spec spec/std_spec.cr
Using compiled compiler at .build/crystal
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
.build/std_spec --order=random   
0.2.5
Randomized with seed: 24319

what’s the ld warning and why is that?

I’m a relatively new crystal user and found a similar thing just running a simple test Kemal app. I’m on Mac OS 15.5 and upon compiling (for a run) I get loads of ld: warnings like “was built for newer macOS version (15.0) than being linked (13.3)”, e.g. below.. is there a way to suppress these?

ld: warning: object file (H-T-T-P-5858F-ormD-ata.o0.o) was built for newer macOS version (15.0) than being linked (13.3)
ld: warning: object file (P-ointer40H-ash58-ae15d8163d21c417f1fc491f0bbc15a1.o0.o) was built for newer macOS version (15.0) than being linked (13.3)
ld: warning: object file (H-T-T-P-5858F-ormD-ata5858P-arser.o0.o) was built for newer macOS version (15.0) than being linked (13.3)
ld: warning: ld: warning: object file (M-I-M-E-5858M-ultipart5858P-arser.o0.o) was built for newer macOS version (15.0) than being linked (13.3)
ld: warning: object file (M-I-M-E-5858M-ultipart.o0.o) was built for newer macOS version (15.0) than being linked (13.3)
ld: warning: object file (M-I-M-E-5858M-ultipart5858S-tate.o0.o) was built for newer macOS version (15.0) than being linked (13.3)
ld: warning: object file (H-T-T-P-5858F-ormD-ata5858P-art.o0.o) was built for newer macOS version (15.0) than being linked (13.3)

Thanks.

This should have been fixed in the latest version of Crystal

Thanks for the quick reply. I checked the version I used, and it was 1.17.1.

Apparently the MACOS_DEPLOYMENT_TARGET environment variable isn’t enough :disappointed_face:

should I raise a separate github issue about this, or is the above one which has a bot message referring to this message enough?

I also wonder when compiling on the mac, would it be necessary to set an env variable to suppress these (amongst other things)?

Let’s try to figure out what’s happening here. Is $MACOSX_DEPLOYMENT_TARGET defined on your system? Or maybe they renamed it as $MACOS_DEPLOYMENT_TARGET (no X)?

Or maybe the linker defaults to macOS 13.3 but the environment variable isn’t set, so we build the objects for the current host triple, which then leads to the mismatch warnings?

poke @HertzDevil

Sorry, I wanted to reply to the other post, but being a new user I was limited to 3 replies on that topic, so I’ve raised a new one to reply.

In that other post I was reporting why when doing ‘crystal run ..’ I would see so many of the following warnings:

ld: warning: object file (…o0.o) was built for newer macOS version (15.0) than being linked (11.0)

it was suggested by @ysbaddaden that I might need to set the env var $MACOSX_DEPLOYMENT_TARGET and I did set it to “15.5”, and reran, and found that the warnings were suppressed, which is great. However as a new crystal user, I think this is not very intuitive and wonder about the need to see those messages. Why would it be necessary to set this var? Is it possible to invert the situation so those are suppressed by default and enable a var or flag to show those? Thanks.

I wasn’t asking to export the variable. I’m trying to understand why the linker is complaining on your mac, and figure out what we should do to determine the linker’s default deployment target… or maybe we should tell the linker to target the current target, for example by setting $MACOSX_DEPLOYMENT_TARGET or through an argument?

I assume echo $MACOSX_DEPLOYMENT_TARGET doesn’t print anything by default?

Apologies. Yes, echo $MACOSX_DEPLOYMENT_TARGET prints nothing by default. I’ve just tested it again on a brand new MacBook (MacOS 15.3.1) and after installing Crystal 1.17.1 via homebrew, and there is no $MACOSX_DEPLOYMENT_TARGET or $MACOS_DEPLOYMENT_TARGET variables.

$MACOSX_DEPLOYMENT_TARGET variable needs to be set manually.

See Always set `MACOSX_DEPLOYMENT_TARGET` in build scripts ¡ Issue #13115 ¡ rust-lang/cargo ¡ GitHub

1 Like

I realise this is pretty minor, so feel free to ignore - but as someone coming into Crystal from scratch (and coming from Windows also), perhaps this should be documented. There’s no mention of the env variable on the Mac install page, nor this doc page about env vars, though it seems from the above reply having this env var available may be an assumed thing for general development, so apologies if I’m just ignorant to that :blush:

Do not apologize, we just thought the warnings got finally fixed, but they were not :sob:

Maybe we should do the opposite, like define the env variable from the target triplet given by, and maybe have some safe fallback? The Rust cc crate does that for example… and Rust itself does it too; it falls back to these defaults:

And this is where we should make the change: crystal/src/compiler/crystal/config.cr at aa89b919d7d4310af9e61fb2f44c65a4cb0f9645 ¡ crystal-lang/crystal ¡ GitHub.

3 Likes

Do you get issues if you set MACOSX_DEPLOYMENT_TARGET=10.12 for example?

Thanks. I tried setting to 10.12, and still see warnings, e.g. the following for a simple ‘hello world’ kemal app.

ld: warning: dylib (/opt/homebrew/lib/libgc.dylib) was built for newer macOS version (15.0) than being linked (11.0)
ld: warning: dylib (/opt/homebrew/lib/libpcre2-8.dylib) was built for newer macOS version (13.0) than being linked (11.0)
ld: warning: dylib (/opt/homebrew/lib/libssl.dylib) was built for newer macOS version (15.0) than being linked (11.0)
ld: warning: dylib (/opt/homebrew/lib/libcrypto.dylib) was built for newer macOS version (15.0) than being linked (11.0)

I also tried 11.0 and 13.0 with same result, but setting to 15.0 was good (no warnings). Thanks again.

Oh, Homebrew compiled the libraries for 15.0 so Crystal’s objects must also be compiled for 15.0 or later —except for PCRE2 which targets 13.0 but :person_shrugging:

I was thinking that maybe the crystal formula for Homebrew should set the MACOSX_DEPLOYMENT_TARGET and… that’s exactly what the rust formula does.

I guess we should do both:

  1. fallback to a default version when MACOS_DEPLOYMENT_TARGET is unset (or blank);
  2. fix the homebrew formula to set MACOS_DEPLOYMENT_TARGET to the current macOS version.