Skip to content

Commit a987b98

Browse files
keithcopybara-github
authored andcommitted
Fix uses of std++ on bsd
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
1 parent eed6e61 commit a987b98

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tools/cpp/cc_toolchain_config.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def _impl(ctx):
371371
flag_groups = [
372372
flag_group(
373373
flags = [
374-
"-lstdc++",
374+
"-lc++",
375375
"-Wl,-z,relro,-z,now",
376376
"-no-canonical-prefixes",
377377
],

tools/cpp/unix_cc_configure.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
340340

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

344345
cc = find_cc(repository_ctx, overriden_tools)
345346
is_clang = _is_clang(repository_ctx, cc)
@@ -400,7 +401,8 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
400401
False,
401402
), ":")
402403

403-
bazel_linkopts = "-lc++:-lm" if darwin else "-lstdc++:-lm"
404+
use_libcpp = darwin or bsd
405+
bazel_linkopts = "-lc++:-lm" if use_libcpp else "-lstdc++:-lm"
404406
bazel_linklibs = ""
405407
if repository_ctx.flag_enabled("incompatible_linkopts_to_linklibs"):
406408
bazel_linkopts, bazel_linklibs = bazel_linklibs, bazel_linkopts

0 commit comments

Comments
 (0)