Skip to content

Commit

Permalink
Fix uses of std++ on bsd
Browse files Browse the repository at this point in the history
This fix is the same as bazelbuild#14542
but for freebsd and openbsd

Hopefully fixes bazelbuild/rules_rust#978

Closes bazelbuild#14668.

PiperOrigin-RevId: 429354084
  • Loading branch information
keith authored and Copybara-Service committed Feb 17, 2022
1 parent eed6e61 commit a987b98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/cpp/cc_toolchain_config.bzl
Expand Up @@ -371,7 +371,7 @@ def _impl(ctx):
flag_groups = [
flag_group(
flags = [
"-lstdc++",
"-lc++",
"-Wl,-z,relro,-z,now",
"-no-canonical-prefixes",
],
Expand Down
4 changes: 3 additions & 1 deletion tools/cpp/unix_cc_configure.bzl
Expand Up @@ -340,6 +340,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):

repository_ctx.file("tools/cpp/empty.cc", "int main() {}")
darwin = cpu_value.startswith("darwin")
bsd = cpu_value == "freebsd" or cpu_value == "openbsd"

cc = find_cc(repository_ctx, overriden_tools)
is_clang = _is_clang(repository_ctx, cc)
Expand Down Expand Up @@ -400,7 +401,8 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
False,
), ":")

bazel_linkopts = "-lc++:-lm" if darwin else "-lstdc++:-lm"
use_libcpp = darwin or bsd
bazel_linkopts = "-lc++:-lm" if use_libcpp else "-lstdc++:-lm"
bazel_linklibs = ""
if repository_ctx.flag_enabled("incompatible_linkopts_to_linklibs"):
bazel_linkopts, bazel_linklibs = bazel_linklibs, bazel_linkopts
Expand Down

0 comments on commit a987b98

Please sign in to comment.