[libc-commits] [libc] [libc] Migrate header .def files to public_includes (PR #206727)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Tue Jun 30 06:18:39 PDT 2026


https://github.com/labath created https://github.com/llvm/llvm-project/pull/206727

Now that public_includes is supported in header yaml files, we don't need custom .h.def templates just to include another header.

This patch removes link.h.def, string.h.def, and ucontext.h.def and moves their inclusions directly into
their yaml definitions:
- link.yaml: add elf.h
- string.yaml: add strings.h
- sys/ucontext.yaml: add ucontext.h

Assisted by Gemini.

>From b64bdc8062a356881ddd1f4d3b39727627e3d4cf Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Wed, 24 Jun 2026 12:33:07 +0000
Subject: [PATCH] [libc] Migrate header .def files to public_includes

Now that public_includes is supported in header yaml files, we don't
need custom .h.def templates just to include another header.

This patch removes link.h.def, string.h.def, and ucontext.h.def and
moves their inclusions directly into
their yaml definitions:
- link.yaml: add elf.h
- string.yaml: add strings.h
- sys/ucontext.yaml: add ucontext.h

Assisted by Gemini.
---
 libc/include/link.h.def         | 19 -------------------
 libc/include/link.yaml          |  3 ++-
 libc/include/string.h.def       | 21 ---------------------
 libc/include/string.yaml        |  4 +++-
 libc/include/sys/ucontext.h.def | 16 ----------------
 libc/include/sys/ucontext.yaml  |  3 ++-
 6 files changed, 7 insertions(+), 59 deletions(-)
 delete mode 100644 libc/include/link.h.def
 delete mode 100644 libc/include/string.h.def
 delete mode 100644 libc/include/sys/ucontext.h.def

diff --git a/libc/include/link.h.def b/libc/include/link.h.def
deleted file mode 100644
index b9c83e87751b6..0000000000000
--- a/libc/include/link.h.def
+++ /dev/null
@@ -1,19 +0,0 @@
-//===-- System V header link.h --------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_LINK_H
-#define LLVM_LIBC_LINK_H
-
-#include "__llvm-libc-common.h"
-#include "llvm-libc-macros/link-macros.h"
-
-#include <elf.h>
-
-%%public_api()
-
-#endif // LLVM_LIBC_LINK_H
diff --git a/libc/include/link.yaml b/libc/include/link.yaml
index b917bc0a61ae9..e0228ef6ed6ef 100644
--- a/libc/include/link.yaml
+++ b/libc/include/link.yaml
@@ -1,5 +1,6 @@
 header: link.h
-header_template: link.h.def
+public_includes:
+  - elf.h
 standards:
   - svid
 macros:
diff --git a/libc/include/string.h.def b/libc/include/string.h.def
deleted file mode 100644
index d70254193dafe..0000000000000
--- a/libc/include/string.h.def
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- C standard library header header string.h -------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_STRING_H
-#define LLVM_LIBC_STRING_H
-
-#include "__llvm-libc-common.h"
-
-// TODO: Needed for compatibility with glibc which provides these symbols by
-// default. Would be better in the yaml file but there's no way to represent
-// including another header in yaml right now.
-#include <strings.h>
-
-%%public_api()
-
-#endif // LLVM_LIBC_STRING_H
diff --git a/libc/include/string.yaml b/libc/include/string.yaml
index 0935f38b3fcbd..dc3247543c1d7 100644
--- a/libc/include/string.yaml
+++ b/libc/include/string.yaml
@@ -1,5 +1,7 @@
 header: string.h
-header_template: string.h.def
+public_includes:
+  # Needed for compatibility with glibc which provides these symbols by default.
+  - strings.h
 standards:
   - stdc
 macros:
diff --git a/libc/include/sys/ucontext.h.def b/libc/include/sys/ucontext.h.def
deleted file mode 100644
index 035c545111ed9..0000000000000
--- a/libc/include/sys/ucontext.h.def
+++ /dev/null
@@ -1,16 +0,0 @@
-//===-- GNU header sys/ucontext.h -----------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SYS_UCONTEXT_H
-#define LLVM_LIBC_SYS_UCONTEXT_H
-
-#include <ucontext.h>
-
-%%public_api()
-
-#endif // LLVM_LIBC_SYS_UCONTEXT_H
diff --git a/libc/include/sys/ucontext.yaml b/libc/include/sys/ucontext.yaml
index 35239ea00b924..95e3ca0aa702a 100644
--- a/libc/include/sys/ucontext.yaml
+++ b/libc/include/sys/ucontext.yaml
@@ -1,4 +1,5 @@
 header: sys/ucontext.h
-header_template: ucontext.h.def
+public_includes:
+  - ucontext.h
 standards:
   - gnu



More information about the libc-commits mailing list