summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-02-14 18:35:48 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2024-02-15 13:11:33 +0100
commit09f90fac9092de13a71723f849794474831fd678 (patch)
tree2b300d76bb1ad7133fddb2fe72face269bbaeec6
parentbda3dabe37fdde648f90ce5aa4b20d7336570cf0 (diff)
downloadjustbuild-09f90fac9092de13a71723f849794474831fd678.tar.gz
Replace glibc sync stubs when linking pthreads
... glibc provides synchronization stubs for single-threaded environments as weak symobls. When linking pthreads, these weak symbols must be replaced by the strong symbols provided by the pthread library. For dynamically linking pthreads, this is done automatically. However, to support this for static linking, we must ensure to link the whole archive.
-rw-r--r--etc/import/TARGETS.boringssl3
-rw-r--r--etc/import/TARGETS.re23
-rw-r--r--etc/import/absl/base/TARGETS.absl4
-rw-r--r--etc/import/absl/random/TARGETS.absl3
-rw-r--r--etc/import/absl/synchronization/TARGETS.absl2
-rw-r--r--etc/import/src/TARGETS.archive2
-rw-r--r--etc/import/src/TARGETS.curl6
-rw-r--r--etc/import/src/compiler/TARGETS.grpc3
-rw-r--r--etc/import/src/util/TARGETS.git23
-rw-r--r--src/buildtool/execution_api/execution_service/TARGETS3
-rw-r--r--src/buildtool/logging/TARGETS3
-rw-r--r--src/buildtool/multithreading/TARGETS3
12 files changed, 25 insertions, 13 deletions
diff --git a/etc/import/TARGETS.boringssl b/etc/import/TARGETS.boringssl
index 2c95bc0f..158b3bc5 100644
--- a/etc/import/TARGETS.boringssl
+++ b/etc/import/TARGETS.boringssl
@@ -58,7 +58,8 @@
, "private-hdrs": ["fips_fragments", "crypto_internal_headers"]
, "srcs": ["crypto_sources", "crypto_sources_asm"]
, "pure C": ["YES"]
- , "private-ldflags": ["-pthread"]
+ , "private-ldflags":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
, "ssl-lib":
{ "type": ["@", "rules", "CC", "library"]
diff --git a/etc/import/TARGETS.re2 b/etc/import/TARGETS.re2
index 83f12755..459c597c 100644
--- a/etc/import/TARGETS.re2
+++ b/etc/import/TARGETS.re2
@@ -66,6 +66,7 @@
]
, "hdrs":
["re2/filtered_re2.h", "re2/re2.h", "re2/set.h", "re2/stringpiece.h"]
- , "private-ldflags": ["-pthread"]
+ , "private-ldflags":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
}
diff --git a/etc/import/absl/base/TARGETS.absl b/etc/import/absl/base/TARGETS.absl
index 22b408c5..c1a7713b 100644
--- a/etc/import/absl/base/TARGETS.absl
+++ b/etc/import/absl/base/TARGETS.absl
@@ -47,7 +47,7 @@
, "private-ldflags":
{ "type": "++"
, "$1":
- [ ["-pthread"]
+ [ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
, { "type": "case*"
, "expr":
{ "type": "lookup"
@@ -367,7 +367,7 @@
, "private-ldflags":
{ "type": "++"
, "$1":
- [ ["-pthread"]
+ [ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
, { "type": "case"
, "expr":
{ "type": "var"
diff --git a/etc/import/absl/random/TARGETS.absl b/etc/import/absl/random/TARGETS.absl
index db5b83ee..98f4c1c4 100644
--- a/etc/import/absl/random/TARGETS.absl
+++ b/etc/import/absl/random/TARGETS.absl
@@ -123,7 +123,8 @@
, "stage": ["absl", "random"]
, "hdrs": ["internal/pool_urbg.h"]
, "srcs": ["internal/pool_urbg.cc"]
- , "private-ldflags": ["-pthread"]
+ , "private-ldflags":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
, "deps":
[ "internal_randen"
, "internal_seed_material"
diff --git a/etc/import/absl/synchronization/TARGETS.absl b/etc/import/absl/synchronization/TARGETS.absl
index 84a1a964..09bb1700 100644
--- a/etc/import/absl/synchronization/TARGETS.absl
+++ b/etc/import/absl/synchronization/TARGETS.absl
@@ -45,7 +45,7 @@
, "private-ldflags":
{ "type": "++"
, "$1":
- [ ["-pthread"]
+ [ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
, { "type": "case"
, "expr":
{ "type": "var"
diff --git a/etc/import/src/TARGETS.archive b/etc/import/src/TARGETS.archive
index b71c4f89..a2ffdfa7 100644
--- a/etc/import/src/TARGETS.archive
+++ b/etc/import/src/TARGETS.archive
@@ -6,7 +6,7 @@
{ "type": "if"
, "cond":
{"type": "==", "$1": {"type": "var", "name": "OS"}, "$2": "linux"}
- , "then": ["-pthread"]
+ , "then": ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
}
, "archive_crypt":
diff --git a/etc/import/src/TARGETS.curl b/etc/import/src/TARGETS.curl
index 29fd9706..60164c0e 100644
--- a/etc/import/src/TARGETS.curl
+++ b/etc/import/src/TARGETS.curl
@@ -57,7 +57,11 @@
, "then":
{ "type": "case*"
, "expr": {"type": "var", "name": "OS"}
- , "case": [["linux", ["-pthread"]]]
+ , "case":
+ [ [ "linux"
+ , ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
+ ]
+ ]
}
}
}
diff --git a/etc/import/src/compiler/TARGETS.grpc b/etc/import/src/compiler/TARGETS.grpc
index 13538d46..d9d5fa57 100644
--- a/etc/import/src/compiler/TARGETS.grpc
+++ b/etc/import/src/compiler/TARGETS.grpc
@@ -54,6 +54,7 @@
, "name": ["grpc_cpp_plugin"]
, "srcs": ["cpp_plugin.cc"]
, "private-deps": ["grpc_plugin_support"]
- , "private-ldflags": ["-pthread"]
+ , "private-ldflags":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
}
diff --git a/etc/import/src/util/TARGETS.git2 b/etc/import/src/util/TARGETS.git2
index cac75649..cca52197 100644
--- a/etc/import/src/util/TARGETS.git2
+++ b/etc/import/src/util/TARGETS.git2
@@ -82,7 +82,8 @@
, "$1":
[ { "type": "if"
, "cond": {"type": "var", "name": "USE_THREADS"}
- , "then": ["-pthread"]
+ , "then":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
, { "type": "case"
, "expr": {"type": "var", "name": "OS"}
diff --git a/src/buildtool/execution_api/execution_service/TARGETS b/src/buildtool/execution_api/execution_service/TARGETS
index 2d8492c6..6dfb45c2 100644
--- a/src/buildtool/execution_api/execution_service/TARGETS
+++ b/src/buildtool/execution_api/execution_service/TARGETS
@@ -19,7 +19,8 @@
, "operation_cache"
, ["src/utils/cpp", "verify_hash"]
]
- , "private-ldflags": ["-pthread"]
+ , "private-ldflags":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
, "ac_server":
{ "type": ["@", "rules", "CC", "library"]
diff --git a/src/buildtool/logging/TARGETS b/src/buildtool/logging/TARGETS
index a4871482..15f12cea 100644
--- a/src/buildtool/logging/TARGETS
+++ b/src/buildtool/logging/TARGETS
@@ -17,6 +17,7 @@
]
, "deps": ["log_level", ["@", "fmt", "", "fmt"], ["@", "gsl", "", "gsl"]]
, "stage": ["src", "buildtool", "logging"]
- , "private-ldflags": ["-pthread"]
+ , "private-ldflags":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
}
diff --git a/src/buildtool/multithreading/TARGETS b/src/buildtool/multithreading/TARGETS
index 2d758589..e750c943 100644
--- a/src/buildtool/multithreading/TARGETS
+++ b/src/buildtool/multithreading/TARGETS
@@ -3,7 +3,8 @@
, "name": ["task"]
, "hdrs": ["task.hpp"]
, "stage": ["src", "buildtool", "multithreading"]
- , "private-ldflags": ["-pthread"]
+ , "private-ldflags":
+ ["-pthread", "-Wl,--whole-archive,-lpthread,--no-whole-archive"]
}
, "notification_queue":
{ "type": ["@", "rules", "CC", "library"]