freebsd-dev/lib/clang/clang.build.mk
Jessica Clarke c1f7d8dd23 clang: Build with -fno-strict-aliasing when using GCC
Somewhat ironically, there are strict aliasing violations in Clang,
which can result in the following assertion failure:

  Assertion `*(NamedDecl **)&Data == ND && "PointerUnion mangles the NamedDecl pointer!"' failed.

Upstream's clang/CMakeLists.txt specifically (not LLVM as a whole)
passes -fno-strict-aliasing if the compiler is not Clang, and this fixes
the above issue.

This was seen when cross-building from Linux using a bootstrap
compiler, but likely also affects worlds built with a new enough
external GCC toolchain.

MFC after:	1 week
Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D31533
2021-08-24 15:04:25 +01:00

19 lines
324 B
Makefile

# $FreeBSD$
.include <src.opts.mk>
.ifndef CLANG_SRCS
.error Please define CLANG_SRCS before including this file
.endif
CFLAGS+= -I${CLANG_SRCS}/include
.if ${MK_CLANG_FULL} != "no"
CFLAGS+= -DCLANG_ENABLE_ARCMT
CFLAGS+= -DCLANG_ENABLE_STATIC_ANALYZER
.endif
CFLAGS.gcc+= -fno-strict-aliasing
.include "llvm.build.mk"