[llvm] WIP - [DTLTO][TEST] Add a test for Unicode characters (PR #194823)
Ben Dunbobbin via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 03:03:01 PDT 2026
https://github.com/bd1976bris created https://github.com/llvm/llvm-project/pull/194823
Add a test to verify that Unicode characters in paths and symbols are preserved correctly.
This was broken until recently; see: https://github.com/llvm/llvm-project/issues/194318
>From 9c0d8426be1e9bfd77795c5088d4c68b509b1583 Mon Sep 17 00:00:00 2001
From: Ben <ben.dunbobbin at sony.com>
Date: Wed, 29 Apr 2026 10:56:56 +0100
Subject: [PATCH] [DTLTO][TEST] Add a test for Unicode characters
Add a test to verify that Unicode characters in paths and symbols are
preserved correctly.
This was broken until recently; see:
https://github.com/llvm/llvm-project/issues/194318
---
cross-project-tests/dtlto/unicode.test | 70 ++++++++++++++++++++++++++
llvm/utils/dtlto/local.py | 4 +-
2 files changed, 72 insertions(+), 2 deletions(-)
create mode 100644 cross-project-tests/dtlto/unicode.test
diff --git a/cross-project-tests/dtlto/unicode.test b/cross-project-tests/dtlto/unicode.test
new file mode 100644
index 0000000000000..4b9b92ad22184
--- /dev/null
+++ b/cross-project-tests/dtlto/unicode.test
@@ -0,0 +1,70 @@
+# Test that DTLTO handles Unicode characters in paths and symbols for
+# archive members, thin archive members, and FatLTO inputs.
+
+REQUIRES: ld.lld, llvm-ar
+
+RUN: rm -rf %t && split-file %s %t && mkdir %t/📁 && cd %t/📁
+
+# Compile bitcode. -O2 is required for cross-module importing.
+RUN: %clang --target=x86_64-linux-gnu -O2 -flto=thin -c ../α.c ../β.c ../δ.c
+RUN: %clang --target=x86_64-linux-gnu -O2 -flto=thin -ffat-lto-objects -c ../γ.c
+
+# Create an archive and a thin archive.
+RUN: llvm-ar rcs 🎁.a α.o
+RUN: llvm-ar rcsT 📦.a β.o
+
+# Build with DTLTO.
+RUN: %clang --target=x86_64-linux-gnu -O2 -flto=thin -ffat-lto-objects \
+RUN: -fuse-ld=lld -nostdlib -shared -fthinlto-distributor=%python \
+RUN: -Xthinlto-distributor=%llvm_src_root/utils/dtlto/local.py \
+RUN: -Wl,--save-temps -Wl,--whole-archive 🎁.a 📦.a γ.o δ.o -o 💾.so
+
+# Check that the temporary file names preserve the Unicode symbols.
+RUN: ls | FileCheck %s --check-prefix=FILES
+
+# Archive member: 🎁.a(α.o).
+FILES-DAG: {{^}}🎁.a(α.o at [[#OFFSET:]]).1.[[#%X,HEXPID:]].1.[[#PID:]].native.o{{$}}
+FILES-DAG: {{^}}🎁.a(α.o at [[#OFFSET]]).1.[[#%X,HEXPID]].1.[[#PID]].native.o.thinlto.bc{{$}}
+FILES-DAG: {{^}}🎁.a(α.o at [[#OFFSET]]).1.[[#%X,HEXPID]].o{{$}}
+
+# Thin archive member: 📦.a(β.o).
+FILES-DAG: {{^}}β.2.[[#PID]].native.o{{$}}
+FILES-DAG: {{^}}β.2.[[#PID]].native.o.thinlto.bc{{$}}
+
+# FatLTO object: γ.o.
+FILES-DAG: {{^}}γ.o.3.[[#%X,HEXPID]].3.[[#PID]].native.o{{$}}
+FILES-DAG: {{^}}γ.o.3.[[#%X,HEXPID]].3.[[#PID]].native.o.thinlto.bc{{$}}
+FILES-DAG: {{^}}γ.o.3.[[#%X,HEXPID]].o{{$}}
+
+# Bitcode input: δ.o.
+FILES-DAG: {{^}}δ.4.[[#PID]].native.o{{$}}
+FILES-DAG: {{^}}δ.4.[[#PID]].native.o.thinlto.bc{{$}}
+
+# JSON file for the distributor.
+FILES-DAG: {{^}}💾.[[#PID]].dist-file.json{{$}}
+
+# Check that the final DTLTO-linked shared library exports the expected
+# symbol names.
+RUN: llvm-nm -D -j 💾.so | FileCheck %s --check-prefix=SYMS
+
+SYMS-DAG: {{^}}α{{$}}
+SYMS-DAG: {{^}}β{{$}}
+SYMS-DAG: {{^}}γ{{$}}
+SYMS-DAG: {{^}}δ{{$}}
+
+#--- α.c
+__attribute__((retain)) int α(int x) { return x; }
+
+#--- β.c
+__attribute__((retain)) int β(int x) { return x; }
+
+#--- γ.c
+__attribute__((retain)) int γ(int x) { return x; }
+
+#--- δ.c
+extern int α(int);
+extern int β(int);
+extern int γ(int);
+__attribute__((retain)) int δ(int x) {
+ return α(x) + β(x) + γ(x);
+}
diff --git a/llvm/utils/dtlto/local.py b/llvm/utils/dtlto/local.py
index 304b1bcb46026..85c84184c152f 100644
--- a/llvm/utils/dtlto/local.py
+++ b/llvm/utils/dtlto/local.py
@@ -20,8 +20,8 @@
if __name__ == "__main__":
# Load the DTLTO information from the input JSON file.
- with Path(sys.argv[-1]).open() as f:
- data = json.load(f)
+ with Path(sys.argv[-1]).open(encoding="utf-8") as f:
+ data = json.load(f)
# Iterate over the jobs and execute the codegen tool.
for job in data["jobs"]:
More information about the llvm-commits
mailing list