Skip to content

Instantly share code, notes, and snippets.

@mariasfiraiala
Last active July 11, 2022 09:29
Show Gist options
  • Save mariasfiraiala/6e5d5ad67952c46b79cb12b9875a7241 to your computer and use it in GitHub Desktop.
Save mariasfiraiala/6e5d5ad67952c46b79cb12b9875a7241 to your computer and use it in GitHub Desktop.
Patch which demonstrates needed modifications in order to compile Unikraft apps on Aarch64 using clang

Credits go to michpappas for providing this facil workaround.

  • After modifying the files accordingly, build using
make CC=clang LD=~/toolchains/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gcc OBJCOPY=~/toolchains/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/aarch64-none-elf-objcopy STRIP=~/toolchains/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin/aarch64-none-elf-strip
  • You'll need the gcc cross-compiling toolchain installed. Get it from here.

  • Also, make sure to have erratum options disabled when using menuconfig (Architecture Selection -> Arm8 Compatible -> Workaround for [...] erratum).

  • What's more, you'll have to configure the Custom cross-compiler LLVM target too (Build Options -> Custom cross-compiler LLVM target); just write aarch64-none-elf and you should be good to go.

  • As one of my professors used to say: "Trivial".

diff --git a/Makefile b/Makefile
index e9f4044..b00796e 100644
--- a/Makefile
+++ b/Makefile
@@ -616,6 +616,10 @@ CC_VERSION := $(shell $(CC) --version | \
CC_VER_MAJOR := $(word 1,$(subst ., ,$(CC_VERSION)))
CC_VER_MINOR := $(word 2,$(subst ., ,$(CC_VERSION)))
+CFLAGS += --target=$(CONFIG_LLVM_TARGET_ARCH)
+ASFLAGS += --target=$(CONFIG_LLVM_TARGET_ARCH)
+CXXFLAGS += --target=$(CONFIG_LLVM_TARGET_ARCH)
+
ASFLAGS += -DCC_VERSION=$(CC_VERSION)
CFLAGS += -DCC_VERSION=$(CC_VERSION)
CXXFLAGS += -DCC_VERSION=$(CC_VERSION)
diff --git a/plat/common/pci_ecam.c b/plat/common/pci_ecam.c
index c884f11..7c069db 100644
--- a/plat/common/pci_ecam.c
+++ b/plat/common/pci_ecam.c
@@ -226,7 +226,7 @@ int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq)
fdt32_t initial_match_array[16];
const fdt32_t *match_array = initial_match_array;
const fdt32_t *tmp, *imap, *imask;
- const fdt32_t dummy_imask[] = { [0 ... 16] = cpu_to_fdt32(~0) };
+ const fdt32_t dummy_imask[] = { 0 };
int intsize, newintsize;
int addrsize, newaddrsize = 0;
int imaplen, match, i, rc = -EINVAL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment