-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libcxx] Fix build for glibc < 2.27 #121893
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
Conversation
PR llvm#109211 introduced a build break on systems with glibc < 2.27, since copy_file_range was only introduced after that version. A version check is added to prevent this breakage.
@llvm/pr-subscribers-libcxx Author: Yi Kong (kongy) ChangesPR #109211 introduced a build break on systems with glibc < 2.27, since copy_file_range was only introduced after that version. A version check is added to prevent this breakage. Full diff: https://github.com/llvm/llvm-project/pull/121893.diff 1 Files Affected:
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index bd37c5af86f6c3..e68f89ab1e6114 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -39,8 +39,8 @@
#include <fcntl.h> /* values for fchmodat */
#include <time.h>
-// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc and musl
-#if (defined(__linux__) && (defined(__GLIBC__) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
+// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
+#if (defined(__linux__) && (_LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC)) || defined(__FreeBSD__)
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
#endif
#if __has_include(<sys/sendfile.h>)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like I'd rather just bump the minimum required glibc. 2.27 is almost seven years old by now, which doesn't seem like that crazy of a requirement.
For reference, RHEL 8 uses glibc 2.28, and Ubuntu 20.04 uses glibc 2.31 |
Android is still using glibc 2.17 on the host, but we're planning to move to musl. There are still some issues preventing us from doing so. We are not planning to upgrade glibc before the migration. Since this requires minimal effort to support (just a version macro check), I hope we can continue supporting older versions until it becomes genuinely difficult to maintain. |
We already only claim support for glibc 2.24 and later and the Android bots are just happy with the patch. Also, A libc from 2012 seems a bit unreasonable to support IMO. Having support for half a dozen different libc implementations is already a strain and we don't need even more of that by supporting versions that are more than a decade old. I'm also very sceptical of "just a version macro check". These accumulate, and while one of them isn't much of a problem, all of them together are a burden to support. |
If Android is using glibc 2.17, why don't our CI bots fail after applying #109211? CC @Jannik2099 |
from what I understand, Google is using glibc 2.17 on some build hosts, meaning the host is some GNU-esque userland that builds an Android environment. Unrelated to Android itself, which always uses Bionic, which is what CI tests. |
I'm a bit confused. @kongy Mentioned Glibc 2.27 in their original comment, but then 2.17 in a subsequent comment. The patch itself checks for 2.27. @kongy Can you confirm that you meant 2.27 in #121893 (comment)? Assuming that's correct, then I think we should actually support this since we do claim to support glibc >= 2.24, and 2.27 is certainly more recent than 2.24. We'd then add this and remove it once we bump the glibc requirement. |
FWIW, the original change also breaks building chromium against a debian bullseye sysroot (which you can get from here: https://commondatastorage.googleapis.com/chrome-linux-sysroot/dec7a3a0fc5b83b909cba1b6d119077e0429a138eadef6bf5a0f2e03b1904631). https://issues.chromium.org/issues/388064491 has some details. |
bullseye is glibc 2.31, and as already noticed in the link, the symbol is present in your libc. I think this is due to your linker scripts / wrapper and needs to be fixed on the chromium end? On that note a heads up, you'll possibly want to add |
To clarify, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, this patch LGTM since we support glibc 2.24 and this is truly required for glibc 2.24 through 2.26.
@philnik777 We can and should clean this up as soon as we drop support for older glibcs.
no, see AIX CI
this'll require a bit of ugly |
✅ With the latest revision this PR passed the C/C++ code formatter. |
Can be merged once the CI is green. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/7146 Here is the relevant piece of the build log for the reference
|
Looks like this healed our bots too, so I suppose the problem was with android sysroots, not with linux sysroots. Sorry for the noise! |
PR #109211 introduced a build break on systems with glibc < 2.27, since copy_file_range was only introduced after that version. A version check is added to prevent this breakage.