fix clang support.

Tested:
  make all apps + tests apps/ on x86_64
  make CC=clang all apps + tests apps/ on x86_64

Signed-off-by: David Decotigny <ddecotig@gmail.com>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
This commit is contained in:
Nigel Croxon 2017-02-17 16:24:26 -05:00
parent bdb6182f0a
commit 787cb7fcd8
4 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -97,7 +97,7 @@ static struct {
{ &SMapId, L"ShellDevPathMap" },
{ &SAliasId, L"ShellAlias" },
{ NULL }
{ NULL, NULL }
};
//