Use LLVM Clang + Lld by default

This commit is contained in:
bzt 2021-02-16 11:12:36 +01:00
parent 01776125d9
commit 804d74b0a2
5 changed files with 14 additions and 14 deletions

View file

@ -58,8 +58,8 @@ int main(int argc, wchar_t **argv)
return 0;
}
```
By default it uses the host native's GNU gcc + ld, creates a shared object and converts that into .efi file. If `USE_LLVM`
is given, then LLVM CLang + lld used, and native PE is generated, no conversion involved.
By default it uses Clang + lld, and PE is generated without conversion. If `USE_GCC` is set, then the host native's GNU gcc + ld
used to create a shared object and get converted into an .efi file.
### Available Makefile Options
@ -70,7 +70,7 @@ is given, then LLVM CLang + lld used, and native PE is generated, no conversion
| `CFLAGS` | compiler flags you want to use (empty by default, like "-Wall -pedantic -std=c99") |
| `LDFLAGS` | linker flags you want to use (I don't think you'll ever need this, just in case) |
| `LIBS` | additional libraries you want to link with (like "-lm", only static .a libraries allowed) |
| `USE_LLVM` | set this if you want LLVM Clang + Lld instead of GNU gcc + ld |
| `USE_GCC` | set this if you want native GNU gcc + ld + objccopy instead of LLVM Clang + Lld |
| `ARCH` | the target architecture |
Here's a more advanced **Makefile** example:
@ -82,7 +82,7 @@ CFLAGS = -pedantic -Wall -Wextra -Werror --std=c11 -O2
LDFLAGS =
LIBS = -lm
USE_LLVM = 1
USE_GCC = 1
include uefi/Makefile
```
The build environment configurator was created in a way that it can handle any number of architectures, however

View file

@ -13,6 +13,6 @@ CFLAGS = -pedantic -Wall -Wextra -Werror --ansi -O2
# leave the hard work and all the rest to posix-uefi
# set this if you want LLVM Clang / Lld instead of GNU gcc / ld
#USE_LLVM = 1
# set this if you want GNU gcc + ld + objcopy instead of LLVM Clang + Lld
#USE_GCC = 1
include uefi/Makefile

View file

@ -1,4 +1,4 @@
TARGET = args.efi
#USE_LLVM=1
#USE_GCC=1
include uefi/Makefile

View file

@ -1,4 +1,4 @@
TARGET = dumpmem.efi
#USE_LLVM=1
#USE_GCC=1
include uefi/Makefile

View file

@ -20,10 +20,10 @@ TMP = $(LIBSRCS:.c=.o)
LIBOBJS = $(TMP:.S=.o)
# detect toolchain
ifeq ($(wildcard /usr/bin/gcc),)
USE_LLVM = 1
ifeq ($(wildcard /usr/bin/clang),)
USE_GCC = 1
endif
ifeq ($(USE_LLVM),)
ifneq ($(USE_GCC),)
ifeq ($(ARCH),x86_64)
CFLAGS += -maccumulate-outgoing-args
endif
@ -65,12 +65,12 @@ endif
all: $(ALLTARGETS)
uefi/libuefi.a:
@make --no-print-directory -C uefi libuefi.a USE_LLVM=$(USE_LLVM) ARCH=$(ARCH)
@make --no-print-directory -C uefi libuefi.a USE_GCC=$(USE_GCC) ARCH=$(ARCH)
libuefi.lib: $(LIBOBJS)
libuefi.a: $(LIBOBJS)
ifeq ($(USE_LLVM),)
ifneq ($(USE_GCC),)
@rm $@ 2>/dev/null || true
$(AR) -frsv $@ $(LIBOBJS) >/dev/null
else
@ -78,7 +78,7 @@ else
endif
$(TARGET): $(TARGET).so
ifeq ($(USE_LLVM),)
ifneq ($(USE_GCC),)
@$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc --target $(EFIARCH) --subsystem=10 $^ $@ || echo target: $(EFIARCH)
@rm $(TARGET).so
endif