From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web12.52507.1594017512360396127 for ; Sun, 05 Jul 2020 23:38:32 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: zhiguang.liu@intel.com) IronPort-SDR: 5F5IbqbiFYsNvRiW6XZAC5lGpZ4mCDwdbgLys/hdQPpSMvNFt7c1OXGWJLrUlQIxyQkKVNRNX6 JeAGzhHc+wOw== X-IronPort-AV: E=McAfee;i="6000,8403,9673"; a="145472468" X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="145472468" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2020 23:38:31 -0700 IronPort-SDR: QPBa2krNW6KVCF5uT4T7J8fJvFFuEEQCT3vByiBDhkEjR5s12OoEtf1Acp5GrG3Qaof8LNkEDg V6A6g/PdW3iA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,318,1589266800"; d="scan'208";a="482599041" Received: from fieedk002.ccr.corp.intel.com ([10.239.158.178]) by fmsmga006.fm.intel.com with ESMTP; 05 Jul 2020 23:38:30 -0700 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [PATCH] Using LLVM compiler set to build BaseTools in Linux Date: Mon, 6 Jul 2020 14:38:21 +0800 Message-Id: <20200706063821.1914-1-zhiguang.liu@intel.com> X-Mailer: git-send-email 2.25.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2842 To use LLVM to build BaseTools, first set the CLANG_BIN environment value, and add "CXX=3Dllvm" to choose LLVM compiler set when using make command. Cc: Bob Feng Cc: Liming Gao Signed-off-by: Zhiguang Liu --- BaseTools/Source/C/Makefiles/header.makefile | 22 ++++++++++++++++++= ++-- BaseTools/Source/C/VfrCompile/GNUmakefile | 6 ++++-- BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 4 ++++ BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 4 ++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Sourc= e/C/Makefiles/header.makefile index 4e9b36d98b..1c105ee7d4 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -38,12 +38,19 @@ endif CYGWIN:=3D$(findstring CYGWIN, $(shell uname -s))=0D LINUX:=3D$(findstring Linux, $(shell uname -s))=0D DARWIN:=3D$(findstring Darwin, $(shell uname -s))=0D -=0D +ifeq ($(CXX), llvm)=0D +BUILD_CC ?=3D $(CLANG_BIN)clang=0D +BUILD_CXX ?=3D $(CLANG_BIN)clang++=0D +BUILD_AS ?=3D $(CLANG_BIN)clang=0D +BUILD_AR ?=3D $(CLANG_BIN)llvm-ar=0D +BUILD_LD ?=3D $(CLANG_BIN)llvm-ld=0D +else=0D BUILD_CC ?=3D gcc=0D BUILD_CXX ?=3D g++=0D BUILD_AS ?=3D gcc=0D BUILD_AR ?=3D ar=0D BUILD_LD ?=3D ld=0D +endif=0D LINKER ?=3D $(BUILD_CC)=0D ifeq ($(HOST_ARCH), IA32)=0D ARCH_INCLUDE =3D -I $(MAKEROOT)/Include/Ia32/=0D @@ -72,14 +79,25 @@ ifeq ($(DARWIN),Darwin) BUILD_CFLAGS =3D -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \=0D -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib= -g=0D else=0D +ifeq ($(CXX), llvm)=0D +BUILD_CFLAGS =3D -MD -fshort-wchar -fno-strict-aliasing -fwrapv \=0D +-fno-delete-null-pointer-checks -Wall -Werror \=0D +-Wno-deprecated-declarations -Wno-self-assign \=0D +-Wno-unused-result -nostdlib -g=0D +else=0D BUILD_CFLAGS =3D -MD -fshort-wchar -fno-strict-aliasing -fwrapv \=0D -fno-delete-null-pointer-checks -Wall -Werror \=0D -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict \=0D -Wno-unused-result -nostdlib -g=0D endif=0D +endif=0D +ifeq ($(CXX), llvm)=0D +BUILD_LFLAGS =3D=0D +BUILD_CXXFLAGS =3D -Wno-deprecated-register -Wno-unused-result=0D +else=0D BUILD_LFLAGS =3D=0D BUILD_CXXFLAGS =3D -Wno-unused-result=0D -=0D +endif=0D ifeq ($(HOST_ARCH), IA32)=0D #=0D # Snow Leopard is a 32-bit and 64-bit environment. uname -m returns i386,= but gcc defaults=0D diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C= /VfrCompile/GNUmakefile index 42e3d7da02..fc329944b9 100644 --- a/BaseTools/Source/C/VfrCompile/GNUmakefile +++ b/BaseTools/Source/C/VfrCompile/GNUmakefile @@ -16,9 +16,11 @@ TOOL_INCLUDE =3D -I Pccts/h #OBJECTS =3D VfrSyntax.o VfrServices.o DLGLexer.o EfiVfrParser.o ATokenBuf= fer.o DLexerBase.o AParser.o=0D OBJECTS =3D AParser.o DLexerBase.o ATokenBuffer.o EfiVfrParser.o VfrLexer.= o VfrSyntax.o \=0D VfrFormPkg.o VfrError.o VfrUtilityLib.o VfrCompiler.o=0D -=0D +ifeq ($(CXX), llvm)=0D +VFR_CPPFLAGS =3D -Wno-deprecated-register -DPCCTS_USE_NAMESPACE_STD $(BUIL= D_CPPFLAGS)=0D +else=0D VFR_CPPFLAGS =3D -DPCCTS_USE_NAMESPACE_STD $(BUILD_CPPFLAGS)=0D -=0D +endif=0D # keep BUILD_OPTFLAGS last=0D VFR_CXXFLAGS =3D $(BUILD_OPTFLAGS)=0D =0D diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools= /Source/C/VfrCompile/Pccts/antlr/makefile index 8f2cc78c59..559b1c99f1 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile @@ -164,7 +164,11 @@ PCCTS_H=3D../h #=0D # UNIX (default)=0D #=0D +ifeq ($(CXX), llvm)=0D +BUILD_CC?=3D$(CLANG_BIN)clang=0D +else=0D BUILD_CC?=3Dgcc=0D +endif=0D COPT=3D-O=0D ANTLR=3D${BIN_DIR}/antlr=0D DLG=3D${BIN_DIR}/dlg=0D diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/S= ource/C/VfrCompile/Pccts/dlg/makefile index b3a34d3b46..5a3561edec 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile @@ -114,7 +114,11 @@ PCCTS_H=3D../h #=0D # UNIX=0D #=0D +ifeq ($(CXX), llvm)=0D +BUILD_CC?=3D$(CLANG_BIN)clang=0D +else=0D BUILD_CC?=3Dcc=0D +endif=0D COPT=3D-O=0D ANTLR=3D${BIN_DIR}/antlr=0D DLG=3D${BIN_DIR}/dlg=0D --=20 2.25.1.windows.1