aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/mk/bsd.sys.mk9
-rw-r--r--usr.bin/clang/clang/Makefile3
2 files changed, 11 insertions, 1 deletions
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index a964cf6e596c..80cc3080e552 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -273,7 +273,14 @@ LDFLAGS+= ${LDFLAGS.${LINKER_TYPE}}
# Only allow .TARGET when not using PROGS as it has the same syntax
# per PROG which is ambiguous with this syntax. This is only needed
# for PROG_VARS vars.
-.if !defined(_RECURSING_PROGS)
+#
+# Some directories (currently just clang) also need to disable this since
+# CFLAGS.${COMPILER_TYPE}, CFLAGS.${.IMPSRC:T} and CFLAGS.${.TARGET:T} all live
+# in the same namespace, meaning that, for example, GCC builds of clang pick up
+# CFLAGS.clang via CFLAGS.${.TARGET:T} and thus try to pass Clang-specific
+# flags. Ideally the different sources of CFLAGS would be namespaced to avoid
+# collisions.
+.if !defined(_RECURSING_PROGS) && !defined(NO_TARGET_FLAGS)
.if ${MK_WARNS} != "no"
CFLAGS+= ${CWARNFLAGS.${.TARGET:T}}
.endif
diff --git a/usr.bin/clang/clang/Makefile b/usr.bin/clang/clang/Makefile
index ec42fe78cf90..31f092608583 100644
--- a/usr.bin/clang/clang/Makefile
+++ b/usr.bin/clang/clang/Makefile
@@ -34,4 +34,7 @@ MLINKS+= clang.1 cc.1 \
LIBADD+= z
+# Ensure we don't add CFLAGS.clang when using GCC
+NO_TARGET_FLAGS=
+
.include "../clang.prog.mk"