From 32f71225382ddb7dd1ad51f584bc3d42a7ee39d1 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 12 Apr 2018 13:24:48 -0400 Subject: [PATCH 02/62] Makefiles: ensure -m32 gets propogated to our gcc parameter queries 'gcc -print-file-name=include' and 'gcc -print-libgcc-file-name' both need -m32 when we're building 32-on-64 on some distros, so ensure that gets propogated correctly. Signed-off-by: Peter Jones Upstream-commit-id: 104d6e54ac7 --- Make.defaults | 66 ++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/Make.defaults b/Make.defaults index e11ab5a7f2c..bbfc1d7f77b 100644 --- a/Make.defaults +++ b/Make.defaults @@ -33,66 +33,46 @@ EFI_INCLUDES = -nostdinc -I$(TOPDIR)/Cryptlib -I$(TOPDIR)/Cryptlib/Include \ -I$(EFI_INCLUDE) -I$(EFI_INCLUDE)/$(ARCH) -I$(EFI_INCLUDE)/protocol \ -I$(TOPDIR)/include -iquote $(TOPDIR) -iquote $(shell pwd) -LIB_GCC = $(shell $(CC) -print-libgcc-file-name) -EFI_LIBS = -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group $(LIB_GCC) - EFI_CRT_OBJS = $(EFI_PATH)/crt0-efi-$(ARCH).o EFI_LDS = $(TOPDIR)/elf_$(ARCH)_efi.lds -CFLAGS = -ggdb -O0 -fno-stack-protector -fno-strict-aliasing -fpic \ - -fshort-wchar -Wall -Wsign-compare -Werror -fno-builtin \ - -Werror=sign-compare -ffreestanding -std=gnu89 \ - -I$(shell $(CC) -print-file-name=include) \ - "-DDEFAULT_LOADER=L\"$(DEFAULT_LOADER)\"" \ - "-DDEFAULT_LOADER_CHAR=\"$(DEFAULT_LOADER)\"" \ - $(EFI_INCLUDES) - CLANG_BUGS = $(if $(findstring gcc,$(CC)),-maccumulate-outgoing-args,) COMMIT_ID ?= $(shell if [ -e .git ] ; then git log -1 --pretty=format:%H ; elif [ -f commit ]; then cat commit ; else echo master; fi) -ifneq ($(origin OVERRIDE_SECURITY_POLICY), undefined) - CFLAGS += -DOVERRIDE_SECURITY_POLICY -endif - -ifneq ($(origin ENABLE_HTTPBOOT), undefined) - CFLAGS += -DENABLE_HTTPBOOT -endif - -ifneq ($(origin REQUIRE_TPM), undefined) - CFLAGS += -DREQUIRE_TPM -endif - ifeq ($(ARCH),x86_64) - CFLAGS += -mno-mmx -mno-sse -mno-red-zone -nostdinc \ - $(CLANG_BUGS) -m64 \ - -DEFI_FUNCTION_WRAPPER -DGNU_EFI_USE_MS_ABI \ - -DNO_BUILTIN_VA_FUNCS -DMDE_CPU_X64 -DPAGE_SIZE=4096 + ARCH_CFLAGS ?= -mno-mmx -mno-sse -mno-red-zone -nostdinc \ + $(CLANG_BUGS) -m64 \ + -DEFI_FUNCTION_WRAPPER -DGNU_EFI_USE_MS_ABI \ + -DNO_BUILTIN_VA_FUNCS -DMDE_CPU_X64 \ + -DPAGE_SIZE=4096 LIBDIR ?= $(prefix)/lib64 ARCH_SUFFIX ?= x64 ARCH_SUFFIX_UPPER ?= X64 ARCH_LDFLAGS ?= endif ifeq ($(ARCH),ia32) - CFLAGS += -mno-mmx -mno-sse -mno-red-zone -nostdinc \ - $(CLANG_BUGS) -m32 \ - -DMDE_CPU_IA32 -DPAGE_SIZE=4096 + ARCH_CFLAGS ?= -mno-mmx -mno-sse -mno-red-zone -nostdinc \ + $(CLANG_BUGS) -m32 \ + -DMDE_CPU_IA32 -DPAGE_SIZE=4096 LIBDIR ?= $(prefix)/lib ARCH_SUFFIX ?= ia32 ARCH_SUFFIX_UPPER ?= IA32 ARCH_LDFLAGS ?= + ARCH_CFLAGS ?= -m32 endif ifeq ($(ARCH),aarch64) - CFLAGS += -DMDE_CPU_AARCH64 -DPAGE_SIZE=4096 -mstrict-align + ARCH_CFLAGS ?= -DMDE_CPU_AARCH64 -DPAGE_SIZE=4096 -mstrict-align LIBDIR ?= $(prefix)/lib64 ARCH_SUFFIX ?= aa64 ARCH_SUFFIX_UPPER ?= AA64 FORMAT := -O binary SUBSYSTEM := 0xa ARCH_LDFLAGS += --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM) + ARCH_CFLAGS ?= endif ifeq ($(ARCH),arm) - CFLAGS += -DMDE_CPU_ARM -DPAGE_SIZE=4096 -mstrict-align + ARCH_CFLAGS ?= -DMDE_CPU_ARM -DPAGE_SIZE=4096 -mstrict-align LIBDIR ?= $(prefix)/lib ARCH_SUFFIX ?= arm ARCH_SUFFIX_UPPER ?= ARM @@ -101,6 +81,28 @@ ifeq ($(ARCH),arm) ARCH_LDFLAGS += --defsym=EFI_SUBSYSTEM=$(SUBSYSTEM) endif +CFLAGS = -ggdb -O0 -fno-stack-protector -fno-strict-aliasing -fpic \ + -fshort-wchar -Wall -Wsign-compare -Werror -fno-builtin \ + -Werror=sign-compare -ffreestanding -std=gnu89 \ + -I$(shell $(CC) $(ARCH_CFLAGS) -print-file-name=include) \ + "-DDEFAULT_LOADER=L\"$(DEFAULT_LOADER)\"" \ + "-DDEFAULT_LOADER_CHAR=\"$(DEFAULT_LOADER)\"" \ + $(EFI_INCLUDES) $(ARCH_CFLAGS) + +ifneq ($(origin OVERRIDE_SECURITY_POLICY), undefined) + CFLAGS += -DOVERRIDE_SECURITY_POLICY +endif + +ifneq ($(origin ENABLE_HTTPBOOT), undefined) + CFLAGS += -DENABLE_HTTPBOOT +endif + +ifneq ($(origin REQUIRE_TPM), undefined) + CFLAGS += -DREQUIRE_TPM +endif + +LIB_GCC = $(shell $(CC) $(ARCH_CFLAGS) -print-libgcc-file-name) +EFI_LIBS = -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group $(LIB_GCC) FORMAT ?= --target efi-app-$(ARCH) EFI_PATH ?= $(LIBDIR)/gnuefi -- 2.26.2