From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by mx.groups.io with SMTP id smtpd.web11.31086.1676605891387094109 for ; Thu, 16 Feb 2023 19:51:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jPX9qNGP; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: quicinc.com, ip: 205.220.180.131, mailfrom: quic_rcran@quicinc.com) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31H2T0Wn018861; Fri, 17 Feb 2023 03:51:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=5V2/AN/mWXaGWjxBgRT2jMo0h0nwTyrD8htF1bVTI+0=; b=jPX9qNGPNByl1s64VN4TD9IMM3QcccwDKJV6kG1SuCsktcPuiahAbYX91RspKu/E/J3z mo/o+a2csK01SHGK+HoMZE2OJ0t2ZsgNj90iYozKrAJpYIRRFB+yr8HFCY2heJ4emeHj fj/jqqr/VLNjuCp9sRCALl5qO2LrSOn2wqEgYIhcBDreGZWMGFatnRgNVaEB/+LxY8UF ou7GUlYhoAcw32VTT+HGW/2r1JA/WdhimfG0x+4BoPMl2ORFmAd0PiW/lC6HeiI4uexw oI3UCOROjP/51zsd4euDIHBqM67QilBdmeby2X8CyNUDx/b0iIegHuWAFK29l6s2WgRI jw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nsft5turu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Feb 2023 03:51:16 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31H3pFgY002447 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Feb 2023 03:51:15 GMT Received: from linbox.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 16 Feb 2023 19:51:14 -0800 From: "Rebecca Cran" To: , Andrew Fish , Leif Lindholm , Michael D Kinney , Bob Feng , Liming Gao , "Yuwei Chen" CC: Rebecca Cran Subject: [PATCH 2/3] BaseTools: Improve detection of users wanting to build using clang Date: Thu, 16 Feb 2023 20:51:00 -0700 Message-ID: <20230217035101.880854-3-rebecca@quicinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230217035101.880854-1-rebecca@quicinc.com> References: <20230217035101.880854-1-rebecca@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 3jS-GlKYADZngu3XBF8uqZaHOY8qNDK6 X-Proofpoint-GUID: 3jS-GlKYADZngu3XBF8uqZaHOY8qNDK6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_18,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 impostorscore=0 mlxlogscore=825 clxscore=1015 adultscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302170033 Content-Transfer-Encoding: 8bit Content-Type: text/plain In https://bugzilla.tianocore.org/show_bug.cgi?id=2842 clang support was added by having users specify "make CXX=llvm" when building BaseTools. Improve the detection of when a user wants to use the clang toolchain: instead of checking if CXX=llvm (which in most cases doesn't make sense, because the C++ compiler won't be run via an 'llvm' command), run '$(CC) --version | grep clang' to see if the compiler's version string contains 'clang', and if so configure the environment. This provides flexibility to specify for example CC=clang-17 CXX=clang++-17 if multiple versions are installed. Signed-off-by: Rebecca Cran --- BaseTools/Source/C/DevicePath/GNUmakefile | 3 ++- BaseTools/Source/C/Makefiles/header.makefile | 7 ++++--- BaseTools/Source/C/VfrCompile/GNUmakefile | 3 ++- BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 2 +- BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/C/DevicePath/GNUmakefile b/BaseTools/Source/C/DevicePath/GNUmakefile index 3afc7fc0504e..f61b1b2f171d 100644 --- a/BaseTools/Source/C/DevicePath/GNUmakefile +++ b/BaseTools/Source/C/DevicePath/GNUmakefile @@ -14,8 +14,9 @@ OBJECTS = DevicePath.o UefiDevicePathLib.o DevicePathFromText.o DevicePathUtili include $(MAKEROOT)/Makefiles/app.makefile GCCVERSION = $(shell $(CC) -dumpversion | awk -F'.' '{print $$1}') +CLANG := $(shell $(CC) --version | grep clang) ifneq ("$(GCCVERSION)", "5") -ifneq ($(CXX), llvm) +ifeq ($(CLANG),) ifneq ($(DARWIN),Darwin) # gcc 12 trips over device path handling CFLAGS += -Wno-error=stringop-overflow diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile index 347918c7d4fa..bcc2791998b0 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -44,7 +44,8 @@ endif CYGWIN:=$(findstring CYGWIN, $(shell uname -s)) LINUX:=$(findstring Linux, $(shell uname -s)) DARWIN:=$(findstring Darwin, $(shell uname -s)) -ifeq ($(CXX), llvm) +CLANG:=$(shell $(CC) --version | grep clang) +ifneq ($(CLANG),) CC ?= $(CLANG_BIN)clang CXX ?= $(CLANG_BIN)clang++ AS ?= $(CLANG_BIN)clang @@ -91,7 +92,7 @@ ifeq ($(DARWIN),Darwin) CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \ -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g else -ifeq ($(CXX), llvm) +ifneq ($(CLANG),) CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ -fno-delete-null-pointer-checks -Wall -Werror \ -Wno-deprecated-declarations -Wno-self-assign \ @@ -103,7 +104,7 @@ CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ -Wno-unused-result -nostdlib -g endif endif -ifeq ($(CXX), llvm) +ifneq ($(CLANG),) LDFLAGS = CXXFLAGS = -Wno-deprecated-register -Wno-unused-result else diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile index 9fbaaaba21d7..fdd19f55f77e 100644 --- a/BaseTools/Source/C/VfrCompile/GNUmakefile +++ b/BaseTools/Source/C/VfrCompile/GNUmakefile @@ -16,7 +16,8 @@ TOOL_INCLUDE = -I Pccts/h #OBJECTS = VfrSyntax.o VfrServices.o DLGLexer.o EfiVfrParser.o ATokenBuffer.o DLexerBase.o AParser.o OBJECTS = AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.o VfrSyntax.o \ VfrFormPkg.o VfrError.o VfrUtilityLib.o VfrCompiler.o -ifeq ($(CXX), llvm) +CLANG:=$(shell $(CC) --version | grep clang) +ifneq ($(CLANG),) VFR_CPPFLAGS = -Wno-deprecated-register -DPCCTS_USE_NAMESPACE_STD $(CPPFLAGS) else VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(CPPFLAGS) diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile index 558d2f7b0111..42b603571fab 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile @@ -164,7 +164,7 @@ PCCTS_H=../h # # UNIX (default) # -ifeq ($(CXX), llvm) +ifneq ($(CLANG),) CC?=$(CLANG_BIN)clang else ifeq ($(origin CC),default) CC=gcc diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile index e214b35ab5e1..69dac6a59789 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile @@ -114,7 +114,8 @@ PCCTS_H=../h # # UNIX # -ifeq ($(CXX), llvm) +CLANG:=$(shell $(CC) --version | grep clang) +ifneq ($(CLANG),) CC?=$(CLANG_BIN)clang else ifeq ($(origin CC),default) CC=cc -- 2.30.2