diff mbox series

meson: Adjust for clang compiler

Message ID 20180127070626.27581-1-raj.khem@gmail.com
State Accepted
Commit 05789489d25a5ceac0403613ad789d78198be6ee
Headers show
Series meson: Adjust for clang compiler | expand

Commit Message

Khem Raj Jan. 27, 2018, 7:06 a.m. UTC
Remove hardcoding c/c++ compiler to be gcc alone, its
possible to use clang as replacement for cross compilers
from meta-clang, therefore set clang/clang++ if
TOOLCHAIN = "clang"

Signed-off-by: Khem Raj <raj.khem@gmail.com>

---
 meta/classes/meson.bbclass | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

-- 
2.16.1

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Comments

Ross Burton Jan. 29, 2018, 5:21 p.m. UTC | #1
On 27 January 2018 at 07:06, Khem Raj <raj.khem@gmail.com> wrote:

> Remove hardcoding c/c++ compiler to be gcc alone, its

> possible to use clang as replacement for cross compilers

> from meta-clang, therefore set clang/clang++ if

> TOOLCHAIN = "clang"

>

> Signed-off-by: Khem Raj <raj.khem@gmail.com>

> ---

>  meta/classes/meson.bbclass | 9 +++++++--

>  1 file changed, 7 insertions(+), 2 deletions(-)

>

> diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass

> index 91ac652651..cd3497a802 100644

> --- a/meta/classes/meson.bbclass

> +++ b/meta/classes/meson.bbclass

> @@ -40,6 +40,11 @@ EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"

>  MESON_CROSS_FILE = ""

>  MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"

>

> +CCOMPILER ?= "gcc"

> +CXXCOMPILER ?= "g++"

> +CCOMPILER_toolchain-clang = "clang"

> +CXXCOMPILER_toolchain-clang = "clang++"

> +

>


Can we do this in bitbake.conf instead of repeating ourselves?

Ross
<div dir="ltr">On 27 January 2018 at 07:06, Khem Raj <span dir="ltr">&lt;<a href="mailto:raj.khem@gmail.com" target="_blank">raj.khem@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Remove hardcoding c/c++ compiler to be gcc alone, its<br>
possible to use clang as replacement for cross compilers<br>
from meta-clang, therefore set clang/clang++ if<br>
TOOLCHAIN = &quot;clang&quot;<br>
<br>
Signed-off-by: Khem Raj &lt;<a href="mailto:raj.khem@gmail.com">raj.khem@gmail.com</a>&gt;<br>

---<br>
 meta/classes/meson.bbclass | 9 +++++++--<br>
 1 file changed, 7 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass<br>
index 91ac652651..cd3497a802 100644<br>
--- a/meta/classes/meson.bbclass<br>
+++ b/meta/classes/meson.bbclass<br>
@@ -40,6 +40,11 @@ EXTRA_OEMESON += &quot;${PACKAGECONFIG_CONFARGS}&quot;<br>
 MESON_CROSS_FILE = &quot;&quot;<br>
 MESON_CROSS_FILE_class-target = &quot;--cross-file ${WORKDIR}/meson.cross&quot;<br>
<br>
+CCOMPILER ?= &quot;gcc&quot;<br>
+CXXCOMPILER ?= &quot;g++&quot;<br>
+CCOMPILER_toolchain-clang = &quot;clang&quot;<br>
+CXXCOMPILER_toolchain-clang = &quot;clang++&quot;<br>
+<br></blockquote><div><br></div><div>Can we do this in bitbake.conf instead of repeating ourselves?</div><div><br></div><div>Ross </div></div></div></div>
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Khem Raj Jan. 29, 2018, 5:44 p.m. UTC | #2
On Mon, Jan 29, 2018 at 9:21 AM, Burton, Ross <ross.burton@intel.com> wrote:
> On 27 January 2018 at 07:06, Khem Raj <raj.khem@gmail.com> wrote:

>>

>> Remove hardcoding c/c++ compiler to be gcc alone, its

>> possible to use clang as replacement for cross compilers

>> from meta-clang, therefore set clang/clang++ if

>> TOOLCHAIN = "clang"

>>

>> Signed-off-by: Khem Raj <raj.khem@gmail.com>

>> ---

>>  meta/classes/meson.bbclass | 9 +++++++--

>>  1 file changed, 7 insertions(+), 2 deletions(-)

>>

>> diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass

>> index 91ac652651..cd3497a802 100644

>> --- a/meta/classes/meson.bbclass

>> +++ b/meta/classes/meson.bbclass

>> @@ -40,6 +40,11 @@ EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"

>>  MESON_CROSS_FILE = ""

>>  MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"

>>

>> +CCOMPILER ?= "gcc"

>> +CXXCOMPILER ?= "g++"

>> +CCOMPILER_toolchain-clang = "clang"

>> +CXXCOMPILER_toolchain-clang = "clang++"

>> +

>

>

> Can we do this in bitbake.conf instead of repeating ourselves?


having it in meson bbclass keeps it to meson based recipes,
bitbake.conf is a bit too generic.

>

> Ross

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Richard Purdie Jan. 29, 2018, 11:07 p.m. UTC | #3
On Mon, 2018-01-29 at 09:44 -0800, Khem Raj wrote:
> On Mon, Jan 29, 2018 at 9:21 AM, Burton, Ross <ross.burton@intel.com>
> wrote:
> > 
> > On 27 January 2018 at 07:06, Khem Raj <raj.khem@gmail.com> wrote:
> > > 
> > > 
> > > Remove hardcoding c/c++ compiler to be gcc alone, its
> > > possible to use clang as replacement for cross compilers
> > > from meta-clang, therefore set clang/clang++ if
> > > TOOLCHAIN = "clang"
> > > 
> > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > ---
> > >  meta/classes/meson.bbclass | 9 +++++++--
> > >  1 file changed, 7 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/meta/classes/meson.bbclass
> > > b/meta/classes/meson.bbclass
> > > index 91ac652651..cd3497a802 100644
> > > --- a/meta/classes/meson.bbclass
> > > +++ b/meta/classes/meson.bbclass
> > > @@ -40,6 +40,11 @@ EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
> > >  MESON_CROSS_FILE = ""
> > >  MESON_CROSS_FILE_class-target = "--cross-file
> > > ${WORKDIR}/meson.cross"
> > > 
> > > +CCOMPILER ?= "gcc"
> > > +CXXCOMPILER ?= "g++"
> > > +CCOMPILER_toolchain-clang = "clang"
> > > +CXXCOMPILER_toolchain-clang = "clang++"
> > > +
> > 
> > Can we do this in bitbake.conf instead of repeating ourselves?
> having it in meson bbclass keeps it to meson based recipes,
> bitbake.conf is a bit too generic.

Yes, I do worry a bit about namespace pollution from bitbake.conf
already...

Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index 91ac652651..cd3497a802 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -40,6 +40,11 @@  EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
 MESON_CROSS_FILE = ""
 MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"
 
+CCOMPILER ?= "gcc"
+CXXCOMPILER ?= "g++"
+CCOMPILER_toolchain-clang = "clang"
+CXXCOMPILER_toolchain-clang = "clang++"
+
 def meson_array(var, d):
     return "', '".join(d.getVar(var).split()).join(("'", "'"))
 
@@ -49,8 +54,8 @@  do_write_config() {
     # This needs to be Py to split the args into single-element lists
     cat >${WORKDIR}/meson.cross <<EOF
 [binaries]
-c = '${HOST_PREFIX}gcc'
-cpp = '${HOST_PREFIX}g++'
+c = '${HOST_PREFIX}${CCOMPILER}'
+cpp = '${HOST_PREFIX}${CXXCOMPILER}'
 ar = '${HOST_PREFIX}ar'
 ld = '${HOST_PREFIX}ld'
 strip = '${HOST_PREFIX}strip'