Skip to content

Commit

Permalink
Merge pull request #12109 from deannagarcia/cherrypickOSX
Browse files Browse the repository at this point in the history
Cherrypick osx static linking fix
  • Loading branch information
deannagarcia authored Mar 1, 2023
2 parents af7f9d5 + 964a7f0 commit 4c3d093
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ cc_binary(
linkopts = LINK_OPTS,
features = select({
# This isn't possible on mac because there is no static library for lcrt0.o
"@platforms//os:osx": [],
"//build_defs:config_osx": [],
# When cross-compiling we need to statically link all C++ libraries.
"//conditions:default": ["fully_static_link"],
}),
Expand Down
20 changes: 20 additions & 0 deletions build_defs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Internal Starlark definitions for Protobuf.

load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_cc//cc:defs.bzl", starlark_cc_proto_library = "cc_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
Expand Down Expand Up @@ -83,6 +84,25 @@ config_setting(
},
)

config_setting(
name = "config_osx_aarch64",
values = {"cpu": "osx-aarch_64"},
)

config_setting(
name = "config_osx_x86_64",
values = {"cpu": "osx-aarch_64"},
)

selects.config_setting_group(
name = "config_osx",
match_any = [
"@platforms//os:osx",
":config_osx_aarch64",
":config_osx_x86_64",
]
)

# Internal testing:

starlark_cc_proto_library(
Expand Down
1 change: 1 addition & 0 deletions toolchain/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def _impl(ctx):
flags = [
"-B" + ctx.attr.linker_path,
"-lstdc++",
"-lm",
"--target=" + ctx.attr.target_full_name,
] + ctx.attr.extra_linker_flags,
),
Expand Down

0 comments on commit 4c3d093

Please sign in to comment.