介子交叉编译问题;从Linux x86编译arm64 wayland;简单头文件失败



我正在尝试在linux x86主机系统上为arm64交叉编译wayland。Wayland使用一个名为meson的构建系统,这个构建系统在这种配置下不能正常工作。我已经创建了以下交叉文件。请注意,没有可用的exe包装器。

[binaries]
c = 'aarch64-linux-gnu-gcc'
cpp = 'aarch64-linux-gnu-g++'
ar = 'aarch64-linux-gnu-ar'
strip = 'aarch64-linux-gnu-strip'
[properties]
sizeof_int = 4
sizeof_wchar_t = 4
sizeof_void* = 4
alignment_char = 1
alignment_void* = 4
alignment_double = 4
has_function_printf = true
[host_machine]
system = 'linux'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

当试图调用介子时,会发生以下情况:

$ meson setup --cross-file meson_cross_compile.txt build-nxp
The Meson build system
Version: 0.45.1
Source dir: /disk1/linux/6.0.9/system/wayland
Build dir: /disk1/linux/6.0.9/system/wayland/build-nxp
Build type: cross build
meson.build:83:1: ERROR: lexer
{ 'header': 'sys/signalfd.h', 'symbol': 'SFD_CLOEXEC' },
^
A full log can be found at /disk1/linux/6.0.9/system/wayland/build-nxp/meson-logs/meson-log.txt

完整日志中没有其他可用信息。它只是重复已经打印的内容:

Build started at 2022-12-22T18:40:50.973895
Main binary: /usr/bin/python3
Python system: Linux
The Meson build system
Version: 0.45.1
Source dir: /disk1/linux/6.0.9/system/wayland
Build dir: /disk1/linux/6.0.9/system/wayland/build-nxp
Build type: cross build
meson.build:83:1: ERROR: lexer
{ 'header': 'sys/signalfd.h', 'symbol': 'SFD_CLOEXEC' },
^

这对我来说没有意义。查看/usr/aarch64-linux-gnu/include目录下的文件sys/signalfd.h,我们看到如下:

/* Copyright (C) 2007-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>.  */
#ifndef _SYS_SIGNALFD_H
#define _SYS_SIGNALFD_H 1
#include <stdint.h>
#include <bits/types/sigset_t.h>
/* Get the platform-dependent flags.  */
#include <bits/signalfd.h>
struct signalfd_siginfo
... (some more irrelevant stuff)

如果我们看一下上面包含的文件bits/signalfd.h,我们可以看到以下内容:

/* Copyright (C) 2007-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>.  */
#ifndef _SYS_SIGNALFD_H
# error "Never use <bits/signalfd.h> directly; include <sys/signalfd.h> instead."
#endif
/* Flags for signalfd.  */
enum
{
SFD_CLOEXEC = 02000000,
#define SFD_CLOEXEC SFD_CLOEXEC
SFD_NONBLOCK = 00004000
#define SFD_NONBLOCK SFD_NONBLOCK
};

所以SFD_CLOEXEC在这个文件中是明确定义的。虽然介子打印出的神秘错误信息对某些人来说可能意味着什么,但对我来说却无法理解。任何人谁是熟悉这个工具,请帮助我了解这里发生了什么,以及如何纠正这个问题?

谢谢你的帮助。

您的host_machine应该是'aarch64'和您的build_machine(不需要定义)是'x86_64'。仔细阅读文档:https://mesonbuild.com/Cross-compilation.html#

最新更新