From 877e08a73c8ffd12a7ad71fc96f27c6e4e813886 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 17 Mar 2025 09:00:24 -0500 Subject: [PATCH 1/2] Replace `CXX` entries with `gnu-g++` in sysconfig Closes https://github.com/astral-sh/uv/issues/12207 --- crates/uv-python/src/sysconfig/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/uv-python/src/sysconfig/mod.rs b/crates/uv-python/src/sysconfig/mod.rs index 52401ed158de4..b93fc7b352d30 100644 --- a/crates/uv-python/src/sysconfig/mod.rs +++ b/crates/uv-python/src/sysconfig/mod.rs @@ -89,6 +89,15 @@ static DEFAULT_VARIABLE_UPDATES: LazyLock> = to: "c++".to_string(), }, ), + ( + "CXX".to_string(), + ReplacementEntry { + mode: ReplacementMode::Partial { + from: "/usr/bin/x86_64-linux-gnu-g++".to_string(), + }, + to: "c++".to_string(), + }, + ), ( "BLDSHARED".to_string(), ReplacementEntry { From 20d75064d955947ba9853f9c73aaab3d6b007e60 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 17 Mar 2025 09:04:24 -0500 Subject: [PATCH 2/2] Update `CC` too --- crates/uv-python/src/sysconfig/mod.rs | 38 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/crates/uv-python/src/sysconfig/mod.rs b/crates/uv-python/src/sysconfig/mod.rs index b93fc7b352d30..9b22c29b3340b 100644 --- a/crates/uv-python/src/sysconfig/mod.rs +++ b/crates/uv-python/src/sysconfig/mod.rs @@ -80,6 +80,15 @@ static DEFAULT_VARIABLE_UPDATES: LazyLock> = to: "cc".to_string(), }, ), + ( + "CC".to_string(), + ReplacementEntry { + mode: ReplacementMode::Partial { + from: "/usr/bin/aarch64-linux-gnu-gcc".to_string(), + }, + to: "cc".to_string(), + }, + ), ( "CXX".to_string(), ReplacementEntry { @@ -443,15 +452,36 @@ mod tests { let real_prefix = Path::new("/real/prefix"); let data = patch_sysconfigdata(sysconfigdata, real_prefix); - insta::assert_snapshot!(data.to_string_pretty()?, @r###" + insta::assert_snapshot!(data.to_string_pretty()?, @r##" # system configuration generated and used by the sysconfig module build_time_vars = { "AR": "ar", - "CC": "cc -pthread", - "CXX": "c++ -pthread", + "CC": "clang -pthread", + "CXX": "clang++ -pthread", "PYTHON_BUILD_STANDALONE": 1 } - "###); + "##); + + // Cross-compiles use GNU + let sysconfigdata = [ + ("CC", "/usr/bin/aarch64-linux-gnu-gcc"), + ("CXX", "/usr/bin/x86_64-linux-gnu-g++"), + ] + .into_iter() + .map(|(k, v)| (k.to_string(), Value::String(v.to_string()))) + .collect::(); + + let real_prefix = Path::new("/real/prefix"); + let data = patch_sysconfigdata(sysconfigdata, real_prefix); + + insta::assert_snapshot!(data.to_string_pretty()?, @r##" + # system configuration generated and used by the sysconfig module + build_time_vars = { + "CC": "cc", + "CXX": "c++", + "PYTHON_BUILD_STANDALONE": 1 + } + "##); Ok(()) }