-
Notifications
You must be signed in to change notification settings - Fork 994
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
[question] Upgrade to conan2 resolves symbols differently #17569
Comments
Hi @hoisunng Thanks for your question. I have a quick question. Why are you using? self.requires("spdlog/1.10.0", transitive_headers = True, transitive_libs=True) The Have you tried with a plain |
Hi @memsharded Thanks for your quick response. I ran it again without the extra arguments. Anyway the nm output is the same with just
|
Something that might be worth trying, if in the latest Conan: Use the incubating |
Good point, I forgot to mention the versions. I am trying to upgrade from 1.65 to 2.10 (I also upgraded to 2.11 now). After regenerating everything from conan with Was there maybe an (un)intentional change in conan 2 that I'm not aware of that influences the final binary and not the dependencies? |
Yes, the Conan 2 dependency propagation model is more complete and advanced compared to the Conan 1 one. So Conan 2 knows and model the This improves different aspects, for example it can avoid overlinkage that was way more frequent in Conan 1, and also provides better hiding of things like transitive headers, supporting better SW engineering defaults. So it is expected that the linkage of an application to transitive (not direct) shared libraries. I still don't fully grasp the details of the linkage issue (I am also not expert in Linux shared libs symbol visibility), so the first thing that I am trying to do is to reduce to something minimal that we can fully reproduce in both sides. This is what I have: def test_shared_symbols():
c = TestClient()
c.run("new cmake_lib -d name=fmt")
c.run("export .")
c.run("new cmake_lib -d name=spdlog -d requires=fmt/0.1 --force")
test = textwrap.dedent("""\
from conan import ConanFile
from conan.tools.cmake import CMake
class spdlogTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
self.run("./example", env="conanrun")
self.run("nm example")
""")
c.save({"test_package/conanfile.py": test})
c.run("create . -o *:shared=True --build=missing")
print(c.out) It is not fully clear to me if the Then I see some symbols like:
but I don't see the basic |
I'm not sure if it's possible to reproduce this with just the conan commands, because of the type of symbols involved. I have to admit I'm not very familiar with them except for the basic consumer ones, nor am I an expert in shared libraries either. Just to clarify on your comment. In my case both spdlog and fmt are static libraries and their symbols get copied into my shared library/executable. |
For that case it might be worth to provide some Likewise it would be great to reproduce first with some more standard compiler like the |
Short update: I haven't been able to reproduce it without using the real libraries. I still don't really understand how the symbols work. However, I did try with the default compiler and conan profile on ubuntu 22.04 (in WSL) and the difference also exists. |
What is your question?
Hello!
I am trying to upgrade our code to use conan2, but I am stuck with this problem.
We build a python extension module, so it's a shared library, but the following minimal example also demonstrates my problem.
The conan profiles are similar, but for conan 2 I try to use the new
tool_requires
which makes it very easy to manage the compiler.The executable depends on spdlog, which in turn depends on fmt. There are some symbols that
spdlog
uses that are weak symbols infmt
. So far so good and in both versions I seem to get the more or less the same static libraries. It's not binary identical, but the symbols I'm interested in look the same, for example:However, the symbol in the final executable differs in visibility. In conan 1 it was still an external (weak) symbol but when I use conan 2 it has become local (and strong).
Like I mentioned above, our real application is actually a shared library, but it also has this change of visibility of the symbol like the minimal example. This is a problem because it also contains JIT compilation support and now the JIT compiled code reports missing symbols, because it can't find it in the shared library.
I know that conan 2 has some changes that made things more private (as it should be), so less is leaked to dependants. I think I am just overlooking some small configuration, but I can't find how I can control this last linker step. Unfortunately this is blocking us from upgrading to conan 2.
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: