[v4,1/3] build: add aarch64 clang to meson cross-compile

Message ID 1611045187-8097-2-git-send-email-juraj.linkes@pantheon.tech (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series aarch64 clang cross compilation |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Juraj Linkeš Jan. 19, 2021, 8:33 a.m. UTC
  Create meson cross-file arm64_armv8_linux_clang_ubuntu1804.
Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.

The sysroot path must be in the cross-file so that Clang can find the
proper headers:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect
cross builds (only native builds). Support added in 0.51.0.
* setting pkg-config vars only affects lib searching, not includes
* splitting the cross-file into two (one with clang info, one with
paths) doesn't work. Support added in 0.52.0.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 config/arm/arm64_armv8_linux_clang_ubuntu1804 | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 config/arm/arm64_armv8_linux_clang_ubuntu1804
  

Comments

Thomas Monjalon Jan. 19, 2021, 4:08 p.m. UTC | #1
19/01/2021 09:33, Juraj Linkeš:
> Create meson cross-file arm64_armv8_linux_clang_ubuntu1804.

Why is it specific to Ubuntu 18.04?
I don't want to add specifc cross files per distributions.

> Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
> 
> The sysroot path must be in the cross-file so that Clang can find the
> proper headers:
> * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect
> cross builds (only native builds). Support added in 0.51.0.
> * setting pkg-config vars only affects lib searching, not includes
> * splitting the cross-file into two (one with clang info, one with
> paths) doesn't work. Support added in 0.52.0.

I don't understand the explanations above.
Please explain what is the bug and how it is fixed.

[...]
> +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '/usr/aarch64-linux-gnu']
> +c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
  
Juraj Linkeš Jan. 20, 2021, 8:24 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Tuesday, January 19, 2021 5:08 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: david.marchand@redhat.com; aconole@redhat.com;
> maicolgabriel@hotmail.com; jerinjacobk@gmail.com; ferruh.yigit@intel.com;
> Ruifeng.Wang@arm.com; dev@dpdk.org; bruce.richardson@intel.com
> Subject: Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-
> compile
> 
> 19/01/2021 09:33, Juraj Linkeš:
> > Create meson cross-file arm64_armv8_linux_clang_ubuntu1804.
> 
> Why is it specific to Ubuntu 18.04?
> I don't want to add specifc cross files per distributions.
> 
> > Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
> >
> > The sysroot path must be in the cross-file so that Clang can find the
> > proper headers:
> > * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect
> > cross builds (only native builds). Support added in 0.51.0.
> > * setting pkg-config vars only affects lib searching, not includes
> > * splitting the cross-file into two (one with clang info, one with
> > paths) doesn't work. Support added in 0.52.0.
> 
> I don't understand the explanations above.
> Please explain what is the bug and how it is fixed.
> 

I guess the missing piece is that the sysroot path is the ubuntu specific part. The explanations illustrate why we can't have a generic cross file with the current meson version - there's no way to pass the paths to cross builds. Now that I think about it, the commit message needs a rewrite - I should've mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to come from elsewhere (such as gcc) and thus we have to provide the paths.

> [...]
> > +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot',
> > +'/usr/aarch64-linux-gnu'] c_link_args = ['-target',
> > +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
> 
> 
>
  
Thomas Monjalon Jan. 20, 2021, 10:21 a.m. UTC | #3
20/01/2021 09:24, Juraj Linkeš:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 19/01/2021 09:33, Juraj Linkeš:
> > > Create meson cross-file arm64_armv8_linux_clang_ubuntu1804.
> > 
> > Why is it specific to Ubuntu 18.04?
> > I don't want to add specifc cross files per distributions.
> > 
> > > Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
> > >
> > > The sysroot path must be in the cross-file so that Clang can find the
> > > proper headers:
> > > * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect
> > > cross builds (only native builds). Support added in 0.51.0.
> > > * setting pkg-config vars only affects lib searching, not includes
> > > * splitting the cross-file into two (one with clang info, one with
> > > paths) doesn't work. Support added in 0.52.0.
> > 
> > I don't understand the explanations above.
> > Please explain what is the bug and how it is fixed.
> > 
> 
> I guess the missing piece is that the sysroot path is the ubuntu specific part. The explanations illustrate why we can't have a generic cross file with the current meson version - there's no way to pass the paths to cross builds. Now that I think about it, the commit message needs a rewrite - I should've mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to come from elsewhere (such as gcc) and thus we have to provide the paths.

Can it be done with the option -Dc_args?


> > [...]
> > > +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot',
> > > +'/usr/aarch64-linux-gnu'] c_link_args = ['-target',
> > > +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
  
Juraj Linkeš Jan. 20, 2021, 10:30 a.m. UTC | #4
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, January 20, 2021 11:22 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: david.marchand@redhat.com; aconole@redhat.com;
> maicolgabriel@hotmail.com; jerinjacobk@gmail.com; ferruh.yigit@intel.com;
> Ruifeng.Wang@arm.com; dev@dpdk.org; bruce.richardson@intel.com
> Subject: Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-
> compile
> 
> 20/01/2021 09:24, Juraj Linkeš:
> > From: Thomas Monjalon <thomas@monjalon.net>
> > > 19/01/2021 09:33, Juraj Linkeš:
> > > > Create meson cross-file arm64_armv8_linux_clang_ubuntu1804.
> > >
> > > Why is it specific to Ubuntu 18.04?
> > > I don't want to add specifc cross files per distributions.
> > >
> > > > Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
> > > >
> > > > The sysroot path must be in the cross-file so that Clang can find
> > > > the proper headers:
> > > > * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't
> > > > affect cross builds (only native builds). Support added in 0.51.0.
> > > > * setting pkg-config vars only affects lib searching, not includes
> > > > * splitting the cross-file into two (one with clang info, one with
> > > > paths) doesn't work. Support added in 0.52.0.
> > >
> > > I don't understand the explanations above.
> > > Please explain what is the bug and how it is fixed.
> > >
> >
> > I guess the missing piece is that the sysroot path is the ubuntu specific part.
> The explanations illustrate why we can't have a generic cross file with the
> current meson version - there's no way to pass the paths to cross builds. Now
> that I think about it, the commit message needs a rewrite - I should've
> mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to
> come from elsewhere (such as gcc) and thus we have to provide the paths.
> 
> Can it be done with the option -Dc_args?
> 

Not in Meson 0.47.1, it's explained in the commit msg:
* setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't 
affect cross builds (only native builds). Support added in 0.51.0.

> 
> > > [...]
> > > > +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot',
> > > > +'/usr/aarch64-linux-gnu'] c_link_args = ['-target',
> > > > +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
> 
> 
>
  
Thomas Monjalon Jan. 20, 2021, 10:34 a.m. UTC | #5
20/01/2021 11:30, Juraj Linkeš:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 20/01/2021 09:24, Juraj Linkeš:
> > > From: Thomas Monjalon <thomas@monjalon.net>
> > > > 19/01/2021 09:33, Juraj Linkeš:
> > > > > Create meson cross-file arm64_armv8_linux_clang_ubuntu1804.
> > > >
> > > > Why is it specific to Ubuntu 18.04?
> > > > I don't want to add specifc cross files per distributions.
> > > >
> > > > > Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
> > > > >
> > > > > The sysroot path must be in the cross-file so that Clang can find
> > > > > the proper headers:
> > > > > * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't
> > > > > affect cross builds (only native builds). Support added in 0.51.0.
> > > > > * setting pkg-config vars only affects lib searching, not includes
> > > > > * splitting the cross-file into two (one with clang info, one with
> > > > > paths) doesn't work. Support added in 0.52.0.
> > > >
> > > > I don't understand the explanations above.
> > > > Please explain what is the bug and how it is fixed.
> > > >
> > >
> > > I guess the missing piece is that the sysroot path is the ubuntu specific part.
> > The explanations illustrate why we can't have a generic cross file with the
> > current meson version - there's no way to pass the paths to cross builds. Now
> > that I think about it, the commit message needs a rewrite - I should've
> > mentioned that clang/llvm doesn't provide it's own standard c lib, so that has to
> > come from elsewhere (such as gcc) and thus we have to provide the paths.
> > 
> > Can it be done with the option -Dc_args?
> > 
> 
> Not in Meson 0.47.1, it's explained in the commit msg:
> * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't 
> affect cross builds (only native builds). Support added in 0.51.0.

So I suggest to make it clearer :)
One proposal:

* setting CFLAGS/LDFLAGS variables or using -Dc_args/-Dc_link_args options
  do not work on cross builds until Meson 0.51.0.

> > > > [...]
> > > > > +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot',
> > > > > +'/usr/aarch64-linux-gnu'] c_link_args = ['-target',
> > > > > +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
> > 
> > 
> > 
> 
>
  
Juraj Linkeš Jan. 21, 2021, 3:02 p.m. UTC | #6
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, January 20, 2021 11:35 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: david.marchand@redhat.com; aconole@redhat.com;
> maicolgabriel@hotmail.com; jerinjacobk@gmail.com; ferruh.yigit@intel.com;
> Ruifeng.Wang@arm.com; dev@dpdk.org; bruce.richardson@intel.com
> Subject: Re: [dpdk-dev] [PATCH v4 1/3] build: add aarch64 clang to meson cross-
> compile
> 
> 20/01/2021 11:30, Juraj Linkeš:
> > From: Thomas Monjalon <thomas@monjalon.net>
> > > 20/01/2021 09:24, Juraj Linkeš:
> > > > From: Thomas Monjalon <thomas@monjalon.net>
> > > > > 19/01/2021 09:33, Juraj Linkeš:
> > > > > > Create meson cross-file arm64_armv8_linux_clang_ubuntu1804.
> > > > >
> > > > > Why is it specific to Ubuntu 18.04?
> > > > > I don't want to add specifc cross files per distributions.
> > > > >
> > > > > > Use clang/LLVM toolchain with sysroot pointing to gcc cross stdlib.
> > > > > >
> > > > > > The sysroot path must be in the cross-file so that Clang can
> > > > > > find the proper headers:
> > > > > > * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't
> > > > > > affect cross builds (only native builds). Support added in 0.51.0.
> > > > > > * setting pkg-config vars only affects lib searching, not
> > > > > > includes
> > > > > > * splitting the cross-file into two (one with clang info, one
> > > > > > with
> > > > > > paths) doesn't work. Support added in 0.52.0.
> > > > >
> > > > > I don't understand the explanations above.
> > > > > Please explain what is the bug and how it is fixed.
> > > > >
> > > >
> > > > I guess the missing piece is that the sysroot path is the ubuntu specific part.
> > > The explanations illustrate why we can't have a generic cross file
> > > with the current meson version - there's no way to pass the paths to
> > > cross builds. Now that I think about it, the commit message needs a
> > > rewrite - I should've mentioned that clang/llvm doesn't provide it's
> > > own standard c lib, so that has to come from elsewhere (such as gcc) and
> thus we have to provide the paths.
> > >
> > > Can it be done with the option -Dc_args?
> > >
> >
> > Not in Meson 0.47.1, it's explained in the commit msg:
> > * setting CFLAGS, LDFLAGS or -Dc_args, -Dc_link_args doesn't affect
> > cross builds (only native builds). Support added in 0.51.0.
> 
> So I suggest to make it clearer :)
> One proposal:
> 
> * setting CFLAGS/LDFLAGS variables or using -Dc_args/-Dc_link_args options
>   do not work on cross builds until Meson 0.51.0.
> 

Ok, I'll reword the commit message to make it more clearer based on your feedback.

> > > > > [...]
> > > > > > +c_args = ['-target', 'aarch64-linux-gnu', '--sysroot',
> > > > > > +'/usr/aarch64-linux-gnu'] c_link_args = ['-target',
> > > > > > +'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']
> > >
> > >
> > >
> >
> >
> 
> 
> 
> 
>
  

Patch

diff --git a/config/arm/arm64_armv8_linux_clang_ubuntu1804 b/config/arm/arm64_armv8_linux_clang_ubuntu1804
new file mode 100644
index 000000000..aa5ee0132
--- /dev/null
+++ b/config/arm/arm64_armv8_linux_clang_ubuntu1804
@@ -0,0 +1,20 @@ 
+[binaries]
+c = 'clang'
+cpp = 'clang++'
+ar = 'llvm-ar'
+strip = 'llvm-strip'
+llvm-config = 'llvm-config'
+pcap-config = 'llvm-config'
+pkgconfig = 'aarch64-linux-gnu-pkg-config'
+
+[host_machine]
+system = 'linux'
+cpu_family = 'aarch64'
+cpu = 'armv8-a'
+endian = 'little'
+
+[properties]
+implementor_id = 'generic'
+implementor_pn = 'default'
+c_args = ['-target', 'aarch64-linux-gnu', '--sysroot', '/usr/aarch64-linux-gnu']
+c_link_args = ['-target', 'aarch64-linux-gnu', '-fuse-ld=lld', '--gcc-toolchain=/usr']