Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions extensions/bindgen/private/bindgen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ def _rust_bindgen_impl(ctx):
# Ideally we could depend on a more specific toolchain, requesting one which is specifically clang via some constraint.
# Unfortunately, we can't currently rely on this, so instead we filter only to flags we know clang supports.
# We can add extra flags here as needed.
flags_known_to_clang = (
# Flags in this tuple accept a parameter in the same argument (`-Ipath`, `--target=T`) or separately (`-I path`).
param_flags_known_to_clang = (
"-I",
"-iquote",
"-isystem",
Expand All @@ -283,8 +284,16 @@ def _rust_bindgen_impl(ctx):
"--no-system-header-prefix",
"-Xclang",
"-D",
)

# Flags in this tuple do not accept a parameter.
paramless_flags_known_to_clang = (
"-no-canonical-prefixes",
"-nostd",
"-nostdinc",
"--no-standard-includes",
"-nostdinc++",
"-nostdlib++",
"-nostdlibinc",
)
open_arg = False
for arg in compile_flags:
Expand All @@ -298,12 +307,12 @@ def _rust_bindgen_impl(ctx):
args.add(arg)
continue

if not arg.startswith(flags_known_to_clang):
if not arg.startswith(param_flags_known_to_clang) and not arg in paramless_flags_known_to_clang:
continue

args.add(arg)

if arg in flags_known_to_clang:
if arg in param_flags_known_to_clang:
open_arg = True
continue

Expand Down