Skip to content

Commit

Permalink
Remove uses of -lstdc++ on darwin (bazelbuild#14750)
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
(cherry picked from commit 8b60c90)

Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
  • Loading branch information
brentleyjones and keith authored Feb 9, 2022
1 parent 167e79f commit 22bede9
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 22bede9

Please sign in to comment.