Skip to content

Commit

Permalink
devel/llvm-base: switch to init-all=zero
Browse files Browse the repository at this point in the history
Zero bits of the stack the compiler can't prove are initialized before
use or escape by default.

Issue:		CTSRD-CHERI/cheribsd#2045
  • Loading branch information
brooksdavis committed Mar 18, 2024
1 parent 28e6481 commit 59e83af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion devel/llvm-base/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PORTNAME= llvm
PORTVERSION= 5
PORTVERSION= 6
CATEGORIES= devel lang
MASTER_SITES= # not applicable
DISTFILES= # not applicable
Expand Down
11 changes: 10 additions & 1 deletion devel/llvm-base/files/wrapper.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 59e83af

Please sign in to comment.