Repository: mesonbuild/meson

Issue:
WARNING: Unknown CPU family 'sparc', please report this
Using meson/ninja for Buildroot [1] builds, e.g. with the provides sparc toolchain [2].

[1] https://buildroot.org/
[2] http://autobuild.buildroot.org/toolchains/tarballs/br-sparc-uclibc-2017.11-rc1.tar.bz2


Discussion:
Are there different sparc CPU identifiers? Something like separate ones for 32 and 64 bits?
Yes, sparc64 for the 64 bit variant (already recognized by meson, tested with 0.47.1), see [1] for a complete toolchain list used by Buildroot autobuilders...

[1] http://autobuild.buildroot.org/toolchains/tarballs/
This is while doing a native build on 32-bit sparc and not a cross-compile? Could you please paste the output of `uname -a` and `cat /proc/cpuinfo` as requested by the warning?

AFAIK `sparc64` is the 64-bit SPARC V9 CPU, but which CPUs are covered under `sparc`?
```
While doing a Cross-Compile (using Buildroot on x86_64 Linux):

        $ .../host/bin/meson --prefix=/usr --libdir=lib --default-library=shared --buildtype=plain --cross-file=.../build/libdrm-2.4.92//build/cross-compilation.conf -Dcairo-tests=false -Dmanpages=false -Dintel=false -Dradeon=true -Damdgpu=true -Dnouveau=true -Dvmwgfx=false -Domap=false -Detnaviv=true -Dexynos=false -Dfreedreno=false -Dtegra=false -Dvc4=false -Dudev=true -Dvalgrind=false -Dinstall-test-programs=true .../build/libdrm-2.4.92/ .../build/libdrm-2.4.92//build

WARNING: Unknown CPU family 'sparc', please report this at https://github.com/mesonbuild/meson/issues/new
The Meson build system
Version: 0.47.1
Source dir: .../build/libdrm-2.4.92
Build dir: .../build/libdrm-2.4.92/build
Build type: cross build
WARNING: Unknown options: "manpages"
Project name: libdrm
Project version: 2.4.92
Native C compiler: cc (gcc 8.1.1 "cc (SUSE Linux) 8.1.1 20180614 [gcc-8-branch revision 261584]")
Cross C compiler: .../host/bin/sparc-linux-gcc (gcc 6.4.0)
Host machine cpu family: sparc
Host machine cpu: v8
Target machine cpu family: sparc
Target machine cpu: v8
Build machine cpu family: x86_64
Build machine cpu: x86_64

        $ cat .../build/libdrm-2.4.92/build/cross-compilation.conf 
# Note: Buildroot's and Meson's terminologies differ about the meaning
# of 'build', 'host' and 'target':
# - Buildroot's 'host' is Meson's 'build'
# - Buildroot's 'target' is Meson's 'host'

[binaries]
c = '.../host/bin/sparc-linux-gcc'
cpp = '.../host/bin/sparc-linux-g++'
ar = '.../host/bin/sparc-linux-ar'
strip = '.../host/bin/sparc-linux-strip'
pkgconfig = '.../host/usr/bin/pkg-config'

[properties]
c_args = ["-D_LARGEFILE_SOURCE", "-D_LARGEFILE64_SOURCE", "-D_FILE_OFFSET_BITS=64", "-Os", "-g2",  "-DAO_NO_SPARC_V9",]
c_link_args = [ ]
cpp_args = ["-D_LARGEFILE_SOURCE", "-D_LARGEFILE64_SOURCE", "-D_FILE_OFFSET_BITS=64", "-Os", "-g2",  ]
cpp_link_args = [ ]

[host_machine]
system = 'linux'
cpu_family ='sparc'
cpu = 'v8'
endian = 'big'

For the sparc/sparc64 cpu family see [1].

[1] https://en.wikipedia.org/wiki/SPARC
```
Regardless of anything else, you should not have `-Os` and `-g` in the cross file. Instead you should choose the appropriate build type and get that automatically.

Resolving patch:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -86,6 +86,7 @@
     'ppc64',
     'riscv32',
     'riscv64',
+    'sparc',
     'sparc64',
     'x86',
     'x86_64'


Test patch: