Specify minimum libc version #9726
-
Is it possible to specificy minimum libc version?
How I can check libc version? I try to use version()
but it return:
Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Instead of checking for a specific libc version, you probably should check for a specific feature you need. You probably want to check if a function exists, you can do that with cc.has_function(). |
Beta Was this translation helpful? Give feedback.
-
Dependencies can have version attributes, and check those versions, because pkg-config and cmake etc. have formal methods to expose versions. find_library cannot and does not have a version attributes, and cannot check versions, because there is no way to extract those versions to begin with. One possibility would be to add an attribute to check the soname, but this doesn't really tell you anything about the API, only the ABI, so it would be of very little use. Worse, the soname for GNU libc has been "6" for decades. They use symbol versioning rather than library versioning, and this allows preserving ABI compat. Why do you need to check the GNU libc version? Checking it during configure means that you expect it to be a fatal error if you don't find the "right" version. Do you not intend to support somewhat older but still actively supported Linux distros on previous versions of the GNU libc? Worse: do you not intend to support other popular libc's like musl at all? What about portability to other operating systems, such as the BSDs? It seems like it would make far more sense to either check for functions you need, or else do preprocessor checks to see whether GNU libc's version macros are defined and evaluate to the expected version, and then... ... if/else based on that, with some code to take advantage of GNU libc features and some generic code to handle the non-glibc case. Failing that, you can of course document that only glibc is supported, and do a Either way, please don't manually add |
Beta Was this translation helpful? Give feedback.
Dependencies can have version attributes, and check those versions, because pkg-config and cmake etc. have formal methods to expose versions.
find_library cannot and does not have a version attributes, and cannot check versions, because there is no way to extract those versions to begin with.
One possibility would be to add an attribute to check the soname, but this doesn't really tell you anything about the API, only the ABI, so it would be of very little use. Worse, the soname for GNU libc has been "6" for decades. They use symbol versioning rather than library versioning, and this allows preserving ABI compat.
Why do you need to check the GNU libc version? Checking it during configure …