HomeFreeBSD

clang: Support building with GCC and DEBUG_FILES disabled

Description

clang: Support building with GCC and DEBUG_FILES disabled

If MK_DEBUG_FILES=no then the Clang link rule has clang as .TARGET,
rather than clang.full, causing the implicit ${CFLAGS.${.TARGET:T}} to
be CFLAGS.clang, and thus pull in flags intended for when your compiler
is Clang, not when linking Clang itself. This doesn't matter if your
compiler is in fact Clang, but it breaks using GCC as, for example,
bsd.sys.mk adds -Qunused-arguments to CFLAGS.clang. This is seen when
trying to build a bootstrap toolchain on Linux where GCC is the system
compiler.

Thus, introduce a new internal NO_TARGET_FLAGS variable that is set by
Clang to disable the addition of these implicit flags. This is a bigger
hammer than necessary, as flags for .o files would be safe, but that is
not needed for Clang.

Note that the same problem does not arise for LDFLAGS when building LLD
with BFD, since our build produces a program called ld.lld, not plain
lld (unlike upstream, where ld.lld is a symlink to lld so they can
support multiple different flavours in one binary).

Suggested by: sjg
Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week
Reviewed by: dim, imp, emaste
Differential Revision: https://reviews.freebsd.org/D31532

(cherry picked from commit c8edd0542647f59ab07dd73e865edd34706397a5)

Details

Provenance
jrtc27Authored on Aug 24 2021, 1:59 PM
Reviewer
dim
Differential Revision
D31532: clang: Support building with GCC and DEBUG_FILES disabled
Parents
rGe515dd81ff4f: Fix bootstrapping to actually build lldb-tblgen for later use
Branches
Unknown
Tags
Unknown