【问题标题】:Errors about asm for a gcc build on macos关于在 macos 上构建 gcc 的 asm 错误
【发布时间】:2022-06-25 16:07:41
【问题描述】:

我曾经在 windows 上构建一个项目,现在我试图在 macos (M1) 上构建它,但在依赖项(嵌套在依赖项中)时出现错误:

pixman-0.34.0/pixman/pixman-x86.c:103:4: error: unknown register name '%eax' in asm
        : "%eax", "%ecx");
          ^
pixman-0.34.0/pixman/pixman-x86.c:136:4: error: invalid output constraint '=a' in asm
        : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d)
          ^

我也收到了警告:

pixman-0.34.0/pixman/pixman-x86.c:83:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if _PIXMAN_X86_64 || defined (_MSC_VER) || defined(__native_client__)
    ^
pixman-0.34.0/pixman/pixman-x86.c:78:6: note: expanded from macro '_PIXMAN_X86_64'
    (defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64))
     ^

项目是用CMake配置的,参数很少,大部分配置都是在依赖(Orthanc)的CMake中进行的。
有一个几乎相同的源代码和库的 emscripten 版本运行良好,所以我想我在 CMake 配置中遗漏了一些东西以使其在 macos 上运行。
我想目标架构与 pixman lib 不兼容(可能还有其他编译尚未达到)。但我没有找到解决方法。

我使用自制软件安装了 gcc

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc-11
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/11.3.0/bin/../libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper
Target: aarch64-apple-darwin21
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.3.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --build=aarch64-apple-darwin21 --with-system-zlib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.3.0)

【问题讨论】:

  • 这是 x86 程序集(eax 是 x86 寄存器),但您的编译器针对的是 ARM(aarch64-apple-darwin21)。
  • @AlexReinking 是否意味着如果不以某种方式设置交叉编译,就无法在我的 ARM 系统上构建 lib 代码?
  • 正确。您将需要交叉编译。
  • 如果最终结果应该在您的 M1 mac 上运行,交叉编译将无济于事。您将需要使用 Arm 汇编(或者更好的是纯 C)重写内联装配线。
  • 我只注意到文件名是“pixman-x86.c”。也许您根本不应该构建该文件,检查是否有“pixman-arm.c”或类似文件。

标签: macos gcc cmake cairo pixman


【解决方案1】:

项目是用CMake配置的,参数很少,大部分配置都是在依赖(Orthanc)的CMake中进行的。

thisOrthanc吗?他们究竟是如何使用 CMake 构建 pixman 的? Pixman 在 Assembler 中实现了许多特殊情况。在构建时,autoconf 会检测到要启用的正确选项。既然你写的是你正在使用 CMake,我敢打赌有人回避了所有的自动检测,只是硬编码了要构建的内容。并对 x86 构建进行硬编码。

如果这个猜测是正确的,那么这是该 CMake 文件中的一个错误,除了 orthanc 开发人员之外没有任何人可以解决这个问题。

您要准确构建 orthanc 的哪个部分以及如何构建?我找不到它对 cairo 的使用...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多