diff mbox series

[3/5] build: arm64: provide -target and -march if using clang

Message ID 20241129014850.2852844-4-volodymyr_babchuk@epam.com (mailing list archive)
State New
Headers show
Series aarch64, common: improve clang and llvm support | expand

Commit Message

Volodymyr Babchuk Nov. 29, 2024, 1:49 a.m. UTC
Provide -target and -march explicitly when building with clang. This
makes cross-compilation much easier, because clang accept this
parameters regardless of host platform. Basically,

  make XEN_TARGET_ARCH=arm64 clang=y llvm=y

will behave in the same way if building Xen on x86, or on arm64 or on
any other platform.

-march is required because with default value, clang will not
recognize EL2 registers.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
---
 config/arm64.mk | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jan Beulich Nov. 29, 2024, 8:04 a.m. UTC | #1
On 29.11.2024 02:49, Volodymyr Babchuk wrote:
> Provide -target and -march explicitly when building with clang. This
> makes cross-compilation much easier, because clang accept this
> parameters regardless of host platform. Basically,
> 
>   make XEN_TARGET_ARCH=arm64 clang=y llvm=y
> 
> will behave in the same way if building Xen on x86, or on arm64 or on
> any other platform.
> 
> -march is required because with default value, clang will not
> recognize EL2 registers.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> ---
>  config/arm64.mk | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/config/arm64.mk b/config/arm64.mk
> index c4662f67d0..97eb9a82e7 100644
> --- a/config/arm64.mk
> +++ b/config/arm64.mk
> @@ -5,6 +5,10 @@ CONFIG_XEN_INSTALL_SUFFIX :=
>  
>  CFLAGS += #-marm -march= -mcpu= etc
>  
> +ifeq ($(clang),y)
> +CFLAGS += -target aarch64 -march=armv8-a
> +endif

Why is this dependent on (just?) $(clang), not (also?) $(llvm)? Also
this affects both toolstack builds and hypervisor. Is applying -march
like this actually appropriate for the toolstack?

Jan
diff mbox series

Patch

diff --git a/config/arm64.mk b/config/arm64.mk
index c4662f67d0..97eb9a82e7 100644
--- a/config/arm64.mk
+++ b/config/arm64.mk
@@ -5,6 +5,10 @@  CONFIG_XEN_INSTALL_SUFFIX :=
 
 CFLAGS += #-marm -march= -mcpu= etc
 
+ifeq ($(clang),y)
+CFLAGS += -target aarch64 -march=armv8-a
+endif
+
 # Use only if calling $(LD) directly.
 LDFLAGS_DIRECT += -EL