mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.51k stars 1.6k forks source link

the cross compile always is False when do the cross compile #6790

Open fruitboy1226 opened 4 years ago

fruitboy1226 commented 4 years ago

when i do the cross compile, there always block the following errors:

uild started at 2020-03-18T10:22:04.611031
Main binary: /usr/bin/python3
Build Options: '--cross-file cross_config.txt'
Python system: Linux
The Meson build system
Version: 0.53.2
Source dir: /home/yishan.owen/workspace/camera/libcamera
Build dir: /home/yishan.owen/workspace/camera/libcamera/cross-build
Build type: cross build
Project name: libcamera
Project version: 0.0.0
Appending CFLAGS from environment: ' -O2 -pipe -g -feliminate-unused-debug-types '
Appending LDFLAGS from environment: ['-Wl,-O1', '-Wl,--hash-style=gnu', '-Wl,--as-needed']
No CPPFLAGS in the environment, not changing global flags.
Sanity testing C compiler: arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/yishan.owen/usr/lib/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi
Is cross compiler: False.
Sanity check compiler command line: arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/yishan.owen/usr/lib/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi /home/yishan.owen/workspace/camera/libcamera/cross-build/meson-private/sanitycheckc.c -o /home/yishan.owen/workspace/camera/libcamera/cross-build/meson-private/sanitycheckc.exe -O2 -pipe -g -feliminate-unused-debug-types -pipe -D_FILE_OFFSET_BITS=64 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command: /home/yishan.owen/workspace/camera/libcamera/cross-build/meson-private/sanitycheckc.exe

meson.build:1:0: ERROR: Could not invoke sanity test executable: [Errno 8] Exec format error.

my cross config file defined the following:

[binaries]
c = 'arm-poky-linux-gnueabi-gcc'
cpp = 'arm-poky-linux-gnueabi-g++'
ar = 'arm-poky-linux-gnueabi-ar'
strip = 'arm-poky-linux-gnueabi-strip'
pkgconfig = 'PKG_CONFIG_PATH=/home/yishan.owen/usr/lib/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/lib/pkgconfig'
exe_wrapper = 'wine'

[properties]
sys_root = '/home/yishan.owen/usr/lib/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi'
needs_exe_wrapper = true

sizeof_int = 4
sizeof_wchar_t = 2
sizeof_void* = 8

alignment_char = 1
alignment_void* = 4
alignment_double = 4

has_function_printf = true

c_args = ['-DCROSS=1', '-DSOMETHING=3']

[host_machine]
system = 'Linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'

[target_machine]
system = 'arm'
cpu_family = 'arm'
cpu = 'cortex-a7'
endian = 'little'

my compile cmd: "meson cross-build --cross-file cross_config.txt"

the meson version is 0.53.2.

Could you help to fix this issue? thanks so much.

phillipjohnston commented 4 years ago

You have two options:

  1. Specify the exe_wrapper in your binaries section which can execute a program for the target architecture (e.g., Qemu)
  2. In properties, set needs_exe_wrapper = true without setting an exe_wrapper to avoid the sanity check
phillipjohnston commented 4 years ago

(Sorry, now I see that you've specified wine as your exe_wrapper.)

dcbaker commented 4 years ago

I think your problem is that you've misconfigured your cross file. Unless you're building a cross compiler you don't want to set target_machine, just host_machine (which is the machine that the binaries will run on.

Try this cross file:

[binaries]
c = 'arm-poky-linux-gnueabi-gcc'
cpp = 'arm-poky-linux-gnueabi-g++'
ar = 'arm-poky-linux-gnueabi-ar'
strip = 'arm-poky-linux-gnueabi-strip'
pkgconfig = 'home/yishan.owen/usr/lib/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/lib/pkgconfig'
exe_wrapper = 'wine'

[properties]
sys_root = '/home/yishan.owen/usr/lib/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi'
needs_exe_wrapper = true

sizeof_int = 4
sizeof_wchar_t = 2
sizeof_void* = 8

alignment_char = 1
alignment_void* = 4
alignment_double = 4

has_function_printf = true

c_args = ['-DCROSS=1', '-DSOMETHING=3']

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'cortex-a7'
endian = 'little'
adrien-n commented 4 years ago

I've just had a problem that is possibly related. At least search engines thought so. :)

I was porting some code to run meson and my environment variables were not clean. That caused all kind of troubles and I also got confused because meson will check the sanity of both the native compiler and cross compiler without announcing it.

It could help to print some environment variables like CC and change "Sanity testing C compiler" with "Sanity testing native C compiler".