cross-rs / cross-toolchains

Additional Dockerfiles and crosstool-ng config files to build additional toolchains.
Apache License 2.0
88 stars 16 forks source link

Rust now requires MacOS > 10.12 #56

Open strowk opened 5 months ago

strowk commented 5 months ago

See https://blog.rust-lang.org/2023/09/25/Increasing-Apple-Version-Requirements.html

This: https://github.com/cross-rs/cross-toolchains/blob/83b28663ebf6b38436e534652a2522a6963fa132/docker/darwin.sh#L52 needs to be upped to 10.12 in at least some targets, otherwise error looking like this:

          ld: warning: object file (/target/x86_64-apple-darwin/release/deps/libidna-9e0bb8c28bf4f03d.rlib(idna-9e0bb8c28bf4f03d.idna.3875f9ff72356008-cgu.7.rcgu.o)) was built for newer macOS version (10.12) than being linked (10.7)
          Undefined symbols for architecture x86_64:
            "_clock_gettime", referenced from:
                std::sys::unix::time::Timespec::now::h0ebd2e38935918ca in libstd-4b3c9502f998a9c9.rlib(std-4b3c9502f998a9c9.std.ccb858c55971878c-cgu.0.rcgu.o)
            "_getentropy", referenced from:
                std::sys::unix::rand::hashmap_random_keys::ha92d0a2687c22b7a in libstd-4b3c9502f998a9c9.rlib(std-4b3c9502f998a9c9.std.ccb858c55971878c-cgu.0.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

would be happening (this is from build for x86_64).

Simply upping the value to 10.12 would be more strict than what Rust seems to require now though. There was no issue for me on aarch64-apple-darwin, and that is in alignment with blog post linked above, as that target is not mentioned as affected by change (aarch64-apple-ios is mentioned, but not darwin).

Knniff commented 4 months ago

Is there a fix for this, because no combinations of sdks for the apple targets work for me right now.

strowk commented 4 months ago

@Knniff

For myself, I did a "hacky" workaround here - https://github.com/strowk/tisq/commit/afacd74aecd639ca4790950352c4e41b008fcf7f

Basically I have "cross" folder with cloned cross, which has a problematic file under this subpath: "docker/cross-toolchains/docker/darwin.sh". I override this file with that one - https://github.com/strowk/tisq/blob/afacd74aecd639ca4790950352c4e41b008fcf7f/patched-darwin.sh#L52 before building (it is wired in using cargo-make, I was too lazy for xargo or other fancy ways).

The only difference is in line 52 there

    TARGET_DIR=/opt/osxcross UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh

is replaced by

    TARGET_DIR=/opt/osxcross UNATTENDED=yes OSX_VERSION_MIN=10.12 ./build.sh # this line is changed 10.7 to 10.12

Result of this is successful build, though obviously the binary would not work anymore for MacOS < 10.12 (which is not officially supported by Apple themselves anyway).

I suppose alternative to this could be pinning Rust toolchain to something before 1.74 , if old versions of OS are more important for you than new versions of language.

Knniff commented 4 months ago

Thank you for your explanation. Which version of the SDK are you using? I tried a few but all came out with some kind of linker error.