git: c1f7d8dd23db - main - clang: Build with -fno-strict-aliasing when using GCC

Jessica Clarke jrtc27 at FreeBSD.org
Tue Aug 24 14:06:02 UTC 2021


The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=c1f7d8dd23db693106fcd66e0b1766a3f3194670

commit c1f7d8dd23db693106fcd66e0b1766a3f3194670
Author:     Jessica Clarke <jrtc27 at FreeBSD.org>
AuthorDate: 2021-08-24 13:59:36 +0000
Commit:     Jessica Clarke <jrtc27 at FreeBSD.org>
CommitDate: 2021-08-24 14:04:25 +0000

    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
---
 lib/clang/clang.build.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk
index 0d3151178eb9..fb64b16935f2 100644
--- a/lib/clang/clang.build.mk
+++ b/lib/clang/clang.build.mk
@@ -13,4 +13,6 @@ CFLAGS+=	-DCLANG_ENABLE_ARCMT
 CFLAGS+=	-DCLANG_ENABLE_STATIC_ANALYZER
 .endif
 
+CFLAGS.gcc+=	-fno-strict-aliasing
+
 .include "llvm.build.mk"


More information about the dev-commits-src-all mailing list