[compiler-rt] [llvm] [flang] [clang] [clang-tools-extra] [AArch64][compiler-rt] Avoid use of libc header in sme-libc-routines (PR #79454)

Peter Waller via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 02:55:11 PST 2024


https://github.com/peterwaller-arm updated https://github.com/llvm/llvm-project/pull/79454

>From 18fbfe3d757372fc904146a9156e8af466c9f013 Mon Sep 17 00:00:00 2001
From: Peter Waller <peter.waller at arm.com>
Date: Thu, 25 Jan 2024 14:29:45 +0000
Subject: [PATCH] [AArch64][compiler-rt] Avoid use of libc header in
 sme-libc-routines

The use of `#include <stdlib.h>` introduces a libc dependency. In many
build environments such a file can be found under e.g. /usr/include, but this
does not correspond to the libc in use, which may not be available until
after the builtins have been built.

So far as I understand, it's not valid to have a dependency on libc from
builtins; there are a handful of such includes in builtins, but they are
protected by ifdefs.

Instead, use <stddef.h> which is provided by the compiler's resource
headers and so should always be available.
---
 compiler-rt/lib/builtins/aarch64/sme-libc-routines.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/builtins/aarch64/sme-libc-routines.c b/compiler-rt/lib/builtins/aarch64/sme-libc-routines.c
index cd73025a19cc1ac..89b52b0d1a8805c 100644
--- a/compiler-rt/lib/builtins/aarch64/sme-libc-routines.c
+++ b/compiler-rt/lib/builtins/aarch64/sme-libc-routines.c
@@ -1,4 +1,4 @@
-#include <stdlib.h>
+#include <stddef.h>
 
 // WARNING: When building the scalar versions of these functions you need to
 // use the compiler flag "-mllvm -disable-loop-idiom-all" to prevent clang



More information about the cfe-commits mailing list