Skip to content

Commit

Permalink
declare macos_default_link_flags unsupported to avoid linking Foundation
Browse files Browse the repository at this point in the history
The cc toolchain feature "macos_default_link_flags" for a unix toolchain
adds the linker flag "-fobjc-link-runtime" for backwards compatibility:

https://cs.opensource.google/bazel/bazel/+/refs/tags/7.3.1:tools/cpp/unix_cc_toolchain_config.bzl;l=1412-1427

Some link actions under Bazel 7 fail with the message:

  ld: framework not found Foundation
  • Loading branch information
malt3 committed Aug 30, 2024
1 parent dac3b6c commit 509bfbd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion haskell/cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def cc_interop_info(ctx, override_cc_toolchain = None):
ctx = real_ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
# we explicitly declare macos_default_link_flags as unsupported since it will by default add
# the linker flag "-fobjc-link-runtime", since it leads to the Foundation framewok being linked on macOS
# which leads to: "ld: framework not found Foundation"
unsupported_features = ctx.disabled_features + ["macos_default_link_flags"],
)
compile_variables = cc_common.create_compile_variables(
feature_configuration = feature_configuration,
Expand Down

0 comments on commit 509bfbd

Please sign in to comment.