Skip to contentSkip to conversation

meson: Adjust for clang compiler

PATCH In review Khem Raj 3 participants 4 messages Jan 27, 2018 – Jan 29, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 meson: Adjust for clang compiler

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"

---
 meta/classes/meson.bbclass | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/classes/meson.bbclass +7 -2
index 91ac652651..cd3497a802 100644
@@ -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'
Signature · 1 line
2.16.1
#1 lore raw
Quoted 15 lines · Khem Raj

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"

---
 meta/classes/meson.bbclass | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/classes/meson.bbclass +0 -0
index 91ac652651..cd3497a802 100644

meta/classes/meson.bbclass EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}" · line 48

Quoted 9 lines
meta/classes/meson.bbclass +5 -0
@@ -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

author
#2 lore raw
Quoted 20 lines · Ross
Quoted 19 lines · Khem Raj

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"

---
 meta/classes/meson.bbclass | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/classes/meson.bbclass +0 -0
index 91ac652651..cd3497a802 100644
@@ -40,6 +40,11 @@ EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
 MESON_CROSS_FILE = ""
 MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"
 
Quoted 8 lines

meta/classes/meson.bbclass EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}" · line 47

Quoted 5 lines
meta/classes/meson.bbclass +5 -0
+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.

Quoted 2 lines

Ross

#3 lore raw
Quoted 33 lines · Khem Raj
Quoted 24 lines · Ross
Quoted 22 lines · Khem Raj

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"

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

 1 file changed, 7 insertions(+), 2 deletions(-)
meta/classes/meson.bbclass +0 -0
index 91ac652651..cd3497a802 100644
@@ -40,6 +40,11 @@ EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"

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

Quoted 7 lines

meta/classes/meson.bbclass EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}" · line 47

Quoted 5 lines
meta/classes/meson.bbclass +5 -0
+CCOMPILER ?= "gcc"
+CXXCOMPILER ?= "g++"
+CCOMPILER_toolchain-clang = "clang"
+CXXCOMPILER_toolchain-clang = "clang++"
+

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

Quoted 2 lines

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