-
Notifications
You must be signed in to change notification settings - Fork 974
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
[feature] Handle library loops (--start-group, --end-group) #6530
Comments
Hi! AFAIK, the order of the libraries in the In v1.22 we modified the CMake generator (those using targets) to fix some issues related to the link order and the dependencies between CMake targets. This is the PR #6298. It is true that we are not considering the Which generator were you using when you came across this issue? Issue #6510 is about the build-order between Conan packages computed from graphlock, it sholdn't be related to the link-order of libraries within the same package |
Hi @jgsogo ! Thanks for the quick response! I'm using
This worked before, but now it seems to push the |
Hi! This is totally related to the fix applied in #6298, it modified the way we are creating the targets in our CMake function There is nothing in Conan taking into account those command-line arguments, so we need to approach this issue like a feature request. I'm very sorry it has broken your build, but we can try to work on a workaround before the actual feature is ready. The reason people use those keywords is that there is a circular dependency between the libraries, those keywords are only a convenient way to avoid repeating the libraries in the linker line, so we can try a few things:
|
Okay, thanks for the help! The workaround we're using is not pretty, but here it is:
You can see the full recipe here. Do I need to submit a formal feature request, or is this something that is already in the works? |
Yes, that's a workaround for sure.... I'll change the title of this issue and it is enough 😉 I'm thinking about something like this (totally speculative): def package_info(self):
self.cpp_info.libs = ['libA', LibGroup('libB', 'libC'), ..., 'libH'] and, under the hood, Conan will do something with that And we also have to consider this in the scope of the components feature... |
I'm having a look at some CMake modules for MKL and I'm seeing some crazy stuff (i.e. pytorch). I have a doubt, this inter-dependency can be handled just between libraries, or CMake is able to handle it between targets too? |
Yeah, it gets pretty crazy. To be honest, I've been doing it somewhat ad-hoc--I'm not using all the functionality within MKL, so not trying to account for all the different inter-dependencies. One way that I was thinking about dealing with this in a more structured way, was through adding different |
Some time ago i came uppon this issue in my company and although i believe this is not a critical issue (there is a workaround using exelinkflags, you shouldnt have cyclic dependencies between your libraries anyway), i still think it is worth to have a look at this because:
So if conan would handle this situation gracefully, i think for the rare cases where it is a problem, it would really be an improvement (it is not the responsibility of conan to make developers aware of weaknesses in their SW architecture, right?). But after having a first look in a bit detail i found that as usual this is much harder to implement than anticipated. So before actually changing code, i would like to ask for some guidance. (maybe @jgsogo ?)
Findings sofar:
Necessary steps for implementation:
Open points:
|
Is there a better workaround for this when using the |
I've been able to fool the conan and get at least test_package working by creating additional symlinks. But I'm not sure that it won't break in some other place.
|
Hi all, I am revisiting this, trying to improve over this issue. One of the main blockers that I am finding is that CMake doesn't have a native way to specify this. It might allow defining cycles in dependencies, but the cycle has to be known, it is not possible to explicitly define the linking group with I have seen some thread using
But this looks terrible. |
CMake 3.24+ https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:LINK_GROUP |
The disadvantage of LINK_GROUP is that it cannot be set on the libraries targets. Maybe we can set it to the target if("{{ '${' }}{{ pkg_name }}_LINK_GROUP{{ config_suffix }}}")
target_link_libraries({{root_target_name}} "$<LINK_GROUP:RESCAN,{{ '${' }}{{ pkg_name }}_LINK_GROUP{{ config_suffix }}}>")
endi() And we could define it as a to talk with @jcar87 |
If I recall correctly, if the But from what can I see @memsharded, we are still limited by the targets in CMakeDeps:
So this feature wouldn't work. Out of curiosity, presumably this is only a problem for libraries within a package, where a package has multiple components that are all static libraries which present a dependency cycle? If this is the case, regardless of the implementation details (which we can probably handle some way or the other), this probably calls for a specific syntax in the |
Problem is that we don't have a mechanism to do cycles of
So not only the targets types, also the model would be lacking here. |
Hi, @memsharded
I'm also in favour of that. Now I have to write all libs' name, specifying order and dealing with the |
It seems that going from
v1.21
tov1.22
, the library ordering specified inself.cpp_info.libs
is no longer maintained. Is this true or am I missing something?The package I'm creating depends on Intel MKL, which requires a specific linking ordering as well as
-Wl,--start-group
and-Wl,--end-group
surrounding the MKL libraries being linked to. I have the ordering specified in a Bintray package for MKL which was working fine forv1.21
. When updating tov1.22
, the ordering specified for the libraries in theconanfile.py
for MKL is no longer maintained, so linking fails.Is there a way to force
conan
to maintain the ordering or what is the best way to deal with this? Seems like this issue is related to #6510.The text was updated successfully, but these errors were encountered: