Skip to content

Commit 6e1b440

Browse files
fmeumcopybara-github
authored andcommitted
Use .dylib extension for macOS dynamic libraries in XCode toolchain
This is a follow-up to #14158. Fixes #11082. Closes #14354. PiperOrigin-RevId: 413885597
1 parent fbd4427 commit 6e1b440

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/test/shell/bazel/cc_integration_test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,14 @@ EOF
505505
506506
using namespace std;
507507
508+
#ifdef __APPLE__
509+
#define DYNAMIC_LIB_EXT "dylib"
510+
#else
511+
#define DYNAMIC_LIB_EXT "so"
512+
#endif
513+
508514
int main() {
509-
void* handle = dlopen("libf.so", RTLD_LAZY);
515+
void* handle = dlopen("libf." DYNAMIC_LIB_EXT, RTLD_LAZY);
510516
511517
typedef string (*f_t)();
512518

tools/osx/crosstool/cc_toolchain_config.bzl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
load(
1717
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
1818
"action_config",
19+
"artifact_name_pattern",
1920
"env_entry",
2021
"env_set",
2122
"feature",
@@ -3007,7 +3008,15 @@ def _impl(ctx):
30073008
else:
30083009
fail("Unreachable")
30093010

3010-
artifact_name_patterns = []
3011+
# macOS artifact name patterns differ from the defaults only for dynamic
3012+
# libraries.
3013+
artifact_name_patterns = [
3014+
artifact_name_pattern(
3015+
category_name = "dynamic_library",
3016+
prefix = "lib",
3017+
extension = ".dylib",
3018+
),
3019+
]
30113020

30123021
make_variables = [
30133022
make_variable(

0 commit comments

Comments
 (0)