Skip to content

Commit

Permalink
Remove uses of -lstdc++ on darwin
Browse files Browse the repository at this point in the history
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
  • Loading branch information
keith authored and Copybara-Service committed Jan 27, 2022
1 parent 6c31c1d commit 8b60c90
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/cpp/cc_toolchain_config.bzl
Expand Up @@ -395,7 +395,7 @@ def _impl(ctx):
flag_groups = [
flag_group(
flags = [
"-lstdc++",
"-lc++",
"-undefined",
"dynamic_lookup",
"-headerpad_max_install_names",
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/unix_cc_configure.bzl
Expand Up @@ -400,7 +400,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
False,
), ":")

bazel_linkopts = "-lstdc++:-lm"
bazel_linkopts = "-lc++:-lm" if darwin 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 8b60c90

Please sign in to comment.