[Buildroot] [PATCH v1 06/30] package/llvm: add config to build backend for host arch

Romain Naour romain.naour at smile.fr
Sat Feb 29 18:17:53 UTC 2020


Hello Michael,

Le 05/12/2019 à 18:14, Michael Drake a écrit :
> From: Joseph Kogut <joseph.kogut at gmail.com>
> 
> When cross-compiling for a different architecture to the host,
> LLVM only has target architecture support.  This change adds
> support for compiling for the host architecture as well.
> 
> Signed-off-by: Joseph Kogut <joseph.kogut at gmail.com>
> Signed-off-by: Michael Drake <michael.drake at codethink.co.uk>
> Signed-off-by: Thomas Preston <thomas.preston at codethink.co.uk>
> ---
>  package/llvm/Config.in | 6 ++++++
>  package/llvm/llvm.mk   | 6 +++++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/package/llvm/Config.in b/package/llvm/Config.in
> index 1d21d879da..ae96d30a64 100644
> --- a/package/llvm/Config.in
> +++ b/package/llvm/Config.in
> @@ -28,6 +28,12 @@ config BR2_PACKAGE_LLVM
>  
>  if BR2_PACKAGE_LLVM
>  

This should be outside of BR2_PACKAGE_LLVM, like BR2_PACKAGE_LLVM_TARGET_ARCH.

> +config BR2_PACKAGE_HOST_LLVM_HOST_ARCH
> +	string
> +	default "X86" if BR2_HOSTARCH = "x86" || BR2_HOSTARCH = "x86_64"
> +	default "AArch64" if BR2_HOSTARCH="aarch64"
> +	default "ARM" if BR2_HOSTARCH = "arm"
> +
>  config BR2_PACKAGE_LLVM_AMDGPU
>  	bool "AMDGPU backend"
>  	help
> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
> index 2b2bcf336e..300ac3e300 100644
> --- a/package/llvm/llvm.mk
> +++ b/package/llvm/llvm.mk
> @@ -42,7 +42,10 @@ LLVM_TARGET_ARCH = $(call qstrip,$(BR2_PACKAGE_LLVM_TARGET_ARCH))
>  
>  # Build backend for target architecture. This include backends like AMDGPU.
>  LLVM_TARGETS_TO_BUILD = $(LLVM_TARGET_ARCH)
> -HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(subst $(space),;,$(LLVM_TARGETS_TO_BUILD))"
> +HOST_LLVM_TARGETS_TO_BUILD = \
> +	$(LLVM_TARGETS_TO_BUILD) \
> +	$(call qstrip,$(BR2_PACKAGE_HOST_LLVM_HOST_ARCH))
> +HOST_LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(subst $(space),;,$(HOST_LLVM_TARGETS_TO_BUILD))"

Maybe we want to consider the case where llvm is supported by the host
(BR2_PACKAGE_HOST_LLVM_HOST_ARCH is set) but not by the selected target
(BR2_PACKAGE_LLVM_TARGET_ARCH is not set).

In this case LLVM_TARGETS_TO_BUILD would be -DLLVM_TARGETS_TO_BUILD=";X86" due
to a space before the host target string (X86).

Some one may need host-llvm (ex qdoc) [1]

[1] http://patchwork.ozlabs.org/patch/1246516/

>  LLVM_CONF_OPTS += -DLLVM_TARGETS_TO_BUILD="$(subst $(space),;,$(LLVM_TARGETS_TO_BUILD))"
>  
>  # LLVM target to use for native code generation. This is required for JIT generation.
> @@ -58,6 +61,7 @@ LLVM_CONF_OPTS += -DLLVM_TARGET_ARCH=$(LLVM_TARGET_ARCH)
>  # output only $(LLVM_TARGET_ARCH) if not, and mesa3d won't build as
>  # it thinks AMDGPU backend is not installed on the target.
>  ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
> +HOST_LLVM_TARGETS_TO_BUILD += AMDGPU

Ok, we need to keep AMDGPU here to keep llvm-config working for the cross build
process.

Best regards,
Romain

>  LLVM_TARGETS_TO_BUILD += AMDGPU
>  endif
>  
> 



More information about the buildroot mailing list