Skip to content

Commit

Permalink
Enable --crate-type cdylib on Rust 1.64.0
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Aug 16, 2022
1 parent 56d7cc8 commit b415fb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

* Allow user to override default Emscripten settings in [#1059](https://github.com/PyO3/maturin/pull/1059)
* Enable `--crate-type cdylib` on Rust 1.64.0 in [#1060](https://github.com/PyO3/maturin/pull/1060)

## [0.13.2] - 2022-08-14

Expand Down
15 changes: 5 additions & 10 deletions src/compile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::build_context::BridgeModel;
use crate::target::RUST_1_64_0;
use crate::{BuildContext, PlatformTag, PythonInterpreter, Target};
use anyhow::{anyhow, bail, Context, Result};
use fat_macho::FatWriter;
Expand Down Expand Up @@ -170,16 +171,10 @@ fn compile_target(
.iter()
.any(|k| LIB_CRATE_TYPES.contains(&k.as_str()))
{
if let Ok(channel) = rustc_version::version_meta().map(|x| x.channel) {
if matches!(
channel,
rustc_version::Channel::Nightly | rustc_version::Channel::Dev
) {
cargo_rustc
.unstable_flags
.push("unstable-options".to_string());
cargo_rustc.crate_type = vec!["cdylib".to_string()];
}
// `--crate-type` is stable since Rust 1.64.0
// See https://github.com/rust-lang/cargo/pull/10838
if target.rustc_version.semver >= RUST_1_64_0 {
cargo_rustc.crate_type = vec!["cdylib".to_string()];
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use std::path::PathBuf;
use std::str;
use target_lexicon::{Environment, Triple};

pub(crate) const RUST_1_64_0: semver::Version = semver::Version::new(1, 64, 0);

/// All supported operating system
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Deserialize)]
#[serde(rename_all = "lowercase")]
Expand Down Expand Up @@ -414,10 +416,9 @@ impl Target {
PlatformTag::manylinux2014()
}
Arch::X86 | Arch::X86_64 => {
let rust_1_64 = semver::Version::new(1, 64, 0);
// rustc 1.64.0 bumps glibc requirement to 2.17
// see https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html
if self.rustc_version.semver >= rust_1_64 {
if self.rustc_version.semver >= RUST_1_64_0 {
PlatformTag::manylinux2014()
} else {
PlatformTag::manylinux2010()
Expand Down

0 comments on commit b415fb2

Please sign in to comment.