Skip to content

Commit 3d6e597

Browse files
committed
unix: stop using pthread_yield()
This symbol was removed from glibc 2.34. Its replacement (sched_yield()) appears to have been available forever. So we disable the usage of pthread_yield(). We also add verification for ELF banned symbols.
1 parent b3fc971 commit 3d6e597

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

cpython-unix/build-bdb.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@ tar -xf db-${BDB_VERSION}.tar.gz
1313

1414
pushd db-${BDB_VERSION}/build_unix
1515

16+
CONFIGURE_FLAGS="--enable-dbm --disable-shared"
17+
18+
# configure looks for pthread_yield(), which was dropped from glibc 2.34.
19+
# Its replacement is sched_yield(). Fortunately, bdb's source code will fall
20+
# back to sched_yield() if pthread_yield() isn't available. So we just lie
21+
# to configure and tell it pthread_yield() isn't available.
22+
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} ac_cv_func_pthread_yield=no"
23+
1624
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ../dist/configure \
1725
--build=${BUILD_TRIPLE} \
1826
--host=${TARGET_TRIPLE} \
1927
--prefix=/tools/deps \
20-
--enable-dbm \
21-
--disable-shared
28+
${CONFIGURE_FLAGS}
2229

2330
make -j ${NUM_CPUS}
2431
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out

src/validation.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ static PLATFORM_TAG_BY_TRIPLE: Lazy<HashMap<&'static str, &'static str>> = Lazy:
362362
.collect()
363363
});
364364

365+
const ELF_BANNED_SYMBOLS: &[&str] = &[
366+
// Deprecated as of glibc 2.34 in favor of sched_yield.
367+
"pthread_yield",
368+
];
369+
365370
/// Symbols that we don't want to appear in mach-o binaries.
366371
const MACHO_BANNED_SYMBOLS_NON_AARCH64: &[&str] = &[
367372
// _readv and _pwritev are introduced when building with the macOS 11 SDK.
@@ -524,6 +529,14 @@ fn validate_elf(
524529
undefined_symbols.sort();
525530

526531
for symbol in undefined_symbols {
532+
if ELF_BANNED_SYMBOLS.contains(&symbol.symbol.as_str()) {
533+
errors.push(format!(
534+
"{} defines banned ELF symbol {}",
535+
path.display(),
536+
symbol.symbol,
537+
));
538+
}
539+
527540
if let Some(version) = &symbol.version {
528541
let parts: Vec<&str> = version.splitn(2, '_').collect();
529542

0 commit comments

Comments
 (0)