diff options
author | Khem Raj <raj.khem@gmail.com> | 2024-09-05 20:58:41 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2024-09-05 21:56:45 -0700 |
commit | 8937be5718b5bc398d3f4ce0111635c700af636f (patch) | |
tree | d216e37b598325556ba43eb4e0631f8df8e10cb0 | |
parent | fb7e45fcbff00dfbe9a03023582b9a1d3184f6fc (diff) | |
download | meta-openembedded-8937be5718b5bc398d3f4ce0111635c700af636f.tar.gz |
nodejs: Fix build with libc++ 19
As noted in the libc++ 19 release notes [1], std::char_traits<> is now
only provided for char, char8_t, char16_t, char32_t and wchar_t, and any
instantiation for other types will fail.
This causes nodejs-20 to fail to compile with clang 19 and libc++ 19,
resulting in errors similar to:
/usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
820 | static_assert(is_same<_CharT, typename traits_type::char_type>::value,
| ^
../deps/v8/src/inspector/string-16.h:114:28: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
114 | std::basic_string<UChar> m_impl;
| ^
/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
| ^
Upstream v8 has fixed this in commit 182d9c05e78 [2], so add it as a
backported patch, until the next version of node is released.
[1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals
[2] https://chromium.googlesource.com/v8/v8.git/+/182d9c05e78
Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r-- | meta-oe/recipes-devtools/nodejs/nodejs/182d9c05e78.patch | 182 | ||||
-rw-r--r-- | meta-oe/recipes-devtools/nodejs/nodejs_20.17.0.bb | 1 |
2 files changed, 183 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/182d9c05e78.patch b/meta-oe/recipes-devtools/nodejs/nodejs/182d9c05e78.patch new file mode 100644 index 0000000000..689512cb64 --- /dev/null +++ b/meta-oe/recipes-devtools/nodejs/nodejs/182d9c05e78.patch | |||
@@ -0,0 +1,182 @@ | |||
1 | From 182d9c05e78b1ddb1cb8242cd3628a7855a0336f Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrey Kosyakov <caseq@chromium.org> | ||
3 | Date: Thu, 17 Aug 2023 13:50:11 -0700 | ||
4 | Subject: [PATCH] Define UChar as char16_t | ||
5 | |||
6 | We used to have UChar defined as uint16_t which does not go along | ||
7 | with STL these days if you try to have an std::basic_string<> of it, | ||
8 | as there are no standard std::char_traits<> specialization for uint16_t. | ||
9 | |||
10 | This switches UChar to char16_t where practical, introducing a few | ||
11 | compatibility shims to keep CL size small, as (1) this would likely | ||
12 | have to be back-ported and (2) crdtp extensively uses uint16_t for | ||
13 | wide chars. | ||
14 | |||
15 | Bug: b:296390693 | ||
16 | Change-Id: I66a32d8f0050915225b187de56896c26dd76163d | ||
17 | Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4789966 | ||
18 | Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> | ||
19 | Commit-Queue: Jaroslav Sevcik <jarin@chromium.org> | ||
20 | Auto-Submit: Andrey Kosyakov <caseq@chromium.org> | ||
21 | Cr-Commit-Position: refs/heads/main@{#89559} | ||
22 | |||
23 | Upstream-Status: Backport [https://chromium-review.googlesource.com/c/v8/v8/+/4789966] | ||
24 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
25 | --- | ||
26 | src/inspector/string-16.cc | 8 +++++++- | ||
27 | src/inspector/string-16.h | 10 ++++++++-- | ||
28 | src/inspector/v8-string-conversions.cc | 6 +++--- | ||
29 | src/inspector/v8-string-conversions.h | 6 ++++-- | ||
30 | .../inspector_protocol/crdtp/test_platform_v8.cc | 9 ++++++--- | ||
31 | 5 files changed, 28 insertions(+), 11 deletions(-) | ||
32 | |||
33 | --- a/deps/v8/src/inspector/string-16.cc | ||
34 | +++ b/deps/v8/src/inspector/string-16.cc | ||
35 | @@ -27,7 +27,7 @@ bool isSpaceOrNewLine(UChar c) { | ||
36 | return isASCII(c) && c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); | ||
37 | } | ||
38 | |||
39 | -int64_t charactersToInteger(const UChar* characters, size_t length, | ||
40 | +int64_t charactersToInteger(const uint16_t* characters, size_t length, | ||
41 | bool* ok = nullptr) { | ||
42 | std::vector<char> buffer; | ||
43 | buffer.reserve(length + 1); | ||
44 | @@ -50,6 +50,8 @@ int64_t charactersToInteger(const UChar* | ||
45 | |||
46 | String16::String16(const UChar* characters, size_t size) | ||
47 | : m_impl(characters, size) {} | ||
48 | +String16::String16(const uint16_t* characters, size_t size) | ||
49 | + : m_impl(reinterpret_cast<const UChar*>(characters), size) {} | ||
50 | |||
51 | String16::String16(const UChar* characters) : m_impl(characters) {} | ||
52 | |||
53 | @@ -241,6 +243,10 @@ String16 String16::fromUTF16LE(const UCh | ||
54 | #endif // V8_TARGET_BIG_ENDIAN | ||
55 | } | ||
56 | |||
57 | +String16 String16::fromUTF16LE(const uint16_t* stringStart, size_t length) { | ||
58 | + return fromUTF16LE(reinterpret_cast<const UChar*>(stringStart), length); | ||
59 | +} | ||
60 | + | ||
61 | std::string String16::utf8() const { | ||
62 | return UTF16ToUTF8(m_impl.data(), m_impl.size()); | ||
63 | } | ||
64 | --- a/deps/v8/src/inspector/string-16.h | ||
65 | +++ b/deps/v8/src/inspector/string-16.h | ||
66 | @@ -6,6 +6,7 @@ | ||
67 | #define V8_INSPECTOR_STRING_16_H_ | ||
68 | |||
69 | #include <stdint.h> | ||
70 | +#include <uchar.h> | ||
71 | |||
72 | #include <cctype> | ||
73 | #include <climits> | ||
74 | @@ -17,7 +18,7 @@ | ||
75 | |||
76 | namespace v8_inspector { | ||
77 | |||
78 | -using UChar = uint16_t; | ||
79 | +using UChar = char16_t; | ||
80 | |||
81 | class String16 { | ||
82 | public: | ||
83 | @@ -27,6 +28,7 @@ class String16 { | ||
84 | String16(const String16&) V8_NOEXCEPT = default; | ||
85 | String16(String16&&) V8_NOEXCEPT = default; | ||
86 | String16(const UChar* characters, size_t size); | ||
87 | + String16(const uint16_t* characters, size_t size); | ||
88 | V8_EXPORT String16(const UChar* characters); | ||
89 | V8_EXPORT String16(const char* characters); | ||
90 | String16(const char* characters, size_t size); | ||
91 | @@ -48,7 +50,9 @@ class String16 { | ||
92 | int toInteger(bool* ok = nullptr) const; | ||
93 | std::pair<size_t, size_t> getTrimmedOffsetAndLength() const; | ||
94 | String16 stripWhiteSpace() const; | ||
95 | - const UChar* characters16() const { return m_impl.c_str(); } | ||
96 | + const uint16_t* characters16() const { | ||
97 | + return reinterpret_cast<const uint16_t*>(m_impl.c_str()); | ||
98 | + } | ||
99 | size_t length() const { return m_impl.length(); } | ||
100 | bool isEmpty() const { return !m_impl.length(); } | ||
101 | UChar operator[](size_t index) const { return m_impl[index]; } | ||
102 | @@ -78,6 +82,8 @@ class String16 { | ||
103 | // On Big endian architectures, byte order needs to be flipped. | ||
104 | V8_EXPORT static String16 fromUTF16LE(const UChar* stringStart, | ||
105 | size_t length); | ||
106 | + V8_EXPORT static String16 fromUTF16LE(const uint16_t* stringStart, | ||
107 | + size_t length); | ||
108 | |||
109 | std::size_t hash() const { | ||
110 | if (!hash_code) { | ||
111 | --- a/deps/v8/src/inspector/v8-string-conversions.cc | ||
112 | +++ b/deps/v8/src/inspector/v8-string-conversions.cc | ||
113 | @@ -12,7 +12,7 @@ | ||
114 | |||
115 | namespace v8_inspector { | ||
116 | namespace { | ||
117 | -using UChar = uint16_t; | ||
118 | +using UChar = char16_t; | ||
119 | using UChar32 = uint32_t; | ||
120 | |||
121 | bool isASCII(UChar c) { return !(c & ~0x7F); } | ||
122 | @@ -386,7 +386,7 @@ std::string UTF16ToUTF8(const UChar* str | ||
123 | |||
124 | std::basic_string<UChar> UTF8ToUTF16(const char* stringStart, size_t length) { | ||
125 | if (!stringStart || !length) return std::basic_string<UChar>(); | ||
126 | - std::vector<uint16_t> buffer(length); | ||
127 | + std::vector<UChar> buffer(length); | ||
128 | UChar* bufferStart = buffer.data(); | ||
129 | |||
130 | UChar* bufferCurrent = bufferStart; | ||
131 | @@ -395,7 +395,7 @@ std::basic_string<UChar> UTF8ToUTF16(con | ||
132 | reinterpret_cast<const char*>(stringStart + length), | ||
133 | &bufferCurrent, bufferCurrent + buffer.size(), nullptr, | ||
134 | true) != conversionOK) | ||
135 | - return std::basic_string<uint16_t>(); | ||
136 | + return std::basic_string<UChar>(); | ||
137 | size_t utf16Length = bufferCurrent - bufferStart; | ||
138 | return std::basic_string<UChar>(bufferStart, bufferStart + utf16Length); | ||
139 | } | ||
140 | --- a/deps/v8/src/inspector/v8-string-conversions.h | ||
141 | +++ b/deps/v8/src/inspector/v8-string-conversions.h | ||
142 | @@ -5,14 +5,16 @@ | ||
143 | #ifndef V8_INSPECTOR_V8_STRING_CONVERSIONS_H_ | ||
144 | #define V8_INSPECTOR_V8_STRING_CONVERSIONS_H_ | ||
145 | |||
146 | +#include <uchar.h> | ||
147 | + | ||
148 | #include <cstdint> | ||
149 | #include <string> | ||
150 | |||
151 | // Conversion routines between UT8 and UTF16, used by string-16.{h,cc}. You may | ||
152 | // want to use string-16.h directly rather than these. | ||
153 | namespace v8_inspector { | ||
154 | -std::basic_string<uint16_t> UTF8ToUTF16(const char* stringStart, size_t length); | ||
155 | -std::string UTF16ToUTF8(const uint16_t* stringStart, size_t length); | ||
156 | +std::basic_string<char16_t> UTF8ToUTF16(const char* stringStart, size_t length); | ||
157 | +std::string UTF16ToUTF8(const char16_t* stringStart, size_t length); | ||
158 | } // namespace v8_inspector | ||
159 | |||
160 | #endif // V8_INSPECTOR_V8_STRING_CONVERSIONS_H_ | ||
161 | --- a/deps/v8/third_party/inspector_protocol/crdtp/test_platform_v8.cc | ||
162 | +++ b/deps/v8/third_party/inspector_protocol/crdtp/test_platform_v8.cc | ||
163 | @@ -11,13 +11,16 @@ | ||
164 | namespace v8_crdtp { | ||
165 | |||
166 | std::string UTF16ToUTF8(span<uint16_t> in) { | ||
167 | - return v8_inspector::UTF16ToUTF8(in.data(), in.size()); | ||
168 | + return v8_inspector::UTF16ToUTF8(reinterpret_cast<const char16_t*>(in.data()), | ||
169 | + in.size()); | ||
170 | } | ||
171 | |||
172 | std::vector<uint16_t> UTF8ToUTF16(span<uint8_t> in) { | ||
173 | - std::basic_string<uint16_t> utf16 = v8_inspector::UTF8ToUTF16( | ||
174 | + std::basic_string<char16_t> utf16 = v8_inspector::UTF8ToUTF16( | ||
175 | reinterpret_cast<const char*>(in.data()), in.size()); | ||
176 | - return std::vector<uint16_t>(utf16.begin(), utf16.end()); | ||
177 | + return std::vector<uint16_t>( | ||
178 | + reinterpret_cast<const uint16_t*>(utf16.data()), | ||
179 | + reinterpret_cast<const uint16_t*>(utf16.data()) + utf16.size()); | ||
180 | } | ||
181 | |||
182 | } // namespace v8_crdtp | ||
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_20.17.0.bb b/meta-oe/recipes-devtools/nodejs/nodejs_20.17.0.bb index fee2eeaf9e..38e5ca9ff1 100644 --- a/meta-oe/recipes-devtools/nodejs/nodejs_20.17.0.bb +++ b/meta-oe/recipes-devtools/nodejs/nodejs_20.17.0.bb | |||
@@ -25,6 +25,7 @@ SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ | |||
25 | file://system-c-ares.patch \ | 25 | file://system-c-ares.patch \ |
26 | file://0001-liftoff-Correct-function-signatures.patch \ | 26 | file://0001-liftoff-Correct-function-signatures.patch \ |
27 | file://libatomic.patch \ | 27 | file://libatomic.patch \ |
28 | file://182d9c05e78.patch \ | ||
28 | file://run-ptest \ | 29 | file://run-ptest \ |
29 | " | 30 | " |
30 | SRC_URI:append:class-target = " \ | 31 | SRC_URI:append:class-target = " \ |