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

Linux -> Mac cannot cross compile aws-lc-sys #409

Closed
brongan opened this issue Apr 25, 2024 · 6 comments
Closed

Linux -> Mac cannot cross compile aws-lc-sys #409

brongan opened this issue Apr 25, 2024 · 6 comments
Labels
build problem Build failure

Comments

@brongan
Copy link

brongan commented Apr 25, 2024

Problem:

On an x86_64 Linux box

cargo new repro
cd repro
cargo add aws-lc-rs
cargo b --target x86_64-apple-darwin

Fails with unknown flag errors.

  --- stderr
  thread 'main' panicked at /home/brong/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.15.0/builder/cc_builder.rs:225:9:
  COMPILER: "cc"ARGS: ["-O0", "-ffunction-sections", "-fdata-sections", "-fPIC", "-gdwarf-2", "-fno-omit-frame-pointer", "-m64", "-arch", "x86_64", "-mmacosx-version-min=10.7", "-Wall", "-Wextra", "/home/brong/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.15.0/aws-lc/tests/compiler_features_tests/memcmp_invalid_stripped_check.c", "-Wno-unused-parameter", "-o", "/home/brong/ws/repro/target/x86_64-apple-darwin/debug/build/aws-lc-sys-963977ec30e96b4e/out/memcmp_invalid_stripped_check"]EXECUTED: trueERROR: cc: error: unrecognized command-line option ‘-arch’
  cc: error: unrecognized command-line option ‘-mmacosx-version-min=10.7’
  OUTPUT: Failed to compile memcmp_invalid_stripped_check

Relevant details

aws-lc-rs 17

Linux 6.8.6-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sat, 13 Apr 2024 14:44:53 +0000 x86_64 unknown

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.78.0-nightly (a4472498d 2024-02-15)

@thedjpetersen
Copy link

+1

@justsmth justsmth added the build problem Build failure label Apr 25, 2024
@justsmth
Copy link
Contributor

I can reproduce this on my Linux host. I'm investigating now.

@justsmth
Copy link
Contributor

justsmth commented Apr 25, 2024

The parameter appears to be added here: https://github.com/rust-lang/cc-rs/blob/994dc909dc54caa9eaa473b9807c171e1763d27e/src/lib.rs#L2659

...
        match arch {
            AppleArchSpec::Device(_) if is_mac => {
                cmd.args
                    .push(format!("-mmacosx-version-min={}", min_version).into());
            }
...

It seems related to this issue: rust-lang/cc-rs#1030

@justsmth
Copy link
Contributor

justsmth commented Apr 25, 2024

Another related issue: rust-lang/cc-rs#710

I'm not certain cross-compiling C/C++ code to MacOS from Linux via cc-rs is expect to work like this. I tried this same method and reproduced the failure with ring and openssl; they both generate errors about these same flags:

  cargo:warning=cc: error: unrecognized debug output level ‘full’
  cargo:warning=cc: error: unrecognized command-line option ‘-arch’
  cargo:warning=cc: error: unrecognized command-line option ‘-mmacosx-version-min=10.7’

@brongan
Copy link
Author

brongan commented Apr 25, 2024

From https://rust-lang.github.io/rustup/cross-compilation.html

Note that rustup target add only installs the Rust standard library for a given target. There are typically other tools necessary to cross-compile, particularly a linker. For example, to cross compile to Android the Android NDK must be installed. In the future, rustup will provide assistance installing the NDK components as well. See the target section of the cargo configuration for how to setup a linker to use for a certain target.

@justsmth
Copy link
Contributor

Since cross-compiling from Linux to Mac is not something we currently plan to support. I'm closing this issue. Feel free to open another issue as a feature request if you'd like us to further investigate this as a cross-compilation option.

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

No branches or pull requests

3 participants