diff --git a/Make.defaults b/Make.defaults index 51bd7d8..16f1fd2 100755 --- a/Make.defaults +++ b/Make.defaults @@ -101,6 +101,7 @@ endif ifeq ($(ARCH),x86_64) GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d.) GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d.) + USING_CLANG := $(shell $(CC) -v 2>&1 | grep -q 'clang version' && echo clang) # Rely on GCC MS ABI support? GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \ @@ -109,6 +110,8 @@ ifeq ($(ARCH),x86_64) && echo 1) ifeq ($(GCCNEWENOUGH),1) CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 + else ifeq ($(USING_CLANG),clang) + CPPFLAGS += -DGNU_EFI_USE_MS_ABI --std=c11 endif CFLAGS += -mno-red-zone @@ -159,7 +162,7 @@ CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \ else CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \ -fshort-wchar -fno-strict-aliasing \ - -fno-merge-constants -ffreestanding -fno-stack-protector \ + -fno-merge-all-constants -ffreestanding -fno-stack-protector \ -fno-stack-check endif diff --git a/apps/debughook.c b/apps/debughook.c index fb6cdad..93cd0cf 100644 --- a/apps/debughook.c +++ b/apps/debughook.c @@ -37,8 +37,13 @@ GetVariable(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner) EFI_GUID DUMMY_GUID = {0x55aad538, 0x8f82, 0x4e2a, {0xa4,0xf0,0xbe, 0x59, 0x13, 0xb6, 0x5f, 0x1e}}; -static void -__attribute__((__optimize__("0"))) +#if defined(__clang__) +# define _OPTNONE __attribute__((optnone)) +#else +# define _OPTNONE __attribute__((__optimize__("0"))) +#endif + +static _OPTNONE void DebugHook(void) { EFI_GUID guid = DUMMY_GUID; diff --git a/inc/x86_64/efibind.h b/inc/x86_64/efibind.h index 5ee620b..de37641 100644 --- a/inc/x86_64/efibind.h +++ b/inc/x86_64/efibind.h @@ -25,6 +25,8 @@ Revision History #if defined(GNU_EFI_USE_MS_ABI) #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) #define HAVE_USE_MS_ABI 1 + #elif defined(__clang__) + #define HAVE_USE_MS_ABI 1 #else #error Compiler is too old for GNU_EFI_USE_MS_ABI #endif diff --git a/lib/guid.c b/lib/guid.c index bd1f1a5..8daa505 100644 --- a/lib/guid.c +++ b/lib/guid.c @@ -97,7 +97,7 @@ static struct { { &SMapId, L"ShellDevPathMap" }, { &SAliasId, L"ShellAlias" }, - { NULL } + { NULL, NULL } }; //