-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc++] Fix Newlib check in __fwd/ios.h #168952
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
base: main
Are you sure you want to change the base?
Conversation
_NEWLIB_VERSION is only visible when any libc header is included. I ran into a weird case where during libc++ compilation, __fwd/ios.h did not see _NEWLIB_VERSION and defined off_t as `long long`, but in the actual user program, _NEWLIB_VERSION was visible, so the program tried to use a `long int` instead of `long long` specialization of a template function that is provided by libc++.a, and caused linking failure. The new cmake option was also used in another PR that I created; see llvm#167962.
|
@llvm/pr-subscribers-libcxx Author: Chenguang Wang (wecing) Changes_NEWLIB_VERSION is only visible when any libc header is included. I ran into a weird case where during libc++ compilation, __fwd/ios.h did not see _NEWLIB_VERSION and defined off_t as The new cmake option was also used in another PR that I created; see #167962. Full diff: https://github.com/llvm/llvm-project/pull/168952.diff 3 Files Affected:
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 1423b6713fd35..fabfb126d06f3 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -298,6 +298,7 @@ endif()
# Feature options -------------------------------------------------------------
option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
+option(LIBCXX_HAS_NEWLIB_LIBC "Build libc++ with support for the Newlib C library" OFF)
option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF)
option(LIBCXX_HAS_EXTERNAL_THREAD_API
@@ -754,6 +755,7 @@ config_define(${LIBCXX_HAS_PTHREAD_API} _LIBCPP_HAS_THREAD_API_PTHREAD)
config_define(${LIBCXX_HAS_EXTERNAL_THREAD_API} _LIBCPP_HAS_THREAD_API_EXTERNAL)
config_define(${LIBCXX_HAS_WIN32_THREAD_API} _LIBCPP_HAS_THREAD_API_WIN32)
config_define(${LIBCXX_HAS_MUSL_LIBC} _LIBCPP_HAS_MUSL_LIBC)
+config_define(${LIBCXX_HAS_NEWLIB_LIBC} _LIBCPP_HAS_NEWLIB_LIBC)
config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
config_define(${LIBCXX_ENABLE_FILESYSTEM} _LIBCPP_HAS_FILESYSTEM)
config_define(${LIBCXX_ENABLE_RANDOM_DEVICE} _LIBCPP_HAS_RANDOM_DEVICE)
diff --git a/libcxx/include/__config_site.in b/libcxx/include/__config_site.in
index 6dcca1849a96c..6521cf7c51c96 100644
--- a/libcxx/include/__config_site.in
+++ b/libcxx/include/__config_site.in
@@ -17,6 +17,7 @@
#cmakedefine01 _LIBCPP_HAS_MONOTONIC_CLOCK
#cmakedefine01 _LIBCPP_HAS_TERMINAL
#cmakedefine01 _LIBCPP_HAS_MUSL_LIBC
+#cmakedefine01 _LIBCPP_HAS_NEWLIB_LIBC
#cmakedefine01 _LIBCPP_HAS_THREAD_API_PTHREAD
#cmakedefine01 _LIBCPP_HAS_THREAD_API_EXTERNAL
#cmakedefine01 _LIBCPP_HAS_THREAD_API_WIN32
diff --git a/libcxx/include/__fwd/ios.h b/libcxx/include/__fwd/ios.h
index 831624f4b1c57..96505e615693c 100644
--- a/libcxx/include/__fwd/ios.h
+++ b/libcxx/include/__fwd/ios.h
@@ -31,7 +31,7 @@ using wios = basic_ios<wchar_t>;
template <class _CharT, class _Traits>
class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios;
-#if defined(_NEWLIB_VERSION)
+#if _LIBCPP_HAS_NEWLIB_LIBC
// On newlib, off_t is 'long int'
using streamoff = long int; // for char_traits in <string>
#else
|
|
Added @mplatings for the CI changes |
philnik777
left a comment
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'm pretty sure #147956 fixes your problems.
_NEWLIB_VERSION is only visible when any libc header is included. I ran into a weird case where during libc++ compilation, __fwd/ios.h did not see _NEWLIB_VERSION and defined off_t as
long long, but in the actual user program, _NEWLIB_VERSION was visible, so the program tried to use along intinstead oflong longspecialization of a template function that is provided by libc++.a, and caused linking failure.The new cmake option was also used in another PR that I created; see #167962.