build: not cross-compiling when musl from gnu

This commit is contained in:
David Hewitt 2020-11-10 08:21:11 +00:00
parent 3b3ba4e3ab
commit cfa586c034
2 changed files with 27 additions and 6 deletions

View File

@ -6,8 +6,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
### Fixed
- Fix missing field in `PyCodeObject` struct (`co_posonlyargcount`) - caused invalid access to other fields in Python >3.7. [#1260](https://github.com/PyO3/pyo3/pull/1260)
### Packaging ### Packaging
- Drop support for Python 3.5 (as it is now end-of-life). [#1250](https://github.com/PyO3/pyo3/pull/1250) - Drop support for Python 3.5 (as it is now end-of-life). [#1250](https://github.com/PyO3/pyo3/pull/1250)
@ -27,6 +25,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Remove deprecated ffi definitions `PyUnicode_AsUnicodeCopy`, `PyUnicode_GetMax`, `_Py_CheckRecursionLimit`, `PyObject_AsCharBuffer`, `PyObject_AsReadBuffer`, `PyObject_CheckReadBuffer` and `PyObject_AsWriteBuffer`, which will be removed in Python 3.10. [#1217](https://github.com/PyO3/pyo3/pull/1217) - Remove deprecated ffi definitions `PyUnicode_AsUnicodeCopy`, `PyUnicode_GetMax`, `_Py_CheckRecursionLimit`, `PyObject_AsCharBuffer`, `PyObject_AsReadBuffer`, `PyObject_CheckReadBuffer` and `PyObject_AsWriteBuffer`, which will be removed in Python 3.10. [#1217](https://github.com/PyO3/pyo3/pull/1217)
- Remove unused `python3` feature. [#1235](https://github.com/PyO3/pyo3/pull/1235) - Remove unused `python3` feature. [#1235](https://github.com/PyO3/pyo3/pull/1235)
### Fixed
- Fix missing field in `PyCodeObject` struct (`co_posonlyargcount`) - caused invalid access to other fields in Python >3.7. [#1260](https://github.com/PyO3/pyo3/pull/1260)
- Fix building for `x86_64-unknown-linux-musl` target from `x86_65-unknown-linux-gnu` host. [#1267](https://github.com/PyO3/pyo3/pull/1267)
## [0.12.3] - 2020-10-12 ## [0.12.3] - 2020-10-12
### Fixed ### Fixed
- Fix support for Rust versions 1.39 to 1.44, broken by an incorrect internal update to paste 1.0 which was done in PyO3 0.12.2. [#1234](https://github.com/PyO3/pyo3/pull/1234) - Fix support for Rust versions 1.39 to 1.44, broken by an incorrect internal update to paste 1.0 which was done in PyO3 0.12.2. [#1234](https://github.com/PyO3/pyo3/pull/1234)

View File

@ -150,15 +150,34 @@ impl CrossCompileConfig {
fn cross_compiling() -> Result<Option<CrossCompileConfig>> { fn cross_compiling() -> Result<Option<CrossCompileConfig>> {
let target = env::var("TARGET")?; let target = env::var("TARGET")?;
let host = env::var("HOST")?; let host = env::var("HOST")?;
if target == host || (target == "i686-pc-windows-msvc" && host == "x86_64-pc-windows-msvc") { if target == host {
// Not cross-compiling
return Ok(None);
}
if target == "i686-pc-windows-msvc" && host == "x86_64-pc-windows-msvc" {
// Not cross-compiling to compile for 32-bit Python from windows 64-bit
return Ok(None);
}
if host.starts_with(&format!(
"{}-{}-{}",
env::var("CARGO_CFG_TARGET_ARCH")?,
env::var("CARGO_CFG_TARGET_VENDOR")?,
env::var("CARGO_CFG_TARGET_OS")?
)) {
// Not cross-compiling if arch-vendor-os is all the same
// e.g. x86_64-unknown-linux-musl on x86_64-unknown-linux-gnu host
return Ok(None); return Ok(None);
} }
if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" { if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" {
Ok(Some(CrossCompileConfig::both()?)) // Windows cross-compile uses both header includes and sysconfig
} else { return Ok(Some(CrossCompileConfig::both()?));
Ok(Some(CrossCompileConfig::lib_only()?))
} }
// Cross-compiling on any other platform
Ok(Some(CrossCompileConfig::lib_only()?))
} }
/// A list of python interpreter compile-time preprocessor defines that /// A list of python interpreter compile-time preprocessor defines that