From 59e83af253b114debaa5ee46196828c636e7f669 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Thu, 14 Mar 2024 16:45:56 +0000 Subject: [PATCH] devel/llvm-base: switch to init-all=zero Zero bits of the stack the compiler can't prove are initialized before use or escape by default. Issue: https://github.com/CTSRD-CHERI/cheribsd/issues/2045 --- devel/llvm-base/Makefile | 2 +- devel/llvm-base/files/wrapper.sh.in | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/devel/llvm-base/Makefile b/devel/llvm-base/Makefile index e7eda35585227..2a90e89e52aec 100644 --- a/devel/llvm-base/Makefile +++ b/devel/llvm-base/Makefile @@ -1,5 +1,5 @@ PORTNAME= llvm -PORTVERSION= 5 +PORTVERSION= 6 CATEGORIES= devel lang MASTER_SITES= # not applicable DISTFILES= # not applicable diff --git a/devel/llvm-base/files/wrapper.sh.in b/devel/llvm-base/files/wrapper.sh.in index 281a219d2935f..22c528ed38b22 100644 --- a/devel/llvm-base/files/wrapper.sh.in +++ b/devel/llvm-base/files/wrapper.sh.in @@ -91,6 +91,15 @@ esac # version in ${LOCALBASE}/bin to ensure LD_LIBRARY_PATH is correct. realtool=${LOCALBASE}/bin/${llvmtool} +cflags= +if [ "$CHERIBSD_VERSION" -gt 20230804 ]; then + cflags="-ftrivial-auto-var-init=zero" + # XXX: The -enable-... flag becomes a warning in clang 16 and is + # removed in llvm 18. Remove this once llvm-cheri and llvm-morello + # no longer require it. + cflags="${cflags} -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang" +fi + # CheriBSD: assume that if we're on a CHERI architecture we want either # purecap or hybrid binaries. arch_cflags= @@ -131,7 +140,7 @@ esac case $tool in cc|c++|cpp) - toolflags=$arch_cflags + toolflags="$cflags $arch_cflags" ;; ld|ld.lld) # no flags should be required as ld can see what it's doing from