diff --git a/0032-BaseTools-GenEfs-GenSec-fix-gcc12-warning.patch b/0032-BaseTools-GenEfs-GenSec-fix-gcc12-warning.patch index 59197006c1b85166acd7401bcaf896bdb61d9161..705822475dc296ec79068167f36d3fc54d72ad33 100644 --- a/0032-BaseTools-GenEfs-GenSec-fix-gcc12-warning.patch +++ b/0032-BaseTools-GenEfs-GenSec-fix-gcc12-warning.patch @@ -25,26 +25,26 @@ index 949025c333..d78d62ab36 100644 --- a/BaseTools/Source/C/GenFfs/GenFfs.c +++ b/BaseTools/Source/C/GenFfs/GenFfs.c @@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) - PeFileBuffer = (UINT8 *) malloc (PeFileSize); - if (PeFileBuffer == NULL) { - fclose (InFileHandle); -- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); -+ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); - return EFI_OUT_OF_RESOURCES; - } - fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); + PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { + fclose (InFileHandle); +- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); ++ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); + return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index d54a4f9e0a..b1d05367ec 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) - PeFileBuffer = (UINT8 *) malloc (PeFileSize); - if (PeFileBuffer == NULL) { - fclose (InFileHandle); -- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); -+ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); - return EFI_OUT_OF_RESOURCES; - } - fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); + PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { + fclose (InFileHandle); +- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); ++ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); + return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); -- -2.41.0 \ No newline at end of file +2.41.0 diff --git a/0035-support-build-with-clang.patch b/0035-support-build-with-clang.patch new file mode 100644 index 0000000000000000000000000000000000000000..2eb5ce17849bdacae3f310407e2aed14875f58dd --- /dev/null +++ b/0035-support-build-with-clang.patch @@ -0,0 +1,89 @@ +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 diff --git a/edk2.spec b/edk2.spec index f5dceebefa3a438941e6dc2c67bbfe5aa45f2360..d8622bb9c85834211f8fc00761a797445d448876 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