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

fix: maturin develop can compile on macOS with M1/M2 chip #1015

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub fn develop(
Ok(output) if output.status.success() => {
let platform = String::from_utf8_lossy(&output.stdout);
if platform.contains("macos") {
if platform.contains("x86_64") && target.target_arch() != Arch::X86_64 {
if platform.contains("x86_64") && target.target_arch() == Arch::X86_64 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L38 and L40 change is wrong. We want to respect Python architecture to fix #982 and #979. target is default Rust target we get from rustc -vV.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the discussion in #1013, can you add a debug print here and paste the output here.

println!("{} {:?}", platform, target.target_arch());

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macosx-10.14.6-arm64 Aarch64

@messense

This comment was marked as off-topic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the offending code shouldn't be these two I think? It might be related to the target_triple variable, can you try #1016 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if I append --target aarch64-apple-darwin, it works fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you have to debug further, based on the macosx-10.14.6-arm64 Aarch64 output it shouldn't reach these two lines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try add println!("{:#?}", build_options); just above

let build_context = build_options.into_build_context(release, strip, true)?;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BuildOptions {
    platform_tag: [
        Linux,
    ],
    interpreter: [
        "/Users/pvon/Documents/string_sum/.env/bin/python",
    ],
    find_interpreter: false,
    bindings: None,
    out: Some(
        "/var/folders/0r/tkx69nhn6vg6sr0w1c6nnsxr0000gn/T/.tmpAolWXa",
    ),
    skip_auditwheel: false,
    zig: false,
    universal2: false,
    cargo: CargoOptions {
        quiet: false,
        jobs: None,
        profile: None,
        features: [],
        all_features: false,
        no_default_features: false,
        target: None,
        target_dir: None,
        manifest_path: None,
        ignore_rust_version: false,
        verbose: 0,
        color: None,
        frozen: false,
        locked: false,
        offline: false,
        config: [],
        unstable_flags: [],
        timings: None,
        future_incompat_report: false,
        args: [],
    },
}

Copy link
Member

@messense messense Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing seems wrong, I can't reproduce this issue, so you have to debug on your own.

Try to track down where did the target triple changed to x86_64.

target_triple = Some("x86_64-apple-darwin".to_string());
} else if platform.contains("arm64") && target.target_arch() != Arch::Aarch64 {
} else if platform.contains("arm64") && target.target_arch() == Arch::Aarch64 {
target_triple = Some("aarch64-apple-darwin".to_string());
}
}
Expand All @@ -48,7 +48,7 @@ pub fn develop(
// Store wheel in a unique location so we don't get name clashes with parallel runs
let wheel_dir = TempDir::new().context("Failed to create temporary directory")?;

let build_options = BuildOptions {
let mut build_options = BuildOptions {
platform_tag: vec![PlatformTag::Linux],
interpreter: vec![python.clone()],
find_interpreter: false,
Expand All @@ -63,6 +63,11 @@ pub fn develop(
},
};

// We should respect user input.
if cargo_options.target.is_some() {
build_options.cargo.target = cargo_options.target;
dzvon marked this conversation as resolved.
Show resolved Hide resolved
}

let build_context = build_options.into_build_context(release, strip, true)?;

let interpreter = PythonInterpreter::check_executable(&python, &target, &build_context.bridge)?
Expand Down