Skip to content

Commit 8b60c90

Browse files
keithcopybara-github
authored andcommitted
Remove uses of -lstdc++ on darwin
This flag has been invalid seemingly since macOS 10.9 from 2013. By default clang remaps this back to -lc++, but if your linkopts pass -nodefaultlibs this is not the case, in which case this invalid flag fails the link. This happened for rust builds where the rust driver passes this flag intentionally. For more info see bazelbuild#14395 (comment) Fixes google/cargo-raze#247 bazelbuild#14395 bazelbuild/rules_rust#226 Closes bazelbuild#14542. PiperOrigin-RevId: 424588734
1 parent 6c31c1d commit 8b60c90

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tools/cpp/cc_toolchain_config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def _impl(ctx):
395395
flag_groups = [
396396
flag_group(
397397
flags = [
398-
"-lstdc++",
398+
"-lc++",
399399
"-undefined",
400400
"dynamic_lookup",
401401
"-headerpad_max_install_names",

tools/cpp/unix_cc_configure.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
400400
False,
401401
), ":")
402402

403-
bazel_linkopts = "-lstdc++:-lm"
403+
bazel_linkopts = "-lc++:-lm" if darwin else "-lstdc++:-lm"
404404
bazel_linklibs = ""
405405
if repository_ctx.flag_enabled("incompatible_linkopts_to_linklibs"):
406406
bazel_linkopts, bazel_linklibs = bazel_linklibs, bazel_linkopts

0 commit comments

Comments
 (0)