About Meson, Cross File and STM32

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

[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.

Upvotes: 1

Views: 1993

Answers (1)

pmod
pmod

Reputation: 11007

As far as I see you have in output log:

Build type: native build

however, you should have:

Build type: cross build

So, check how the build is configured, you should set cross file to setup build directory which you then use for building:

$ meson build/ --cross-file cross_file.build
$ ninja -C build/

Upvotes: 2

Related Questions