git: b20eb96fe818 - stable/13 - clang: Build with -fno-strict-aliasing when using GCC

Jessica Clarke jrtc27 at FreeBSD.org
Tue Sep 7 12:10:11 UTC 2021


The branch stable/13 has been updated by jrtc27:

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

commit b20eb96fe818df5e3a1b089f3761dfcaa83a92f4
Author:     Jessica Clarke <jrtc27 at FreeBSD.org>
AuthorDate: 2021-08-24 13:59:36 +0000
Commit:     Jessica Clarke <jrtc27 at FreeBSD.org>
CommitDate: 2021-09-07 12:08:19 +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
    
    (cherry picked from commit c1f7d8dd23db693106fcd66e0b1766a3f3194670)
---
 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-branches mailing list