-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] Remove transitive <locale> include from <vector> #80282
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
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThis reduces the time to include Full diff: https://github.com/llvm/llvm-project/pull/80282.diff 9 Files Affected:
diff --git a/libcxx/include/__format/formatter_bool.h b/libcxx/include/__format/formatter_bool.h
index 1c479501b675f..5e3daff7b3dba 100644
--- a/libcxx/include/__format/formatter_bool.h
+++ b/libcxx/include/__format/formatter_bool.h
@@ -22,7 +22,7 @@
#include <__utility/unreachable.h>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-# include <locale>
+# include <__locale>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__format/formatter_integral.h b/libcxx/include/__format/formatter_integral.h
index e0217a240027c..eca966f8886f8 100644
--- a/libcxx/include/__format/formatter_integral.h
+++ b/libcxx/include/__format/formatter_integral.h
@@ -32,7 +32,7 @@
#include <string_view>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-# include <locale>
+# include <__locale>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/vector b/libcxx/include/vector
index e9dd57055cb11..6b0bdb960203c 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -2972,6 +2972,7 @@ _LIBCPP_POP_MACROS
# include <atomic>
# include <concepts>
# include <cstdlib>
+# include <locale>
# include <type_traits>
# include <typeinfo>
# include <utility>
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 21f0138b1b4bb..5eb839a3aa7a6 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -839,13 +839,17 @@ system_error type_traits
system_error version
thread array
thread atomic
+thread cctype
thread cerrno
thread chrono
+thread clocale
thread compare
thread cstddef
thread cstdint
+thread cstdlib
thread cstring
thread ctime
+thread cwchar
thread functional
thread iosfwd
thread limits
@@ -954,8 +958,10 @@ variant version
vector algorithm
vector array
vector atomic
+vector cctype
vector cerrno
vector climits
+vector clocale
vector compare
vector concepts
vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 71d1735d79487..7b372fb37dcd5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -841,13 +841,17 @@ system_error type_traits
system_error version
thread array
thread atomic
+thread cctype
thread cerrno
thread chrono
+thread clocale
thread compare
thread cstddef
thread cstdint
+thread cstdlib
thread cstring
thread ctime
+thread cwchar
thread functional
thread iosfwd
thread limits
@@ -956,8 +960,10 @@ variant version
vector algorithm
vector array
vector atomic
+vector cctype
vector cerrno
vector climits
+vector clocale
vector compare
vector concepts
vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 71d1735d79487..7b372fb37dcd5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -841,13 +841,17 @@ system_error type_traits
system_error version
thread array
thread atomic
+thread cctype
thread cerrno
thread chrono
+thread clocale
thread compare
thread cstddef
thread cstdint
+thread cstdlib
thread cstring
thread ctime
+thread cwchar
thread functional
thread iosfwd
thread limits
@@ -956,8 +960,10 @@ variant version
vector algorithm
vector array
vector atomic
+vector cctype
vector cerrno
vector climits
+vector clocale
vector compare
vector concepts
vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 4d4372275eb82..9b4915a468d1c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -846,12 +846,16 @@ system_error type_traits
system_error version
thread array
thread atomic
+thread cctype
thread cerrno
+thread clocale
thread compare
thread cstddef
thread cstdint
+thread cstdlib
thread cstring
thread ctime
+thread cwchar
thread functional
thread iosfwd
thread limits
@@ -960,8 +964,10 @@ variant version
vector algorithm
vector array
vector atomic
+vector cctype
vector cerrno
vector climits
+vector clocale
vector compare
vector concepts
vector cstddef
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 94c67307cc2f1..7c7099d176f18 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -585,11 +585,16 @@ system_error string
system_error version
thread array
thread atomic
+thread cctype
thread cerrno
+thread clocale
thread compare
thread cstddef
thread cstdint
+thread cstdlib
+thread cstring
thread ctime
+thread cwchar
thread initializer_list
thread iosfwd
thread limits
@@ -601,6 +606,7 @@ thread stdexcept
thread string
thread string_view
thread tuple
+thread typeinfo
thread version
tuple compare
tuple cstddef
@@ -658,20 +664,23 @@ variant new
variant tuple
variant version
vector array
+vector cctype
vector cerrno
vector climits
+vector clocale
vector compare
vector cstddef
vector cstdint
+vector cstdlib
vector cstring
vector cwchar
vector initializer_list
vector iosfwd
vector limits
-vector locale
vector new
vector stdexcept
vector string
vector string_view
vector tuple
+vector typeinfo
vector version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 94c67307cc2f1..7c7099d176f18 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -585,11 +585,16 @@ system_error string
system_error version
thread array
thread atomic
+thread cctype
thread cerrno
+thread clocale
thread compare
thread cstddef
thread cstdint
+thread cstdlib
+thread cstring
thread ctime
+thread cwchar
thread initializer_list
thread iosfwd
thread limits
@@ -601,6 +606,7 @@ thread stdexcept
thread string
thread string_view
thread tuple
+thread typeinfo
thread version
tuple compare
tuple cstddef
@@ -658,20 +664,23 @@ variant new
variant tuple
variant version
vector array
+vector cctype
vector cerrno
vector climits
+vector clocale
vector compare
vector cstddef
vector cstdint
+vector cstdlib
vector cstring
vector cwchar
vector initializer_list
vector iosfwd
vector limits
-vector locale
vector new
vector stdexcept
vector string
vector string_view
vector tuple
+vector typeinfo
vector version
|
608c27b
to
3436f76
Compare
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.
LGTM with the CI green and the clang-tidy change split up elsewhere.
3436f76
to
5ffbaf6
Compare
This reduces the time to include `<vector>` from 468ms to 367ms.
This is a follow-up to llvm#80282. The transitive includes of `<locale>` in `<vector>` were all guarded by the availability macro -- the new include should also be guarded, otherwise any users who compile with localization disabled will start getting errors trying to include `<vector>`.
After llvm/llvm-project#80282, `formatter_integral.h` includes not `locale` but `_locale` https://github.com/llvm/llvm-project/blame/aadaa00de76ed0c4987b97450dd638f63a385bed/libcxx/include/__format/formatter_integral.h#L35 and after several more include changes this causes https://github.com/llvm/llvm-project/blob/aadaa00de76ed0c4987b97450dd638f63a385bed/libcxx/include/__thread/support/pthread.h not to be included when https://github.com/emscripten-core/emscripten/blob/main/system/include/emscripten/val.h is included. `pthread.h` is where `pthread_t` is defined, which is used here: https://github.com/emscripten-core/emscripten/blob/fb14f6d9fc2b00fea36af0f5ca4e996f61520b8f/system/include/emscripten/val.h#L676 Until LLVM 18, the contents of https://github.com/llvm/llvm-project/blob/aadaa00de76ed0c4987b97450dd638f63a385bed/libcxx/include/__thread/support/pthread.h was in https://github.com/llvm/llvm-project/blob/3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff/libcxx/include/__threading_support, which was split off to several files in llvm/llvm-project#79654. This file was (transitively) included from `locale`. Anyway, this commit just adds `#include <pthread.h>` directly to `val.h`.
After llvm/llvm-project#80282, `formatter_integral.h` includes not `locale` but `_locale` https://github.com/llvm/llvm-project/blame/aadaa00de76ed0c4987b97450dd638f63a385bed/libcxx/include/__format/formatter_integral.h#L35 and after several more include changes this causes https://github.com/llvm/llvm-project/blob/aadaa00de76ed0c4987b97450dd638f63a385bed/libcxx/include/__thread/support/pthread.h not to be included when https://github.com/emscripten-core/emscripten/blob/main/system/include/emscripten/val.h is included. `pthread.h` is where `pthread_t` is defined, which is used here: https://github.com/emscripten-core/emscripten/blob/fb14f6d9fc2b00fea36af0f5ca4e996f61520b8f/system/include/emscripten/val.h#L676 Until LLVM 18, the contents of https://github.com/llvm/llvm-project/blob/aadaa00de76ed0c4987b97450dd638f63a385bed/libcxx/include/__thread/support/pthread.h was in https://github.com/llvm/llvm-project/blob/3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff/libcxx/include/__threading_support, which was split off to several files in llvm/llvm-project#79654. This file was (transitively) included from `locale`. Anyway, this commit just adds `#include <pthread.h>` directly to `val.h`.
…ro (#95686) This is a follow-up to llvm/llvm-project#80282. The transitive includes of `<locale>` in `<vector>` were all guarded by the availability macro -- the new include should also be guarded, otherwise any users who compile with localization disabled will start getting errors trying to include `<vector>`. NOKEYCHECK=True GitOrigin-RevId: 0cfdce854d588876bfca7030be868314e84c0e5b
This reduces the time to include
<vector>
from 468ms to 367ms.