Skip to content

Commit ec55533

Browse files
Googlercopybara-github
authored andcommitted
Remove support for "nodeps" dynamic libraries on Apple platforms.
Any such usage was only accidentally working due to -undefined dynamic_lookup. That flag only works on Darwin (macOS) at all. But even there, TLS can cause undefined symbols with these "nodeps" libraries. Fundamentally, Mach-O's two-level namespacing makes this infeasible. #4341 Closes #4341. PiperOrigin-RevId: 352002776
1 parent bbeb1da commit ec55533

5 files changed

Lines changed: 20 additions & 12 deletions

File tree

src/test/shell/bazel/cc_integration_test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,10 @@ EOF
660660
}
661661

662662
function test_aspect_accessing_args_link_action_with_tree_artifact() {
663+
# This test assumes the presence of "nodeps" dynamic libraries, which do not
664+
# function on Apple platforms.
665+
[ "$PLATFORM" != "darwin" ] || return 0
666+
663667
local package="${FUNCNAME[0]}"
664668
mkdir -p "${package}"
665669
cat > "${package}/makes_tree_artifacts.sh" <<EOF
@@ -739,6 +743,10 @@ EOF
739743
}
740744

741745
function test_directory_arg_compile_action() {
746+
# This test assumes the presence of "nodeps" dynamic libraries, which do not
747+
# function on Apple platforms.
748+
[ "$PLATFORM" != "darwin" ] || return 0
749+
742750
local package="${FUNCNAME[0]}"
743751
mkdir -p "${package}"
744752

src/test/shell/bazel/tags_propagation_native_test.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,16 @@ EOF
5555
assert_contains "local:" output1
5656
assert_contains "no-cache:" output1
5757
assert_contains "no-remote:" output1
58-
59-
bazel aquery --experimental_allow_tags_propagation 'mnemonic("CppLink", outputs(".*/libtest.so", //test:test))' > output1 2> $TEST_log \
60-
|| fail "should have generated output successfully"
61-
62-
assert_contains "ExecutionInfo: {" output1
63-
assert_contains "local:" output1
64-
assert_contains "no-cache:" output1
65-
assert_contains "no-remote:" output1
58+
if [ "${PLATFORM}" != "darwin" ]; then
59+
# Darwin does not support implicit "nodeps" shared libraries.
60+
bazel aquery --experimental_allow_tags_propagation 'mnemonic("CppLink", outputs(".*/libtest.so", //test:test))' > output1 2> $TEST_log \
61+
|| fail "should have generated output successfully"
62+
63+
assert_contains "ExecutionInfo: {" output1
64+
assert_contains "local:" output1
65+
assert_contains "no-cache:" output1
66+
assert_contains "no-remote:" output1
67+
fi
6668
}
6769

6870
function test_cc_binary_tags_propagated() {

src/test/shell/integration/configured_query_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ EOF
11221122

11231123
if "$is_windows"; then
11241124
assert_contains "cclib.lib" output
1125+
elif is_darwin; then
1126+
assert_contains "libcclib.a" output
11251127
else
11261128
assert_contains "libcclib.a" output
11271129
assert_contains "libcclib.so" output

tools/cpp/cc_toolchain_config.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,6 @@ def _impl(ctx):
11591159
features = [
11601160
default_compile_flags_feature,
11611161
default_link_flags_feature,
1162-
supports_dynamic_linker_feature,
11631162
supports_pic_feature,
11641163
objcopy_embed_flags_feature,
11651164
dbg_feature,

tools/osx/crosstool/cc_toolchain_config.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4734,8 +4734,6 @@ def _impl(ctx):
47344734
],
47354735
)
47364736

4737-
supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
4738-
47394737
objc_actions_feature = feature(
47404738
name = "objc_actions",
47414739
implies = [
@@ -6243,7 +6241,6 @@ def _impl(ctx):
62436241
linker_param_file_feature,
62446242
compiler_input_flags_feature,
62456243
compiler_output_flags_feature,
6246-
supports_dynamic_linker_feature,
62476244
objcopy_embed_flags_feature,
62486245
dynamic_linking_mode_feature,
62496246
set_install_name,

0 commit comments

Comments
 (0)