rules_foreign_cc doesn't add -fPIC when --force_pic is specified
Bazel adds -fPIC for other cc targets. This results link failure.
Note it would also help if envoy_cmake_external supported copts. It already supports linkopts, and this is a shortcoming relative to cc_library or cc_binary. This would make implementing workarounds simpler.
While it does support cache_entries, which can include CMAKE_CXX_FLAGS, and also supports env_vars, which can include CXXFLAGS, these are very difficult to manipulate using select().
I guess one of the tricky issues here is that for native bazel targets it builds static libraries with both -fPIC and without depending upon the context within which it is linked. Now when you are relying on an external build system to replicate that behaviour it very much depends on the third party build system as to whether it natively adds (or indeed strips off) -fPIC from its builds.
I guess a workaround to this could be to set a feature on the target that passes -fPIC from the configure cc toolchain.
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!
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"
Why has this report been ignored and allowed to expire? Please reopen, it's pretty basic and trivial
Sorry the report has gone unaddressed as long as it has. Unfortunately, rules_foreign_cc has no official support and those who do work on it do so in their free time. If the solution is simple, I'd be happy to collaborate on a pull request if someone would be willing to open one 😄
I'll otherwise re-open for now though.
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!
I will again ask on behalf of bazel consumers that you please do not close. If @lizan or I had assurance a patch might be applied, one of us might even volunteer to fix, but we are less than optimistic based on a few years of observation
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!
@wrowe apologies if this feels ignored but I'd definitely review a change for this if it was put in but I don't think its that simple to achieve as I have had a quick look at this in the past.
https://github.com/bazelbuild/bazel/pull/10143 was an attempt to add --force-pic to the cc_common api which was rejected in favour of having to do the work manually to select the correct pic versions of libraries to link. Note that as bazel adds .pic in the library names then getting this to work with cc_* rules in a portable way is probably quite tricky to do correctly.
There is also the added complexity I noted above of how to actually add -fPIC in a portable way to all the build systems that are supported.