-
Notifications
You must be signed in to change notification settings - Fork 522
Closed
Description
Hello,
In generate_cc_link_build_info, the field user_link_flags of the LinkerInput is used to extend the command line of rustc through --arg-file:
rules_rust/bindgen/private/bindgen.bzl
Line 127 in 012af3b
| linker_flags.extend(linker_input.user_link_flags) |
It doesn't work with platform-specific linker flags such as Apple's -framework.
Here is a PoC:
# BUILD
load("@rules_rust//bindgen:defs.bzl", "rust_bindgen_library")
cc_library(
name = "foo",
srcs = ["foo.c"],
hdrs = ["foo.h"],
linkopts = ["-framework", "Security"],
)
rust_bindgen_library(
name = "foo_bindgen",
cc_lib = ":foo",
header = "foo.h",
)Bazel fails with the following error:
error: Unrecognized option: 'f'The content of the .link_flags is the following:
-lstatic=foo
-framework
Security
-framework is treated as -f ramework, leading to the Unrecognized option error.
Since user_link_flags is supposed to contain linker flags, I think you should instead use the codegen option link-args:
-C
link-args=-framework Security
(Note that -lstatic= arguments won't end up in link-args since they don't come from user_link_flags)
Metadata
Metadata
Assignees
Labels
No labels