-
Notifications
You must be signed in to change notification settings - Fork 989
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
[bug] Unexpected propagation of buildenv env vars with host-context transitive deps #15306
Comments
Hi @valgur I am starting to move that code to an unit-test, and I have found that, simplificando: gcc = textwrap.dedent(r"""
from conan import ConanFile
class Pkg(ConanFile):
name = "gcc"
version = "1.0"
package_type = "application"
def package_info(self):
self.buildenv_info.define_path("MYCC", "mock-gcc")
""")
pkga = textwrap.dedent(r"""
from conan import ConanFile
class Pkg(ConanFile):
settings = "os"
tool_requires = "gcc/1.0"
package_type = "shared-library"
def requirements(self):
self.requires("gcc/1.0", headers=False, libs=True)
""") I think that such The effect that you are seeing is that |
Thanks for looking into this! I made the minimal example more realistic by including a mock Using a tool with both It sounds like the real solution for a case like this is to split the package into a separate library and application one, i.e. Still, is there really a use case where a Also, if an |
Yes, exactly. We even added the It works fine with the
We just added the
Unfortunately yes. Environment variables have been largely abused in the C++ ecosystem to propagate information from regular dependencies both static and shared (run=True) to be able to find and link them at build time by their consumers. This is one of the reasons we allowed
There are some use cases of recipes gathering multiple applications for deployment, generally with an "unknown" package type, but the unknown type as been long time associated to libraries. It is not that straightforward to diagnose this situation without generating false positives for those legit cases, but it is totally true that trying to detect it and report it somehow could be helpful and beneficial. |
"application" is not really intended to provide libraries and has pitfalls: conan-io/conan#15306
Environment details
Steps to reproduce
A minimal example: https://github.com/valgur/conan-buildenv-issue
Using a package with
package_type = "application"
as a host-contextself.requires()
dependency without explicitly addingrun=False
results in buildenv environment variables being added to all downstream packages as well.This came up when trying to use
gfortran
from agcc
package together with itsgfortran
andquadmath
runtime libraries to buildopenblas
. The unexpected silent propagation ofCC
andCXX
vars fromgcc
was caused some of the downstream package builds to fail.I suppose this could be considered the intended behavior for
self.requires(..., run=True)
, but it's nevertheless unexpected and looks like an easy pitfall to me.There are two aspects to this issue:
package_type = "application"
default torun=True
when used withself.requires()
?Neither of these look like the correct behavior to me.
Logs
No response
The text was updated successfully, but these errors were encountered: