diff mbox series

[RFC,1/7] xen: clang: Support correctly cross-compile

Message ID 1573031953-12894-2-git-send-email-andrii.anisov@gmail.com (mailing list archive)
State New, archived
Headers show
Series Build XEN with ARM Compiler 6.6.3 | expand

Commit Message

Andrii Anisov Nov. 6, 2019, 9:19 a.m. UTC
From: Julien Grall <julien.grall@arm.com>

Clang uses "-target" option for cross-compilation.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 config/StdGNU.mk | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Wei Liu Nov. 6, 2019, 11:07 a.m. UTC | #1
On Wed, Nov 06, 2019 at 11:19:07AM +0200, Andrii Anisov wrote:
> From: Julien Grall <julien.grall@arm.com>
> 
> Clang uses "-target" option for cross-compilation.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> ---
>  config/StdGNU.mk | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/config/StdGNU.mk b/config/StdGNU.mk
> index 039274e..48c50b5 100644
> --- a/config/StdGNU.mk
> +++ b/config/StdGNU.mk
> @@ -1,8 +1,13 @@
>  AS         = $(CROSS_COMPILE)as
>  LD         = $(CROSS_COMPILE)ld
>  ifeq ($(clang),y)
> -CC         = $(CROSS_COMPILE)clang
> -CXX        = $(CROSS_COMPILE)clang++
> +ifneq ($(CROSS_COMPILE),)
> +CC         = clang -target $(CROSS_COMPILE:-=)
> +CXX        = clang++ -target $(CROSS_COMPILE:-=)
> +else
> +CC         = clang
> +CXX        = clang++
> +endif
>  LD_LTO     = $(CROSS_COMPILE)llvm-ld

Do you not need to fix llvm-ld too? I _think_ the relevant option is
-march.

Wei.

>  else
>  CC         = $(CROSS_COMPILE)gcc
> -- 
> 2.7.4
>
Jan Beulich Nov. 6, 2019, 3:24 p.m. UTC | #2
On 06.11.2019 10:19, Andrii Anisov wrote:
> --- a/config/StdGNU.mk
> +++ b/config/StdGNU.mk
> @@ -1,8 +1,13 @@
>  AS         = $(CROSS_COMPILE)as
>  LD         = $(CROSS_COMPILE)ld
>  ifeq ($(clang),y)
> -CC         = $(CROSS_COMPILE)clang
> -CXX        = $(CROSS_COMPILE)clang++
> +ifneq ($(CROSS_COMPILE),)
> +CC         = clang -target $(CROSS_COMPILE:-=)
> +CXX        = clang++ -target $(CROSS_COMPILE:-=)

And what guarantees that (with the hyphens dropped) the prefix
$(CROSS_COMPILE) originally represents to a valid value for
clang's -target? Please don't forget that people may use non-
standard $(CROSS_COMPILE) setting as well (to e.g. match their
local setup of how to invoke cross compilers).

Jan
Julien Grall Nov. 18, 2019, 6:08 a.m. UTC | #3
Hi,

On 06/11/2019 09:19, Andrii Anisov wrote:
> From: Julien Grall <julien.grall@arm.com>
> 
> Clang uses "-target" option for cross-compilation.

While I appreaciate you want to carry this work, there were a lenghty 
discussion when I sent the patch (see [1]). This should have been 
addressed before resending it (even part of an RFC).

But, AFAICT, you don't use clang=y for this series. So why did you 
include it in this series?

Cheers,

[1] <20190327184531.30986-2-julien.grall@arm.com>
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> ---
>   config/StdGNU.mk | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/config/StdGNU.mk b/config/StdGNU.mk
> index 039274e..48c50b5 100644
> --- a/config/StdGNU.mk
> +++ b/config/StdGNU.mk
> @@ -1,8 +1,13 @@
>   AS         = $(CROSS_COMPILE)as
>   LD         = $(CROSS_COMPILE)ld
>   ifeq ($(clang),y)
> -CC         = $(CROSS_COMPILE)clang
> -CXX        = $(CROSS_COMPILE)clang++
> +ifneq ($(CROSS_COMPILE),)
> +CC         = clang -target $(CROSS_COMPILE:-=)
> +CXX        = clang++ -target $(CROSS_COMPILE:-=)
> +else
> +CC         = clang
> +CXX        = clang++
> +endif
>   LD_LTO     = $(CROSS_COMPILE)llvm-ld
>   else
>   CC         = $(CROSS_COMPILE)gcc
>
diff mbox series

Patch

diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index 039274e..48c50b5 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -1,8 +1,13 @@ 
 AS         = $(CROSS_COMPILE)as
 LD         = $(CROSS_COMPILE)ld
 ifeq ($(clang),y)
-CC         = $(CROSS_COMPILE)clang
-CXX        = $(CROSS_COMPILE)clang++
+ifneq ($(CROSS_COMPILE),)
+CC         = clang -target $(CROSS_COMPILE:-=)
+CXX        = clang++ -target $(CROSS_COMPILE:-=)
+else
+CC         = clang
+CXX        = clang++
+endif
 LD_LTO     = $(CROSS_COMPILE)llvm-ld
 else
 CC         = $(CROSS_COMPILE)gcc