[llvm-branch-commits] [llvm] release/23.x: [llvm-ar][GOFF] Implement symbol attributes for GOFF archives (#214528) (PR #228824)

James Henderson via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 5 00:14:44 PDT 2026


================
@@ -0,0 +1,79 @@
+## Test that llvm-ar correctly writes z/OS archive symbol attribute bits.
+##
+## The three attribute bits come from GOFF ESD record fields:
+##   bit 2 (0x4): 64-bit  - AMODE == ESD_AMODE_64
+##   bit 1 (0x2): XPLink  - LinkageType == ESD_LT_XPLink
+##   bit 0 (0x1): WSA     - NameSpaceId == ESD_NS_Parts
+##
+## GOFF objects are produced by compiling embedded .ll files with llc.
+
+# REQUIRES: systemz-registered-target
+
+# RUN: rm -rf %t.dir && mkdir -p %t.dir
+# RUN: split-file %s %t.dir
+
+## Compile each .ll file into a GOFF object.
+# RUN: llc -mtriple=s390x-ibm-zos -filetype=obj %t.dir/func.ll -o %t.dir/func.o
+# RUN: llc -mtriple=s390x-ibm-zos -filetype=obj %t.dir/data.ll -o %t.dir/data.o
+
+## Build a z/OS archive containing both objects.
+# RUN: llvm-ar rcD --format=zos %t.dir/test.a %t.dir/func.o %t.dir/data.o
+
+## 1. Check the attribute words written into the archive symbol table.
+##    s_func: 0x6 (64-bit=0x4 + XPLink=0x2)
+##    s_data: 0x3 (XPLink=0x2 + WSA=0x1)
+# RUN: %python %t.dir/print_symattrs.py %t.dir/test.a | FileCheck %s --check-prefix=ATTRS
+
+# ATTRS:      0x6
+# ATTRS-NEXT: 0x3
+
+## 2. Test that basic archive operations still work on a GOFF archive.
+##    llvm-ar t should list exactly the expected member names and nothing else.
+# RUN: llvm-ar t %t.dir/test.a | FileCheck %s --check-prefix=LIST \
+# RUN:   --implicit-check-not={{.}}
+
+# LIST: func.o
+# LIST-NEXT: data.o
+
+## 3. Test mixed archive: one GOFF object and one bitcode object together.
+##    The bitcode member should have an attribute of 0 (no GOFF ESD data available).
+# RUN: llc -mtriple=s390x-ibm-zos -filetype=obj %t.dir/func2.ll -o %t.dir/func2.o
+# RUN: llvm-as %t.dir/mixed.ll -o %t.dir/mixed.bc
+# RUN: llvm-ar rcD --format=zos %t.dir/mixed.a %t.dir/func2.o %t.dir/mixed.bc
+# RUN: %python %t.dir/print_symattrs.py %t.dir/mixed.a | FileCheck %s --check-prefix=MIXED-ATTRS
+
+# MIXED-ATTRS:      0x6
----------------
jh7370 wrote:

Technically, this would also match `0x60`, for example. You need either a `{{$}}` end-of-line marker or `--match-full-lines` in FileCheck or similar to make sure the whole number is matched.

https://github.com/llvm/llvm-project/pull/228824


More information about the llvm-branch-commits mailing list