Skip to content

Commit

Permalink
Add opt-in set_soname feature
Browse files Browse the repository at this point in the history
This allows correctly setting the `soname` for shared libraries on
Linux. This is useful for similar reasons to the macOS
`set_install_name` feature.

Fixes bazelbuild#18798

Closes bazelbuild#23839.

PiperOrigin-RevId: 681847016
Change-Id: I2d3584c9d91564b41c2501e6664e2956f9760e41
  • Loading branch information
keith committed Oct 3, 2024
1 parent 3d6de3c commit 5ca2c1c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tools/cpp/unix_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,25 @@ def _impl(ctx):
),
],
)
set_install_name_feature = None
set_install_name_feature = feature(
name = "set_soname",
flag_sets = [
flag_set(
actions = [
ACTION_NAMES.cpp_link_dynamic_library,
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
],
flag_groups = [
flag_group(
flags = [
"-Wl,-soname,%{runtime_solib_name}",
],
expand_if_available = "runtime_solib_name",
),
],
),
],
)
else:
runtime_library_search_directories_feature = feature(
name = "runtime_library_search_directories",
Expand Down Expand Up @@ -1576,6 +1594,7 @@ def _impl(ctx):
unfiltered_compile_flags_feature,
treat_warnings_as_errors_feature,
archive_param_file_feature,
set_install_name_feature,
] + layering_check_features(ctx.attr.compiler, ctx.attr.extra_flags_per_feature, is_macos = False)
else:
# macOS artifact name patterns differ from the defaults only for dynamic
Expand Down

0 comments on commit 5ca2c1c

Please sign in to comment.