diff --git a/arch/lkl/auto.conf b/arch/lkl/auto.conf index cf257066a5f745..371f7b4a68c901 100644 --- a/arch/lkl/auto.conf +++ b/arch/lkl/auto.conf @@ -1,2 +1,9 @@ -export OUTPUT_FORMAT=$(shell $(LD) -r -print-output-format) +ifneq ($(shell $(LD) --version 2>&1 | head -n 1 | grep LLD),) + CC_TARGET=$(shell $(CC) --version 2>&1 | grep Target | cut -d " " -f2) + ifeq ($(CC_TARGET),x86_64-unknown-linux-gnu) + export OUTPUT_FORMAT=elf64-x86-64 + endif +else + export OUTPUT_FORMAT=$(shell $(LD) -r -print-output-format) +endif export EXEC_FORMAT=$(shell echo $(OUTPUT_FORMAT) | cut -d - -f1) diff --git a/tools/lkl/Makefile.autoconf b/tools/lkl/Makefile.autoconf index 38a2473c70623f..74aea30a1a8799 100644 --- a/tools/lkl/Makefile.autoconf +++ b/tools/lkl/Makefile.autoconf @@ -8,6 +8,17 @@ define set_autoconf_var export LKL_HOST_CONFIG_$(1)=$(2) endef +define output_format + $(if $(shell $(LD) --version 2>&1 | head -n 1 \ + | grep LLD),$(eval lld=yes),$(eval lld=no)) + $(if $(filter yes,$(lld)),$(eval target=$(shell $(CC) --version 2>&1 \ + | grep Target | cut -d " " -f2))) + $(if $(filter x86_64-unknown-linux-gnu,$(target)),$(call \ + set_autoconf_var,OUTPUT_FORMAT,"elf64-x86-64")) + $(if $(filter no,$(lld)),$(call set_autoconf_var,OUTPUT_FORMAT,"$(shell \ + $(LD) -r -print-output-format)")) +endef + define find_include $(eval include_paths=$(shell $(CC) -E -Wp,-v -xc /dev/null 2>&1 | grep '^ ')) $(foreach f, $(include_paths), $(wildcard $(f)/$(1))) @@ -98,7 +109,8 @@ define do_autoconf export AR := $(CROSS_COMPILE)ar $(eval LD := $(CROSS_COMPILE)ld) $(eval CC := $(CROSS_COMPILE)gcc) - $(eval LD_FMT := $(shell $(LD) -r -print-output-format)) + $(call output_format) + $(eval LD_FMT := $(shell echo $(LKL_HOST_CONFIG_OUTPUT_FORMAT))) $(eval EXEC_FMT := $(shell echo $(LD_FMT) | cut -d "-" -f1)) $(if $(filter $(EXEC_FMT),$(POSIX_HOSTS)),$(call posix_host,$(LD_FMT))) $(if $(filter $(EXEC_FMT),$(NT_HOSTS)),$(call nt_host,$(LD_FMT)))