-
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
[question] Conan 2.x Migration - transitive_headers and transitive_libs Trait Defaults #17505
Comments
Hi @radonish Thanks for your question. First, the
This also works for shared libraries, you can add So the only case where |
Hello @memsharded, thank you for the quick response. I ran the commands you gave and do see the expected behavior for those test packages. I'm comparing the generated recipes with the actual recipes my team is using in order to determine what is going wrong. One key observation when looking at the linker command line for the link failure that occurs in the test_package for our library is that the library paths are there (-L parameters for transitive dependencies are contained) but the specific transitive library path/names are missing. That makes me wonder if it is a package_info problem where the libs for the transitive dependency packages aren't being properly set/advertised. (In one example our proprietary library - let's call it libx - is simply dependent on the Conan Center's POCO library package. libx builds and links fine, but its test_package fails with linker errors that it cannot find POCO. As noted above, the linker command line contains the -L parameter to the Conan cache for POCO but I do not see any of the POCO libraries called out.) |
@memsharded, the issue appears to occur when cross-compiling. An example cross-compile host profile that fails with your liba/libb test is this aarch64 one below:
It works with a host profile that matches the build profile:
|
Here is a build log that shows:
(Changed them to shared libraries within the conanfile.py itself.) |
@memsharded, from the log above, the linker command that fails to link libb to liba for the libb test_package is:
I think the problem is related to how the linker command is being constructed. My understanding is we want to use 1 of 2 options:
Instead the linker command being generated is adding a If I change the Conan-generated libb/test_package/conanfile.py from:
to
The link succeeds because it causes the addition of the full path to liba in the cache to the linker command line. I haven't dug into why this works OK when I'm not cross-compiling and the build and host profiles are just the default RHEL build tools. Perhaps it has something to do with GCC 4 (build tool version) vs. GCC 8 (host tool version for our buildroot-based cross toolchains) and linker nuances. Either way, it's starting to feel like this is a cross-compilation test_package linker bug when the dependency tree is made up of shared libraries. It seems to me that the test_package linker command should include the full path to the shared libraries of the transitive dependencies (as is the case for the actual package linker command). Thank you |
@memsharded, following up - hope you had a nice holiday season! Wanted to share that an easy way to reproduce the problem is as follows
Again, I'm using a buildroot-generated aarch64 host profile to get the failure above. If I use a buildroot-generated x86_64 host profile (that is relatively close to the RHEL toolchain installed on the build machine) it succeeds just as the default profile succeeds - so it's not something specific to buildroot-generated toolchains. If I update |
Hi @radonish I hope you had some nice holiday season too! Thanks for following up and the feedback. I hope you had some nice holiday season too! It is indeed possible that sysroots cause some issues in the One of the goals of the new incubating It is not that straightforward for me to have a buildroot-generated aarch64, maybe @jcar87 could help with this. |
Thanks for the response, @memsharded and for pulling in @jcar87. May I ask what version of GCC you're using in your non-cross-compile testing? Our local build machines are using GCC 4 whereas our cross-compilation buildroot-generated toolchains are GCC 8. In this case it's not obvious that the sysroot is actually causing a problem itself. When breaking down a simplified version of what gets put on the link stage command line for the liba/libb/appx example, line by line:
It seems like it should work. For GCC 4, it's clear that the shared library dependency paths are being used from the rpath option passed to the linker as I can delete the For GCC 8 it's not clear why it fails to find libliba.so with the same core command line options. As stated earlier, I can get it to work in GCC 8 if I add rpath-link to the above options ( I'm trying to understand if there is a GCC version behavior delta that needs to be taken into account when generating that link command string. Is that a Conan or CMake responsibility? EDIT: I recalled that one of our target cross-compilation toolchains was also GCC 4 (for an old ARM target). I verified that the cross-compilation liba/libb/appx example is successful with that GCC 4 ARM toolchain. So, it does indeed appear to be a GCC 4 vs. GCC 8/modern GCC issue. After some quick research I do see references to changes made in modern GCC versions in regards to how the rpath option is handled - rpath apparently now only applies to the current binary being processed, not its dependencies. Thank you |
Sure, I typically use something like Ubuntu 22, with a gcc 11.
Yes, it would seem something more related to CMake than to Conan, it is CMake the one building the compile commands, not Conan, and Conan doesn't do anything different for different gcc compiler versions (in general Conan tries to be very agnostic about this, the knowledge that Conan build-system integrations like Regarding other possible |
Thank you, @memsharded. I have found a few CMake threads that essentially echo this same issue I've created in the liba/libb/appx sandbox. One good one is CMake issue #22678. I've not digested the discussions across the CMake threads well enough to know what could be done differently in the Conan-generated CMake files (via I did try the incubating I'm working on updating 80+ recipes to Conan 2.x. This incubating I'm at a fork in the road: litter conanfile.py and CMakeLists.txt files with what should be implicit transitive shared library dependencies or enable the experimental feature. The incubating page notes it "is limited to |
The new incubating CMakeDeps is definitely the future, but it might be a bumpy road at the moment, so it is almost guaranteed that it will break, so not safe to use at all. But it has already achieved the goal, if you reported that it solved your problem, that is gold feedback for us to keep working on it and get it out of the "incubating" and at that point it will be much safer. What is your urgency? Even if it is incubating now, it is not that our timelines are too large, it might be just a matter of a couple of months, maybe? |
What is your question?
Hello, I've read over the requirements traits documentation and want to ensure the behavior I'm seeing is as desired.
Let's say liba requires libx and liby. Let's also say that all 3 libraries are built shared. liba conanfile.py has:
In migrating the test_package for liba my first attempt was to simply have the following in test_package's conanfile.py:
The link of test_package for liba fails due to symbols from libx and liby. (Edit: Note, the test_package is just an empty main() - no actual code/references to the transitive dependencies.)
If I update liba's conanfile.py as follows, test_package can link:
I think I would have expected the transitive_headers and transitive_libs to be True by default since the libraries are shared. Any insight on the behavior/my assumptions would be appreciated. Thank you!
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: