rules_foreign_cc icon indicating copy to clipboard operation
rules_foreign_cc copied to clipboard

Skip adding linkopts for static library targets

Open keith opened this issue 3 years ago • 2 comments

One thing I've noticed with rules_foreign_cc in envoy is that if I pass --linkopt=-foo to debug something or try a new option, it invalidates all rules_foreign_cc rules. I haven't dug in but my assumption is that linkopts are added to cmake etc configs for every rule even if we're only producing static libraries based on the attributes for the rule.

Do you think it would be safe to exclude them in that case? I worry that it's up to the tools to also use those for other things, so missing important linkopts like -L/path/to/system/libs might break even the setup of cmake, even if the target doesn't use it. But ideally these rules would be more stable in this case otherwise.

keith avatar Apr 29 '22 17:04 keith

This is tricky to support in the general case as we don't know what the configure or cmake files are going to do as part of the build. Since it may build 'exec' configuration tools as part of the build to generate even a static library then in general we have to tell cmake / configure about all the flags that are configured in the toolchain as linkopts gets propagated through to LDFLAGS.

jsharpe avatar May 29 '22 20:05 jsharpe

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_foreign_cc!

github-actions[bot] avatar Nov 25 '22 22:11 github-actions[bot]