[libc-commits] [libc] [libc] Add ar header (PR #243964)

via libc-commits libc-commits at lists.llvm.org
Wed Nov 18 10:51:25 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

<details>
<summary>Changes</summary>

The ar header is a GNU extension for archiver utilities. Added for
compatibility.

Assisted-by: Automated tooling, human reviewed.


---
Full diff: https://github.com/llvm/llvm-project/pull/243964.diff


7 Files Affected:

- (modified) libc/config/linux/aarch64/headers.txt (+1) 
- (modified) libc/config/linux/riscv/headers.txt (+1) 
- (modified) libc/config/linux/x86_64/headers.txt (+1) 
- (modified) libc/include/CMakeLists.txt (+9) 
- (added) libc/include/ar.yaml (+12) 
- (modified) libc/include/llvm-libc-types/CMakeLists.txt (+1) 
- (added) libc/include/llvm-libc-types/struct_ar_hdr.h (+28) 


``````````diff
diff --git a/libc/config/linux/aarch64/headers.txt b/libc/config/linux/aarch64/headers.txt
index 30b59c2170493..53ced730e8ff8 100644
--- a/libc/config/linux/aarch64/headers.txt
+++ b/libc/config/linux/aarch64/headers.txt
@@ -1,5 +1,6 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.alloca
+    libc.include.ar
     libc.include.arpa_inet
     libc.include.arpa_nameser
     libc.include.assert
diff --git a/libc/config/linux/riscv/headers.txt b/libc/config/linux/riscv/headers.txt
index 729460260484d..4fd6f5e591a6b 100644
--- a/libc/config/linux/riscv/headers.txt
+++ b/libc/config/linux/riscv/headers.txt
@@ -1,5 +1,6 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.alloca
+    libc.include.ar
     libc.include.arpa_inet
     libc.include.arpa_nameser
     libc.include.assert
diff --git a/libc/config/linux/x86_64/headers.txt b/libc/config/linux/x86_64/headers.txt
index ab85066f418e7..cd882ec8e3603 100644
--- a/libc/config/linux/x86_64/headers.txt
+++ b/libc/config/linux/x86_64/headers.txt
@@ -1,5 +1,6 @@
 set(TARGET_PUBLIC_HEADERS
     libc.include.alloca
+    libc.include.ar
     libc.include.arpa_inet
     libc.include.arpa_nameser
     libc.include.assert
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 1c35510f5d72e..7ca695073e2ab 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -704,6 +704,15 @@ add_header_macro(
     .llvm-libc-types.posix_spawn_file_actions_t
 )
 
+add_header_macro(
+  ar
+  ../libc/include/ar.yaml
+  ar.h
+  DEPENDS
+    .llvm_libc_common_h
+    .llvm-libc-types.struct_ar_hdr
+)
+
 add_header_macro(
   elf
   ../libc/include/elf.yaml
diff --git a/libc/include/ar.yaml b/libc/include/ar.yaml
new file mode 100644
index 0000000000000..65665cfabcc99
--- /dev/null
+++ b/libc/include/ar.yaml
@@ -0,0 +1,12 @@
+header: ar.h
+standards:
+  - bsd
+macros:
+  - macro_name: ARMAG
+    macro_value: '"!<arch>\n"'
+  - macro_name: SARMAG
+    macro_value: 8
+  - macro_name: ARFMAG
+    macro_value: '"`\n"'
+types:
+  - type_name: struct_ar_hdr
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 00fae51cf48f1..485a93d9959f0 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -648,6 +648,7 @@ endif()
 add_type_header(mcontext_t HDR mcontext_t.h)
 add_type_header(ucontext_t HDR ucontext_t.h)
 add_type_header(struct_user_regs_struct HDR struct_user_regs_struct.h)
+add_header(struct_ar_hdr HDR struct_ar_hdr.h)
 
 # UEFI
 add_header(EFI_GUID HDR EFI_GUID.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
diff --git a/libc/include/llvm-libc-types/struct_ar_hdr.h b/libc/include/llvm-libc-types/struct_ar_hdr.h
new file mode 100644
index 0000000000000..caf9ea9bcd9be
--- /dev/null
+++ b/libc/include/llvm-libc-types/struct_ar_hdr.h
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of struct ar_hdr.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_STRUCT_AR_HDR_H
+#define LLVM_LIBC_TYPES_STRUCT_AR_HDR_H
+
+// Archive member header. Every field is ASCII text padded with spaces.
+struct ar_hdr {
+  char ar_name[16]; // Member name, terminated by '/' in the System V format.
+  char ar_date[12]; // Modification time, decimal seconds since the Epoch.
+  char ar_uid[6];   // User ID, decimal.
+  char ar_gid[6];   // Group ID, decimal.
+  char ar_mode[8];  // File mode, octal.
+  char ar_size[10]; // Member size in bytes, decimal.
+  char ar_fmag[2];  // Always ARFMAG.
+};
+
+#endif // LLVM_LIBC_TYPES_STRUCT_AR_HDR_H

``````````

</details>


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


More information about the libc-commits mailing list