From nobody Sat Dec 25 11:55:45 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EDE2718F3303; Sat, 25 Dec 2021 11:55:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JLj785ZMKz4l4l; Sat, 25 Dec 2021 11:55:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1243916C58; Sat, 25 Dec 2021 11:55:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BPBtj8J006750; Sat, 25 Dec 2021 11:55:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BPBtj0O006749; Sat, 25 Dec 2021 11:55:45 GMT (envelope-from git) Date: Sat, 25 Dec 2021 11:55:45 GMT Message-Id: <202112251155.1BPBtj0O006749@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: f28517db4ed0 - stable/12 - clang: Support building with GCC and DEBUG_FILES disabled List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: f28517db4ed04e186a8ef12ddb5f68b73ce1e51d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640433349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1GiQzQf0Oxo7Tm1nnawG77iqL5mLCSAD+xC1JIQ7TWQ=; b=Sb2oOfvNJfanIe4X4J95DSLdZlyvlacUyTVIXw8EjztBYrLThIIMf3dsY2iwa9Z2U+yWEm ycLYBtYT9rFRkWASn3hXr5oxYPZ0/zzlUItBUXfaTumMvHBsJ7bEv9z1ipJVM8EEm1jDcW n2LW6SuWyPux5B6uAv+C8ye0Kfudo1yX35/rKiD2chj9TffgU97bSLRi8l3o5KyG5doyXF jampQvliQ94buFkoEh6xN2qRWgfXYDaDlj+McqyNyZSjrrmNmuH5+Ba7+N1gzyHxb46ChZ +P8WkESaRMfB2J4zNu0lO2x6rTV0271Mp7GobTqAxP31ssEsRssUUfbi8D9fyA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640433349; a=rsa-sha256; cv=none; b=DEifL4TQ0M/ZlgSluutB2mQtF7c0bn1Skx5W476nrRvEhx2bvCUmfgSV9ez4DEj3/dzXjz hi71C9UiQYb7fwrxYb7oaW/rMRqnFZ69sviU58RP31GaHqQQZ25I5IbiFJJw/Qd5zbIVWT OmjXIkTOO5WWj1XfL58ZnG6Sc/yn0QSbW6ZCT/VRlEV+1VduZOBF+NVrZ0tGIQcBRO9Jz5 6Qc7kiFhZ0EGT/9Zp3gkM4/08oFWzPLJKWv3gPFAat61gJ0wCZ/MFyeZS3nvg97yFTsG8q N5oVi2d2BxElAvC8Y+n2wB7rcrFMadJ2wx9p1+R/g/B772NsWHIG/98o4upKTw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=f28517db4ed04e186a8ef12ddb5f68b73ce1e51d commit f28517db4ed04e186a8ef12ddb5f68b73ce1e51d Author: Jessica Clarke AuthorDate: 2021-08-24 13:59:18 +0000 Commit: Dimitry Andric CommitDate: 2021-12-25 11:51:19 +0000 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) --- share/mk/bsd.sys.mk | 9 ++++++++- usr.bin/clang/clang/Makefile | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 375df956b4fd..f228984719c7 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -272,7 +272,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"