Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 7697475

Browse files
committed
[Weekly]: Merge from branch main of upstream
1 parent bee54d9 commit 7697475

18 files changed

+269
-44
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
187187
llvm-readelf
188188
llvm-readobj
189189
llvm-size
190+
llvm-strings
190191
llvm-strip
191192
llvm-symbolizer
192193
LTO
@@ -2038,7 +2039,7 @@ configure_file(
20382039
)
20392040

20402041
set(multilib_yaml_depends
2041-
"${CMAKE_CURRENT_SOURCE_DIR}/multilib-fpus.py"
2042+
"${CMAKE_CURRENT_SOURCE_DIR}/multilib-generate.py"
20422043
"${CMAKE_CURRENT_BINARY_DIR}/multilib-without-fpus.yaml"
20432044
)
20442045
if(LIBS_DEPEND_ON_TOOLS)
@@ -2050,7 +2051,7 @@ add_custom_command(
20502051
COMMAND ${CMAKE_COMMAND} -E copy
20512052
${CMAKE_CURRENT_BINARY_DIR}/multilib-without-fpus.yaml
20522053
${CMAKE_CURRENT_BINARY_DIR}/llvm/${TARGET_LIBRARIES_DIR}${library_subdir}/multilib.yaml
2053-
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/multilib-fpus.py"
2054+
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/multilib-generate.py"
20542055
"--clang=${LLVM_BINARY_DIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}"
20552056
"--llvm-source=${llvmproject_SOURCE_DIR}"
20562057
>> "${CMAKE_CURRENT_BINARY_DIR}/llvm/${TARGET_LIBRARIES_DIR}${library_subdir}/multilib.yaml"

docs/Screenshot_L4R5.png

231 Bytes
Loading

docs/Screenshot_U5A9.png

-14.5 KB
Loading

docs/llvmlibc.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ following command line options, in addition to `--target`, `-march` or
4747
the symbol `__stack` in addition to whatever other memory layout you
4848
want.
4949

50+
* `-Wl,__llvm_libc_heap_limit=0x`_nnnnnn_ if you are using the heap.
51+
The heap start defined by the value of the symbol `_end` which will
52+
be defined by the linker if no linker script is used. Alternatively
53+
use a linker script that defines the symbols `_end` and
54+
`__llvm_libc_heap_limit` in addition to whatever other memory layout
55+
you want.
56+
5057
For example:
5158

5259
```
@@ -55,9 +62,6 @@ clang --config=llvmlibc.cfg --target=arm-none-eabi -march=armv7m -o hello hello.
5562

5663
## Limitations of LLVM libc in LLVM Embedded Toolchain for Arm
5764

58-
At present, this toolchain only builds LLVM libc for AArch32, not for
59-
AArch64.
60-
6165
At present, this toolchain does not build any C++ libraries to go with
6266
LLVM libc.
6367

multilib-fpus.py renamed to multilib-generate.py

Lines changed: 120 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

3-
"""Auto-generate implications between -mfpu options for multilib.yaml.in.
3+
"""Auto-generate implications between command-line options options for
4+
multilib.yaml.in.
45
56
Each FPU name that clang knows about is mapped to all the FPU names
67
that clang considers to be a subset of it (determined by extracting
@@ -21,13 +22,28 @@
2122
d-registers, because the extra 16 d-registers are caller-saved, so
2223
setjmp and exceptions need not preserve them. Interrupt handlers would
2324
have to preserve them, but our libraries don't define any.
25+
26+
For architecture extension modifiers on the -march option, we expand these into
27+
options of the form -march=armvX+[no]feature, for each feature which is listed
28+
as enabled or disabled in the input options. Each of these new options has
29+
exactly one feature, so the multilib file can mark a library as depending on
30+
any set of by matching multiple options. The "armvX" architecture version isn't
31+
a valid option, but that doesn't matter to multilib, and means that we don't
32+
need to repeat the matching for every minor version.
33+
34+
For architecture versions, we expand -march=armvX.Y-a+features to include every
35+
lower or equal architecture version, so that if, for example, a library
36+
requires armv8.3-a, then a link command targeting any later version will be
37+
able to select it. These generated options don't include the feature modifiers,
38+
which can be matched separately if a library requires them.
2439
"""
2540

2641
import argparse
2742
import json
2843
import os
2944
import shlex
3045
import subprocess
46+
from dataclasses import dataclass
3147

3248

3349
def get_fpu_list(args):
@@ -164,21 +180,7 @@ def get_target_features(args, fpu):
164180
return features
165181

166182

167-
def main():
168-
parser = argparse.ArgumentParser(
169-
description=__doc__,
170-
formatter_class=argparse.RawDescriptionHelpFormatter,
171-
)
172-
parser.add_argument(
173-
"--clang", required=True, help="Path to clang executable."
174-
)
175-
parser.add_argument(
176-
"--llvm-source",
177-
required=True,
178-
help="Path to root of llvm-project source tree.",
179-
)
180-
args = parser.parse_args()
181-
183+
def generate_fpus(args):
182184
# Collect all the data: make the list of FPU names, and the set of
183185
# features that LLVM maps each one to.
184186
fpu_features = {
@@ -208,7 +210,109 @@ def main():
208210
print(" Flags:")
209211
for sub_fpu in subsets:
210212
print(" - -mfpu=" + sub_fpu)
213+
print()
214+
215+
216+
def get_extension_list(clang, triple):
217+
"""Extract the list of architecture extension flags from clang, by running
218+
it with the --print-supported-extensions option."""
219+
220+
command = [
221+
clang,
222+
"--target=" + triple,
223+
"--print-supported-extensions",
224+
]
225+
226+
output = subprocess.check_output(
227+
command, stderr=subprocess.STDOUT
228+
).decode()
229+
230+
for line in output.split("\n"):
231+
parts = line.split(maxsplit=1)
232+
# The feature lines will look like this, ignore everything else:
233+
# aes FEAT_AES, FEAT_PMULL Enable AES support
234+
if len(parts) == 2 and parts[1].startswith("FEAT_"):
235+
yield parts[0]
236+
237+
238+
def generate_extensions(args):
239+
aarch64_features = get_extension_list(args.clang, "aarch64-none-eabi")
240+
aarch32_features = get_extension_list(args.clang, "arm-none-eabi")
241+
all_features = set(aarch64_features) | set(aarch32_features)
242+
243+
print("# Expand -march=...+[no]feature... into individual options we can match")
244+
print("# on. We use 'armvX' to represent a feature applied to any architecture, so")
245+
print("# that these don't need to be repeated for every version. Libraries which")
246+
print("# require a particular architecture version or profile should also match on the")
247+
print("# original option to check that.")
248+
249+
for feature in all_features:
250+
print(f"- Match: -march=armv.*\\+{feature}($|\+.*)")
251+
print(f" Flags:")
252+
print(f" - -march=armvX+{feature}")
253+
print(f"- Match: -march=armv.*\\+no{feature}($|\+.*)")
254+
print(f" Flags:")
255+
print(f" - -march=armvX+no{feature}")
256+
print()
257+
258+
259+
@dataclass
260+
class Version:
261+
major: int
262+
minor: int
263+
profile: int
264+
265+
def __str__(self):
266+
if self.minor == 0:
267+
return f"armv{self.major}-{self.profile}"
268+
else:
269+
return f"armv{self.major}.{self.minor}-{self.profile}"
270+
271+
@property
272+
def all_compatible(self):
273+
yield self
274+
for compat_minor in range(self.minor):
275+
yield Version(self.major, compat_minor, self.profile)
276+
if self.major == 9:
277+
for compat_minor in range(self.minor + 5 + 1):
278+
yield Version(self.major - 1, compat_minor, self.profile)
279+
280+
def generate_versions(args):
281+
"""Generate match blocks which allow selecting a library build for a
282+
lower-version architecture, for the v8.x-A and v9.x-A minor versions."""
283+
versions = (
284+
[Version(8, minor, "a") for minor in range(10)] +
285+
[Version(9, minor, "a") for minor in range(6)] +
286+
[Version(8, minor, "r") for minor in range(1)]
287+
)
288+
289+
for match_ver in versions:
290+
print(f"- Match: -march={match_ver}.*")
291+
print(f" Flags:")
292+
for compat_ver in match_ver.all_compatible:
293+
print(f" - -march={compat_ver}")
294+
print()
295+
296+
297+
298+
def main():
299+
parser = argparse.ArgumentParser(
300+
description=__doc__,
301+
formatter_class=argparse.RawDescriptionHelpFormatter,
302+
)
303+
parser.add_argument(
304+
"--clang", required=True, help="Path to clang executable."
305+
)
306+
parser.add_argument(
307+
"--llvm-source",
308+
required=True,
309+
help="Path to root of llvm-project source tree.",
310+
)
311+
args = parser.parse_args()
211312

313+
generate_fpus(args)
314+
generate_extensions(args)
315+
generate_versions(args)
212316

213317
if __name__ == "__main__":
214318
main()

patches/llvm-project/0001-libc-tests-with-picolibc-xfail-one-remaining-test.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From 1db48238bfbc5324dadf828532a4c67524dc471b Mon Sep 17 00:00:00 2001
1+
From fd26b5fd6a882677062a7c495660f22ca2b13cd5 Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Mon, 16 Oct 2023 11:35:48 +0200
4-
Subject: [PATCH] [libc++] tests with picolibc: xfail one remaining test
4+
Subject: [libc++] tests with picolibc: xfail one remaining test
55

66
---
77
.../language.support/support.start.term/quick_exit.pass.cpp | 3 +++
88
1 file changed, 3 insertions(+)
99

1010
diff --git a/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp b/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp
11-
index d8eff69cb5..e16048df72 100644
11+
index d8eff69cb53f..e16048df722e 100644
1212
--- a/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp
1313
+++ b/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp
1414
@@ -17,6 +17,9 @@
@@ -22,5 +22,5 @@ index d8eff69cb5..e16048df72 100644
2222

2323
void f() {}
2424
--
25-
2.34.1
25+
2.39.5 (Apple Git-154)
2626

patches/llvm-project/0002-libc-tests-with-picolibc-disable-large-tests.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 80000ddfade0f706ad1ebb488a51132a88cbe61d Mon Sep 17 00:00:00 2001
1+
From 02175d0f237e5d14c6b59ce6b16818927f10368f Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Wed, 15 Nov 2023 12:18:35 +0100
44
Subject: [libc++] tests with picolibc: disable large tests
@@ -41,7 +41,7 @@ index b5f9089308d2..0a83e75ceceb 100644
4141
set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
4242
find_program(QEMU_SYSTEM_ARM qemu-system-arm REQUIRED)
4343
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
44-
index fe5598991b83..65d30a352814 100644
44+
index 77f79e0d40e8..4b69df08ea28 100644
4545
--- a/libcxxabi/test/test_demangle.pass.cpp
4646
+++ b/libcxxabi/test/test_demangle.pass.cpp
4747
@@ -7,7 +7,7 @@
@@ -54,5 +54,5 @@ index fe5598991b83..65d30a352814 100644
5454
// https://llvm.org/PR51407 was not fixed in some previously-released
5555
// demanglers, which causes them to run into the infinite loop.
5656
--
57-
2.34.1
57+
2.39.5 (Apple Git-154)
5858

patches/llvm-project/0003-Disable-failing-compiler-rt-test.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From c4837fa13ec89cc06b07af8cba8494189520e546 Mon Sep 17 00:00:00 2001
1+
From d1d619643bedea5759ef56ed42c4d97846f3c789 Mon Sep 17 00:00:00 2001
22
From: Piotr Przybyla <[email protected]>
33
Date: Wed, 15 Nov 2023 16:04:24 +0000
44
Subject: Disable failing compiler-rt test
@@ -18,5 +18,5 @@ index 2ff65a8b9ec3..98611a75e85f 100644
1818
// RUN: %clang_builtins %s %librt -o %t && %run %t
1919

2020
--
21-
2.34.1
21+
2.39.5 (Apple Git-154)
2222

patches/llvm-project/0004-libc-tests-with-picolibc-XFAIL-uses-of-atomics.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 3b7ada947d511fe0edb7cca0dbdb640d8e1ecd2b Mon Sep 17 00:00:00 2001
1+
From 46019866b66f8859e7dff666c519c35d5b921291 Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Thu, 9 Nov 2023 15:25:14 +0100
44
Subject: [libc++] tests with picolibc: XFAIL uses of atomics
@@ -88,10 +88,10 @@ index 000000000000..5ecc58f3e385
8888
+if "has-no-atomics" in config.available_features:
8989
+ config.unsupported = True
9090
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
91-
index 6ef40755c59d..6c2960260189 100644
91+
index 15456171b548..ddd44a63c618 100644
9292
--- a/libcxx/utils/libcxx/test/features.py
9393
+++ b/libcxx/utils/libcxx/test/features.py
94-
@@ -206,6 +206,21 @@ DEFAULT_FEATURES = [
94+
@@ -215,6 +215,21 @@ DEFAULT_FEATURES = [
9595
""",
9696
),
9797
),
@@ -114,5 +114,5 @@ index 6ef40755c59d..6c2960260189 100644
114114
Feature(
115115
name="32-bit-pointer",
116116
--
117-
2.34.1
117+
2.39.5 (Apple Git-154)
118118

patches/llvm-project/0005-libc-tests-with-picolibc-mark-two-more-large-tests.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 8eb9344a4ba97b45cea1a6adec98aff6c6149359 Mon Sep 17 00:00:00 2001
1+
From e3d01a7a6d51fe1f2d605a49123e72e2f493a532 Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Dominik=20W=C3=B3jt?= <[email protected]>
33
Date: Wed, 22 Nov 2023 16:12:39 +0100
44
Subject: [libc++] tests with picolibc: mark two more large tests
@@ -37,5 +37,5 @@ index 64a6a135adda..057301e6f868 100644
3737
// bool
3838
// regex_search(BidirectionalIterator first, BidirectionalIterator last,
3939
--
40-
2.34.1
40+
2.39.5 (Apple Git-154)
4141

0 commit comments

Comments
 (0)