-
Notifications
You must be signed in to change notification settings - Fork 979
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
[Discussion] how to model GLIBC version for conan packages #3972
Comments
We should discuss this issue once we face the cross-building model one as this might affect the current settings and have further implications in Linux packages. |
I am facing a similar issue regarding libc when building packages for glibc and musl (e.g. Alpine). Both are Linux, x86_64 but linked against a different libc. We modified settings.yml like this:
This does not cover the fact of different versions of glibc or musl but covers at least our use case. |
To note: There is more than just the glibc version that defines the system ABI on Linux. Things like dynamic linking SONAMEs to system libraries present another dimension of whether a given ELF can be loaded correctly on a given system. Issues with differing system libraries were my trouble with Qt, even if there were compatible glibc versions. I have a local fork of Conan at A tuple of Of course, not all packages are so sensitive to these system attributes, and may want to "opt-in" to become more granular. One case this design does not consider is that a CentOS 6 package is probably compatible with CentOS 7 (as long as the proper SONAMEs match), but I personally don't consider that a compelling enough feature to warrant additional complexity. |
As a workaround for this issue, is there a Simply using |
I mean, always building the stuff from public servers maybe not that nice, since then why do we store it all then. |
Taking the suggestions from https://docs.conan.io/en/latest/extending/custom_settings.html as a base and incorporating the ideas from @scddev , the following custom settings are working for me:
Whe also have some custom made distros for embedded device which we all have a distro name for. Unlike the glibc mess, working with musl as a libc, does usually not require the definition of the distro. |
For the toolchain side, we also had to expand 'os_build', so that the from source generated toolchain works on all build nodes. The toolchain is added as a dependency in the profile via a '[build_requires]'. The following expansion of the 'settings.yml" seems to works for our embedded, cross compilation setup.
|
I'm in favor of the solution using |
We (with several linux targets, some public distros and some yocto-based cross-toolchains) do the following in settings.yml os:
Linux:
distribution:
None:
# based on /etc/os-release $ID and $VERSION_ID
ubuntu:
version: [ "16.04", "16.10", "18.04", "18.10" ]
wrlinux:
version: [ "7.0", "8.0", "8.0.0.28", "8.0.0.30" ]
fsl-imx:
version: [ "4.14.98-2.0.0_ga" ] Allowing Yocto supports this sort of labeling via the bitbake recipe https://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-core/os-release/ |
What about this:
For auto generation of the profile, the libc version can be detected by compiling+executing a simple file using The bigger problem is: how will the hashing/package id work? Packages compiled with different glibc versions, will generate a different package id. |
That's the same issue as with |
Another point to highlight the importance of this feature is conan-io/conan-docker-tools#200. Even though there is gcc-9.3 available in Ubuntu 20.04 (used already for gcc-10 image) and it fixes some bugs in gcc-9.2 that prevent my library to compile on the older compiler, we can't upgrade the docker image because of glibc issue. |
IMHO - we're discussing a "model" for glibc compatibility for Linux - bugs are not the sort of thing I would include in a model of how glibc compatibility works. Bugs will invariably violate any rules for compatibility, and render any model invalid. I would recommend creating a model that ignores a special case like a bug in a particular version of a library as it will cause more problems than it will solve. A more reasonable fix for an issue like this might be to have a recipe require a version of glibc later than the problematic one. |
We are also facing the issue of Ubuntu 20.04 binaries of dependencies being pulled for 18.04 builds (because package IDs are the same on Ubuntu 18.04 and 20.04), and erroring out with:
Do we have a workaround that works today? |
@blackliner The solution that I most often see recommended is to implement the following in your own
With conan 2.0, you could also try to define the compatibility relationship between different versions of glibc as well, using compatibility.py |
It's absolutely fine to use binaries compiled for centos 7 (glibc 2.17) in ubuntu 16.04 (glibc 2.23), because glibc is backwards compatible. So I wouldn't go that way:
This solution is not a valid yaml and it exposes
I modified it like so: compiler:
gcc:
...
libc: &libc
None: ~
glibc:
version: ["2.17", ...]
msvc:
...
# no libc
clang:
...
libc:
<<: *libc
def package_id(self):
del self.info.settings.compiler It is a problem because an executable built for glibc 2.35 won't start with glibc 2.17. In order to fix this we should |
Are you sure with it because as far as I know its not: |
@jusito let me just quote official webpage:
There you can find some details on how they handle it |
And to add to that – I’ve been building proprietary “shrink wrap” software on Linux for 20+ years, and I have yet to see an instance where C/C++ software compiled on Linux glibc that had trouble running on a system because it had a newer glibc (or maybe my memory is failing). 😉
IMHO I think it would be a surprise if the glibc version were part of the compiler settings though, as it’s a property of the OS/distro.
From: Maksim Petukhov ***@***.***>
Date: Tuesday, March 7, 2023 at 8:56 AM
To: conan-io/conan ***@***.***>
Cc: Rob Boehne ***@***.***>, Comment ***@***.***>
Subject: Re: [conan-io/conan] [Discussion] how to model GLIBC version for conan packages (#3972)
because glibc is backwards compatible.
Are you sure with it because as far as I know its not: https://abi-laboratory.pro/?view=timeline&l=glibc I don't have deep insights into this topic, just read about it and found this overview some time ago.
@jusito<https://github.com/jusito> let me just quote official webpage<https://www.gnu.org/software/libc/>:
The GNU C Library is designed to be a backwards compatible, portable, and ...
There<https://developers.redhat.com/blog/2019/08/01/how-the-gnu-c-library-handles-backward-compatibility> you can find some details on how they handle it
—
Reply to this email directly, view it on GitHub<#3972 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACVSF3QWMA4J64BZRUU4ABLW25EAZANCNFSM4GFTLHYQ>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Please go watch Diego’s or my conference talk, when we do the opinionated ecosystem part I affectionately think of you guys and gals. "Death by a thousand bites" |
I agree. Currently my custom conan v2 os:
Linux:
libc:
null:
glibc:
version: ["2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7",
"2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14",
"2.15", "2.16", "2.17", "2.18", "2.19", "2.20", "2.21",
"2.22", "2.23", "2.24", "2.25", "2.26", "2.27", "2.28",
"2.29", "2.30", "2.31", "2.32", "2.33", "2.34", "2.35",
"2.36", "2.37", "2.38"]
musl:
version: ["0.9", "1.0", "1.1", "1.2"] And in profiles targeting Linux I just have to add something like: os.libc=glibc
os.libc.version=2.35 |
I use the same form as @SpaceIm. It's necessary to put libc as an OS subsetting since application packages will often erase |
Isn't range matching supported per https://docs.conan.io/2/tutorial/versioning/version_ranges.html? If the requirement needs to be part of the recipe because adding requirement based on the system then maybe instead of specifying hard coded versions it would be something like <${system_glibc_version} where ${system_glibc_version} is the version detected on the system. |
No, version-ranges apply only to package versions, but is completely unrelated to the binary In any case, adding custom glibc compatibility in 2.0 is relatively straightforward:
All 3 things can be conveniently managed with |
@memsharded It would be super helpful to have built-in detection for the glibc version through the |
@jwillikers yes that would be possible. Would you like to contribute it yourself? the |
Definitely. This will really help us clean up our Conan profiles, so I'll be able to. Hopefully I'll be able to get around to it in the near future. |
This PR adds a simple function to detect the version of glibc to the detect_api. This functionality is only intended for Linux systems using glibc. The function is detect_gnu_libc(). It simply runs ldd --version to detect the version of glibc. It is also possible to detect the version of the libc library by running the libc.so file. The location of this library varies much more than the path to ldd, so ldd --version is used instead. The path to ldd is passed as an argument, /usr/bin/ldd by default. This can modified to suite alternate sysroots. It can even be used in cross-compilation scenarios where emulation is available to execute ldd. The detect_gnu_libc function does a simple sanity check to verify that glibc is indeed being used. This avoids confusion on systems using an alternative libc implementation, i.e. musl. I also added a function to detect the version of the musl libc library as well. This function is detect_musl_libc() and works the same way. Addresses conan-io#3972, at least in part.
This PR adds a simple function to detect the version of glibc to the detect_api. This functionality is only intended for Linux systems using glibc. The function is detect_gnu_libc(). It simply runs ldd --version to detect the version of glibc. It is also possible to detect the version of the libc library by running the libc.so file. The location of this library varies much more than the path to ldd, so ldd --version is used instead. The path to ldd is passed as an argument, /usr/bin/ldd by default. This can modified to suite alternate sysroots. It can even be used in cross-compilation scenarios where emulation is available to execute ldd. The detect_gnu_libc function does a simple sanity check to verify that glibc is indeed being used. This avoids confusion on systems using an alternative libc implementation, i.e. musl. I also added a function to detect the version of the musl libc library as well. This function is detect_musl_libc() and works the same way. Addresses conan-io#3972, at least in part.
This PR adds a simple function to detect the version of glibc to the detect_api. This functionality is only intended for Linux systems using glibc. The function is detect_gnu_libc(). It simply runs ldd --version to detect the version of glibc. It is also possible to detect the version of the libc library by running the libc.so file. The location of this library varies much more than the path to ldd, so ldd --version is used instead. The path to ldd is passed as an argument, /usr/bin/ldd by default. This can modified to suite alternate sysroots. It can even be used in cross-compilation scenarios where emulation is available to execute ldd. The detect_gnu_libc function does a simple sanity check to verify that glibc is indeed being used. This avoids confusion on systems using an alternative libc implementation, i.e. musl. I also added a function to detect the version of the musl libc library as well. This function is detect_musl_libc() and works the same way. Addresses conan-io#3972, at least in part.
* Add detect_gnu_libc() and detect_musl_libc() functions This PR adds a simple function to detect the version of glibc to the detect_api. This functionality is only intended for Linux systems using glibc. The function is detect_gnu_libc(). It simply runs ldd --version to detect the version of glibc. It is also possible to detect the version of the libc library by running the libc.so file. The location of this library varies much more than the path to ldd, so ldd --version is used instead. The path to ldd is passed as an argument, /usr/bin/ldd by default. This can modified to suite alternate sysroots. It can even be used in cross-compilation scenarios where emulation is available to execute ldd. The detect_gnu_libc function does a simple sanity check to verify that glibc is indeed being used. This avoids confusion on systems using an alternative libc implementation, i.e. musl. I also added a function to detect the version of the musl libc library as well. This function is detect_musl_libc() and works the same way. Addresses #3972, at least in part. * Break out parse functions and add detect_libc function * Add tests and fix detection of musl libc * Add functional tests for detect_gnu_libc and detect_musl_libc These just check that the functions run without errors. This avoids assumptions about what C library is being used. * Unify on a single function * Replace unittest with pytest * Fix return for detect_libc function
Hi, I'm facing a similar issue, building a library for 2 different versions of Ubuntu (Focal, Jammy) and having glibc version issues. |
The detection of libc is not automatic in the default profile detection. If you want to use it, you have to use the new
Then, the |
To help us debug your issue please explain:
/cc @rdeterre @bc-lee @elizagamedev
this is more generic version of #3963
related issues:
bincrafters/community#296
bincrafters/community#267
historically, conan didn't model glibc version, relying only on compiler version for binary compatibility checks.
this causes some issues in the past, as binaries compiled with the same compiler weren't compatible across various linux distributions.
for instance, if we compiled libraries or executables via GCC 4.8 on Ubuntu 12.04, these executables and libraries fail to run/link on CentOS 7 machines. same situation with other popular Linux distributions, like RHEL, Fedora, etc.
The text was updated successfully, but these errors were encountered: