[libc-commits] [libc] [llvm] [libc] Make alloca visible from stdlib.h (PR #241695)

Mike Lothian via libc-commits libc-commits at lists.llvm.org
Fri Nov 13 02:53:16 PST 2026


https://github.com/FireBurn updated https://github.com/llvm/llvm-project/pull/241695

>From 2704507d060161afb5dd35c5f948558f4efe368d Mon Sep 17 00:00:00 2001
From: Mike Lothian <mike at fireburn.co.uk>
Date: Sat, 5 Sep 2026 04:27:42 +0100
Subject: [PATCH] [libc] Make alloca visible from stdlib.h

glibc's `<stdlib.h>` declares `alloca`, and a good deal of code relies on that instead of including `<alloca.h>`. This makes the macro visible from `<stdlib.h>` too

AI disclosure: this patch was written with Claude Code. I reviewed the change and built and ran the new test in a full build; it does not build without the change

Assisted-by: Claude
---
 libc/include/CMakeLists.txt                       | 1 +
 libc/include/alloca.yaml                          | 7 ++-----
 libc/include/stdlib-alloca.yaml                   | 7 +++++++
 libc/include/stdlib.yaml                          | 1 +
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 5 ++++-
 5 files changed, 15 insertions(+), 6 deletions(-)
 create mode 100644 libc/include/stdlib-alloca.yaml

diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 7010d6998b5fe..69228ffc2e1db 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -540,6 +540,7 @@ add_header_macro(
   ../libc/include/stdlib.yaml
   stdlib.h
   DEPENDS
+    .llvm-libc-macros.alloca_macros
     .llvm-libc-macros.null_macro
     .llvm-libc-macros.stdlib_macros
     .llvm-libc-types.__atexithandler_t
diff --git a/libc/include/alloca.yaml b/libc/include/alloca.yaml
index 10349e224608c..72b2f9569e2c8 100644
--- a/libc/include/alloca.yaml
+++ b/libc/include/alloca.yaml
@@ -1,11 +1,8 @@
 header: alloca.h
 standards:
   - gnu
-macros:
-  - macro_name: alloca
-    macro_header: alloca-macros.h
-types:
-  - type_name: size_t
+merge_yaml_files:
+  - stdlib-alloca.yaml
 enums: []
 objects: []
 functions: []
diff --git a/libc/include/stdlib-alloca.yaml b/libc/include/stdlib-alloca.yaml
new file mode 100644
index 0000000000000..34b47709e8887
--- /dev/null
+++ b/libc/include/stdlib-alloca.yaml
@@ -0,0 +1,7 @@
+# This file has declarations that appear both in <stdlib.h> and in <alloca.h>.
+
+macros:
+  - macro_name: alloca
+    macro_header: alloca-macros.h
+types:
+  - type_name: size_t
diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index d278b8daa67ac..3424cbbe5e46f 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -2,6 +2,7 @@ header: stdlib.h
 standards:
   - stdc
 merge_yaml_files:
+  - stdlib-alloca.yaml
   - stdlib-malloc.yaml
 macros:
   - macro_name: "NULL"
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index c346902359aec..493a9e5f995a0 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -251,7 +251,10 @@ LLVM_LIBC_HEADERS = [
     libc_header_info("wctype"),
     libc_header_info(
         "stdlib",
-        other_srcs = ["include/stdlib-malloc.yaml"],
+        other_srcs = [
+            "include/stdlib-alloca.yaml",
+            "include/stdlib-malloc.yaml",
+        ],
     ),
     libc_header_info(
         "malloc",



More information about the libc-commits mailing list