Skip to content

Commit 7b36649

Browse files
committed
rust: ban ___darwin_check_fd_set_overflow on Python 3.8
By changing the SDK in the previous commit, we stopped the introduction of this symbol on Python 3.8. Since it causes problems for end users, lets ban its use in the validator to ensure it doesn't slip back in without notice. We'll consider Python 3.9 separately.
1 parent fd166a9 commit 7b36649

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,15 @@ const MACHO_BANNED_SYMBOLS_NON_AARCH64: &[&str] = &[
351351
"_preadv", "_pwritev",
352352
];
353353

354+
const MACHO_BANNED_SYMBOLS_NON_AARCH64_PYTHON_38: &[&str] = &[
355+
// This symbol was improperly introduced into the 10.15 SDK and wasn't
356+
// guarded by availability checks. Users in the wild have problems linking
357+
// against a modern macOS SDK. So to keep compatibility with the non-buggy
358+
// 10.15 SDK, we prevent the presence of this symbol.
359+
// See https://github.com/indygreg/PyOxidizer/issues/373 for more.
360+
"___darwin_check_fd_set_overflow",
361+
];
362+
354363
static WANTED_WINDOWS_STATIC_PATHS: Lazy<BTreeSet<PathBuf>> = Lazy::new(|| {
355364
[
356365
PathBuf::from("python/build/lib/libffi.lib"),
@@ -463,6 +472,7 @@ fn validate_elf(
463472
}
464473

465474
fn validate_macho(
475+
python_major_minor: &str,
466476
target_triple: &str,
467477
path: &Path,
468478
macho: &goblin::mach::MachO,
@@ -526,7 +536,9 @@ fn validate_macho(
526536
let (name, _) = symbol?;
527537

528538
if target_triple != "aarch64-apple-darwin"
529-
&& MACHO_BANNED_SYMBOLS_NON_AARCH64.contains(&name)
539+
&& (MACHO_BANNED_SYMBOLS_NON_AARCH64.contains(&name)
540+
|| (python_major_minor == "3.8"
541+
&& MACHO_BANNED_SYMBOLS_NON_AARCH64_PYTHON_38.contains(&name)))
530542
{
531543
errors.push(format!(
532544
"{} references unallowed symbol {}",
@@ -576,7 +588,7 @@ fn validate_possible_object_file(
576588
goblin::Object::Mach(mach) => match mach {
577589
goblin::mach::Mach::Binary(macho) => {
578590
let (local_errors, local_seen_dylibs) =
579-
validate_macho(triple, path.as_ref(), &macho, &data)?;
591+
validate_macho(python_major_minor, triple, path.as_ref(), &macho, &data)?;
580592

581593
errors.extend(local_errors);
582594
seen_dylibs.extend(local_seen_dylibs);

0 commit comments

Comments
 (0)