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)
  • Loading branch information
keith committed Jan 11, 2022
1 parent ceece65 commit 26d4aad
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 26d4aad

Please sign in to comment.