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

error: invalid instruction cargo:rustc-cdylib-link-arg from build script of pyo3 v0.14.1 #1719

Closed
Hywan opened this issue Jul 6, 2021 · 15 comments · Fixed by #1755
Closed

Comments

@Hywan
Copy link
Contributor

Hywan commented Jul 6, 2021

🐛 Bug Reports

I try to compile wasmer-python with pyo3 0.14.1. It uses pyo3 to create a Python extension with Rust. Whe compiling, I'm facing this error:

error: invalid instruction `cargo:rustc-cdylib-link-arg` from build script of `pyo3 v0.14.1`
The package pyo3 v0.14.1 does not have a cdylib target.

🌍 Environment

  • macOS 11.1 aarch64
  • Python 3.9.4 from Homebrew
  • Rust 1.55 nightly
  • PyO3 0.14.1

💥 Reproducing

When compiling examples/word-count/ with cargo build --release, we get a warning:

warning: cargo:rustc-cdylib-link-arg was specified in the build script of pyo3 v0.14.1 (/Users/hwhost/Development/pyo3/pyo3), but that package does not contain a cdylib target

Allowing this was an unintended change in the 1.50 release, and may become an error in the future. For more information, see <https://github.com/rust-lang/cargo/issues/9562>.
warning: cargo:rustc-cdylib-link-arg was specified in the build script of pyo3 v0.14.1 (/Users/hwhost/Development/pyo3/pyo3), but that package does not contain a cdylib target

Allowing this was an unintended change in the 1.50 release, and may become an error in the future. For more information, see <https://github.com/rust-lang/cargo/issues/9562>.

In my project (wasmer-python), it's an error.

@Hywan
Copy link
Contributor Author

Hywan commented Jul 6, 2021

To conclude on a more positive aspect: PyO3 is awesome, and you're all doing an amazing job!

@davidhewitt
Copy link
Member

Ah, that's a shame. This is #1539, but I guess that rust-lang/cargo#9562 is saying that was an unintended change.

This probably has implications for #1123, which is using similar cargo flags.

I wonder if we can provide some hooks in the pyo3-build-config crate which work around this.

@Hywan do I understand correctly that this is a blocking error for your attempting to upgrade? If so, we should probably figure out an appropriate patch fix...

@Hywan
Copy link
Contributor Author

Hywan commented Jul 6, 2021

Yeah it's an error that forbids me to update.

I know it comes from the build.rs script where you check only against macos without checking the architecture. The linker arguments are only required for x86_64-darwin-apple, they are not required for aarch64-darwin-apple. I didn't want to put you on the wrong path in my description, but that was my feeling. Also, it's great to handle this in the build.rs script rather than in .cargo/config for sure.

@Hywan
Copy link
Contributor Author

Hywan commented Jul 6, 2021

#1123 seems a good PR to fix the problem. Let me know, I can try anything to help you :-).

@davidhewitt
Copy link
Member

The linker arguments are only required for x86_64-darwin-apple, they are not required for aarch64-darwin-apple

Are you sure about this? Our experience in #1330 seemed to suggest otherwise...

@Hywan
Copy link
Contributor Author

Hywan commented Jul 6, 2021

Prior to pyo3 0.14, I had a .cargo/config file only for x86_64-apple-darwin, nothing for aarch64-apple-darwin and everything was working like a charm.

Don't ask me why though, because it's counter-intuitive.

@davidhewitt
Copy link
Member

Could it be related to building two separate targets versus a universal binary?

@Hywan
Copy link
Contributor Author

Hywan commented Jul 6, 2021

I've no idea. Maybe the user was running Python behind Rosetta?

@Hywan
Copy link
Contributor Author

Hywan commented Jul 13, 2021

Any news on that front :-)?

@davidhewitt
Copy link
Member

No progress yet, sorry. I'm kinda unsure what to do. I guess the reality is that we can't automatically apply the macOS build configuration, so we might want to add an API along the lines of pyo3_build_config::add_macos_configuration() which checks the target and adds the flags if running on macOS. Users would have to add this in their own build script, but at least it's better than requiring cargo configs?

@Hywan
Copy link
Contributor Author

Hywan commented Jul 18, 2021

I think it's better than an error, so yeah :-)

@davidhewitt
Copy link
Member

davidhewitt commented Jul 22, 2021

Just to keep everyone in the loop, as reverting this will involve writing a fair bit of new documentation, I'm planning to do this as part of a big update to the README at the weekend.

@davidhewitt
Copy link
Member

FYI PyO3 0.14.2 is planned to go live tomorrow. #1760

@Hywan
Copy link
Contributor Author

Hywan commented Aug 12, 2021

Thanks!

@Hywan
Copy link
Contributor Author

Hywan commented Aug 12, 2021

I've updated to the latest Rust nighly (rustc 1.56.0-nightly (ccffcafd5 2021-08-11)), and pyo3_build_config::add_extension_module_link_args() is working on macOS M1.

Note: It doesn't mean it was a bug in rustc. I didn't dig into that. But, eh, it works!

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

Successfully merging a pull request may close this issue.

2 participants