Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support per_file_copt #1332

Open
mering opened this issue Nov 29, 2024 · 5 comments
Open

Support per_file_copt #1332

mering opened this issue Nov 29, 2024 · 5 comments

Comments

@mering
Copy link

mering commented Nov 29, 2024

Options passed as --per_file_copt are currently not honored by rules_foreign_cc.

This is blocking us from enabling -Werror for our own code but ignoring warnings on external code where we have no control over.
We want to do this with the following .bazelrc:

build --per_file_copt=external/.*@-Wno-everything --host_per_file_copt=external/.*@-Wno-everything
build --copt=-Werror --host_copt=-Werror

See bazelbuild/bazel#24528 for further details.

@jsharpe
Copy link
Member

jsharpe commented Nov 29, 2024

I'm not sure how you'd implement this as you'd need support from the configure script or the cmake script to apply flags to specific files which I don't think there is a general solution for.
What we support though is features and so you could add a feature to your toolchain that sets the desired flags and then set the features for your rules_foreign_cc targets?

@mering
Copy link
Author

mering commented Nov 29, 2024

@jsharpe thanks for your quick reply.

I do not have control over all rules_foreign_cc targets as some come in via transitive dependencies. I also get some errors for internal tools like make and pkgconfig.

Could there be a way to explicitly set additional copt for all rules_foreign_cc targets?

@mering
Copy link
Author

mering commented Nov 29, 2024

Another approach could be to match the regex (here external/.*) against the BUILD file or the cmake() rule itself and if matching then appending the per_file_copt to the copts for the whole the target.

@jsharpe
Copy link
Member

jsharpe commented Nov 29, 2024

Another approach could be to match the regex (here external/.*) against the BUILD file or the cmake() rule itself and if matching then appending the per_file_copt to the copts for the whole the target.

I don't think starlark has visibility of the per_file_copt except indirectly via the cc_common API?

@mering
Copy link
Author

mering commented Nov 29, 2024

I don't think starlark has visibility of the per_file_copt except indirectly via the cc_common API?

@meteorcloudy @fmeum could you answer this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants