From 1fb214b159dd520488db2bac2fca84870e74d49b Mon Sep 17 00:00:00 2001 From: luofeng14 Date: Tue, 5 Sep 2023 13:42:26 +0000 Subject: [PATCH] Support build with clang Signed-off-by: luofeng14 --- 0035-support-build-with-clang.patch | 105 ++++++++++++++++++++++++++++ edk2.spec | 6 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 0035-support-build-with-clang.patch diff --git a/0035-support-build-with-clang.patch b/0035-support-build-with-clang.patch new file mode 100644 index 0000000..e6cdc35 --- /dev/null +++ b/0035-support-build-with-clang.patch @@ -0,0 +1,105 @@ +From 5ef58b45f3686656466056eeea99f3664e2a39a7 Mon Sep 17 00:00:00 2001 +From: luofeng +Date: Tue, 5 Sep 2023 21:24:08 +0800 +Subject: [PATCH] Support build with clang + +--- + BaseTools/Source/C/DevicePath/GNUmakefile | 2 ++ + BaseTools/Source/C/Makefiles/header.makefile | 8 ++++---- + BaseTools/Source/C/VfrCompile/GNUmakefile | 2 +- + BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile | 2 +- + BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile | 2 +- + 5 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/BaseTools/Source/C/DevicePath/GNUmakefile b/BaseTools/Source/C/DevicePath/GNUmakefile +index b05d2bd..d575317 100644 +--- a/BaseTools/Source/C/DevicePath/GNUmakefile ++++ b/BaseTools/Source/C/DevicePath/GNUmakefile +@@ -14,7 +14,9 @@ OBJECTS = DevicePath.o UefiDevicePathLib.o DevicePathFromText.o DevicePathUtili + include $(MAKEROOT)/Makefiles/app.makefile + + # gcc 12 trips over device path handling ++ifeq ($(CXX), g++) + BUILD_CFLAGS += -Wno-error=stringop-overflow ++endif + + LIBS = -lCommon + ifeq ($(CYGWIN), CYGWIN) +diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile +index 0df728f..902e42f 100644 +--- a/BaseTools/Source/C/Makefiles/header.makefile ++++ b/BaseTools/Source/C/Makefiles/header.makefile +@@ -41,7 +41,7 @@ endif + CYGWIN:=$(findstring CYGWIN, $(shell uname -s)) + LINUX:=$(findstring Linux, $(shell uname -s)) + DARWIN:=$(findstring Darwin, $(shell uname -s)) +-ifeq ($(CXX), llvm) ++ifeq ($(CXX), clang++) + BUILD_CC ?= $(CLANG_BIN)clang + BUILD_CXX ?= $(CLANG_BIN)clang++ + BUILD_AS ?= $(CLANG_BIN)clang +@@ -85,11 +85,11 @@ ifeq ($(DARWIN),Darwin) + BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \ + -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g + else +-ifeq ($(CXX), llvm) ++ifeq ($(CXX), clang++) + BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ + -fno-delete-null-pointer-checks -Wall -Werror \ + -Wno-deprecated-declarations -Wno-self-assign \ +--Wno-unused-result -nostdlib -g ++-Wno-unused-result -Wno-error=unused-result -nostdlib -g + else + BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ + -fno-delete-null-pointer-checks -Wall -Werror \ +@@ -97,7 +97,7 @@ BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ + -Wno-unused-result -nostdlib -g + endif + endif +-ifeq ($(CXX), llvm) ++ifeq ($(CXX), clang++) + BUILD_LFLAGS = + BUILD_CXXFLAGS = -Wno-deprecated-register -Wno-unused-result + else +diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile +index fc32994..e8920f9 100644 +--- a/BaseTools/Source/C/VfrCompile/GNUmakefile ++++ b/BaseTools/Source/C/VfrCompile/GNUmakefile +@@ -16,7 +16,7 @@ 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) ++ifeq ($(CXX), clang++) + VFR_CPPFLAGS = -Wno-deprecated-register -DPCCTS_USE_NAMESPACE_STD $(BUILD_CPPFLAGS) + else + VFR_CPPFLAGS = -DPCCTS_USE_NAMESPACE_STD $(BUILD_CPPFLAGS) +diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile +index 559b1c9..f936f09 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) ++ifeq ($(CXX), clang++) + BUILD_CC?=$(CLANG_BIN)clang + else + BUILD_CC?=gcc +diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +index 5a3561e..9820bd9 100644 +--- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile ++++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile +@@ -114,7 +114,7 @@ PCCTS_H=../h + # + # UNIX + # +-ifeq ($(CXX), llvm) ++ifeq ($(CXX), clang++) + BUILD_CC?=$(CLANG_BIN)clang + else + BUILD_CC?=cc +-- +2.19.1 + diff --git a/edk2.spec b/edk2.spec index f5dceeb..d8622bb 100644 --- a/edk2.spec +++ b/edk2.spec @@ -5,7 +5,7 @@ Name: edk2 Version: %{stable_date} -Release: 13 +Release: 14 Summary: EFI Development Kit II License: BSD-2-Clause-Patent URL: https://github.com/tianocore/edk2 @@ -59,6 +59,7 @@ Patch0031: 0031-MdeModulePkg-UsbBusDxe-fix-NOOPT-build-error.patch Patch0032: 0032-BaseTools-GenEfs-GenSec-fix-gcc12-warning.patch Patch0033: 0033-BaseTools-LzmaCompress-fix-gcc12-warning.patch Patch0034: 0034-Basetools-turn-off-gcc12-warning.patch +Patch0035: 0035-support-build-with-clang.patch BuildRequires: acpica-tools gcc gcc-c++ libuuid-devel python3 bc nasm python3-unversioned-command @@ -260,6 +261,9 @@ chmod +x %{buildroot}%{_bindir}/Rsa2048Sha256GenerateKeys %endif %changelog +* Tue Aug 22 2023 feng luo - 202011-14 +- Support build with clang + * Thu Jul 13 2023 Jiabo Feng - 202011-13 - solving the compilation failure problem of gcc 12.3.0 -- Gitee