Repository: mesonbuild/meson

Issue:
Can't detect host machine.
I have some issue about cross compile STM32 with meson. I'm new to meson and try to compile STM32 code with it. I found this repository https://github.com/hwengineer/STM32F3Discovery-meson-example and try to change it what i need it.

My cross file is like

```ini
[binaries]
c       = 'arm-none-eabi-gcc'
cpp     = 'arm-none-eabi-g++'
ld      = 'arm-none-eabi-ld'
ar      = 'arm-none-eabi-ar'
as      = 'arm-none-eabi-as'
size    = 'arm-none-eabi-size'
objdump = 'arm-none-eabi-objdump'
objcopy = 'arm-none-eabi-objcopy'
strip   = 'arm-none-eabi-strip'
gdb     = 'arm-none-eabi-gdb'
terminal= 'x-terminal-emulator'
openocd = '/usr/local/bin/openocd'

exe_wrapper = 'meson_exe_wrapper.sh'

[properties]
c_args      = [
               '-mthumb',                   # define language
               #------------------------------------
               '-fshort-enums',             # otherwise errors at linking...
               '-fmessage-length=0',        # all error warnings in a single line (default 72)
               '-fsigned-char',             # char is per default unsigned
               '-ffunction-sections',       # each function to a seperate section ==> Code-optimization / deletion
               '-fdata-sections',           # each variable to a seperate section ==> Code-optimization / deletion

              '-Wall',
               '-ffreestanding',
               #------------------------------------
               # '-flto',
               ]

c_link_args = [
                '-nostdlib',             # do not import the standard library's
               # '-flto',
              ]

[host_machine]
system     = 'none'
cpu_family = 'arm'
cpu        = 'cortex-m3'
endian     = 'little'
```
but when i try to compile meson gives this

Build type: native build
Project name: thermometer_with_meson
Project version: undefined
C compiler for the host machine: cc (gcc 10.2.0 "cc (GCC) 10.2.0")
C linker for the host machine: cc ld.bfd 2.35
Host machine cpu family: x86_64
Host machine cpu: x86_64
host machine should be arm cortex-m3 but it seems there is a mistake.

Why meson ignores cross file? and why host machine x86-64?

BTW it gives error like this couse x86_64 should be x86-64.


Discussion:
what is the command line you're using for invoking meson? it should be something like:

`meson setup builddir --cross-file=path-to-my-host-file`

Also, you probably don't want to put `-Wall` and `-flto` in your cross file, meson has `-Db_lto` for lto, and `-Dwarning_level` that can be used to set basic -Wall, -Wextra, etc.
I use 

meson setup build --cross-file=arm.cross

for invoke meson.
hmmm, when I try your cross file it gets as far as I expect (I don't have a toolchain for bare metal arm), but it ends up with:
```terminal
dylan@machine:~/source/libpciaccess% meson setup build --cross-file=cross.cross                                                                                                                                                                                  
The Meson build system
Version: 0.55.3
Source dir: /home/dylan/source/libpciaccess
Build dir: /home/dylan/source/libpciaccess/build
Build type: cross build
Project name: libpciaccess
Project version: 0.16
C compiler for the build machine: ccache cc (gcc 9.3.0 "cc (Gentoo 9.3.0-r1 p3) 9.3.0")
C linker for the build machine: cc ld.bfd 2.34

meson.build:21:0: ERROR: Unknown compiler(s): [['arm-none-eabi-gcc']]
The follow exceptions were encountered:
Running "arm-none-eabi-gcc --version" gave "[Errno 2] No such file or directory: 'arm-none-eabi-gcc'"
```

Note that there are "build compilers", since you're not getting build compilers It's not setting up a cross compile at all.
How can i change build-type?
as in `debug` vs `release`? `-Dbuildtype=<yourbuildtype>`

Resolving patch:
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -181,7 +181,7 @@ def _generate(self, env: environment.Environment) -> None:
         else:
             logger_fun = mlog.debug
         build_machine = intr.builtin['build_machine']
-        host_machine = intr.builtin['build_machine']
+        host_machine = intr.builtin['host_machine']
         target_machine = intr.builtin['target_machine']
         assert isinstance(build_machine, interpreter.MachineHolder)
         assert isinstance(host_machine, interpreter.MachineHolder)


Test patch: