aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2025-01-24 20:03:43 +0300
committerthegeorg <thegeorg@yandex-team.com>2025-01-24 21:39:05 +0300
commitcce7da50df521254dc82ca9e8dacf5da131ff487 (patch)
tree753ecfab38ae6014f55742c6a3367dfdd27afc6e
parent19ef56ab1ad568c9c4677fc22a042f84403053eb (diff)
downloadydb-cce7da50df521254dc82ca9e8dacf5da131ff487.tar.gz
Clarify conditions to link against -lpthread
commit_hash:d1591aff30e1348f17b1d038f2ed92d5537de9cb
-rw-r--r--build/conf/linkers/ld.conf22
-rw-r--r--contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym4
-rw-r--r--contrib/libs/cxxsupp/libcxx/ya.make4
3 files changed, 16 insertions, 14 deletions
diff --git a/build/conf/linkers/ld.conf b/build/conf/linkers/ld.conf
index 28d14f24c0..54cd9b6239 100644
--- a/build/conf/linkers/ld.conf
+++ b/build/conf/linkers/ld.conf
@@ -82,11 +82,6 @@ when ($USEMPROF == "yes" || $USE_MPROF == "yes") {
C_SYSTEM_LIBRARIES_INTERCEPT+=-ldmalloc
}
-_LD_THREAD_LIBRARY=
-when ($OS_LINUX == "yes" || $OS_DARWIN == "yes") {
- _LD_THREAD_LIBRARY=-lpthread
-}
-
_LD_USE_STDLIB=
when ($_BUILD_COVERAGE == "yes" || $GCOV_COVERAGE == "yes" || $CLANG_COVERAGE == "yes" || $_BUILD_SANITIZED == "yes") {
_LD_USE_STDLIB=
@@ -105,13 +100,28 @@ elsewhen ($OS_LINUX == "yes" || $OS_DARWIN == "yes" || $OS_IOS == "yes") {
_LD_USE_STDLIB=-nodefaultlibs
}
-_C_SYSTEM_LIBRARIES=$_LD_USE_STDLIB $_LD_THREAD_LIBRARY -lc
+when ($OS_LINUX == "yes" && $MUSL != "yes") {
+ # NB:
+ # glibc merged pthread into libc.so as of 2.34 / Ubuntu 22.04, see
+ # https://developers.redhat.com/articles/2021/12/17/why-glibc-234-removed-libpthread
+ #
+ # In macOS and iOS libpthread points to libSystem alread (just as libc.tbd does):
+ # $ file libpthread.tbd
+ # libpthread.tbd: symbolic link to libSystem.tbd
+ #
+ # Android does not provide libpthread at all.
+ # Once we will be building against glibc=2.34, we might simply remove -lpthread
+ _C_SYSTEM_LIBRARIES=$_LD_USE_STDLIB -lpthread -lc
+}
when ($MUSL == "yes") {
_C_SYSTEM_LIBRARIES=-nostdlib
}
when ($OS_EMSCRIPTEN == "yes") {
_C_SYSTEM_LIBRARIES=-nostdlib
}
+when ($OS_ANDROID == "yes") {
+ _C_SYSTEM_LIBRARIES=$_LD_USE_STDLIB -lc
+}
C_SYSTEM_LIBRARIES=$_C_SYSTEM_LIBRARIES
LD_EXPORT_ALL_DYNAMIC_SYMBOLS_FLAG=
diff --git a/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym b/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym
index 0f0822ba8c..1ee5328ff5 100644
--- a/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym
+++ b/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym
@@ -157,10 +157,6 @@ ELSE()
)
ENDIF()
-IF (OS_LINUX)
- EXTRALIBS(-lpthread)
-ENDIF()
-
IF (CLANG)
CXXFLAGS(GLOBAL -nostdinc++)
ENDIF()
diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make
index da13447b1a..785b2cf07f 100644
--- a/contrib/libs/cxxsupp/libcxx/ya.make
+++ b/contrib/libs/cxxsupp/libcxx/ya.make
@@ -74,10 +74,6 @@ ELSE()
CXXFLAGS(-nostdinc++)
ENDIF()
-IF (OS_LINUX)
- EXTRALIBS(-lpthread)
-ENDIF()
-
IF (CLANG)
CXXFLAGS(GLOBAL -nostdinc++)
ENDIF()