【问题标题】:cross compiling libc for x86_64-linux-android为 x86_64-linux-android 交叉编译 libc
【发布时间】:2021-04-11 16:08:37
【问题描述】:

我正在交叉编译(使用 x86_64-linux-android-gcc)为 x86_64-linux-android 构建 GNU libc,GLIBC 版本 2.32。从 strtod_l.c 的编译中获取错误“__asm 中的操作数约束不一致”。在 strtod_l.c 中,有一个函数 round_and_return(),它调用宏 math_force_eval(force_underflow)。这个宏在“math-barriers.h”中定义,错误发生在这一行:

    __asm __volatile ("" : : "f" (x));

这促使我尝试发现 force_underflow 的值是什么:
尝试将这些行添加到 strtod_l.c 并得到这些错误:
printf(“force_underflow=%f\n”,force_underflow);
错误:%f 是 double 类型,force_underflow 是 long double 类型

试过:
printf(“force_underflow=%lf\n”,force_underflow);
错误:%lf 是 double 类型,force_underflow 是 long double 类型

试过:
printf(“force_underflow=%Lf\n”,force_underflow);
错误:%Lf 是 long double 类型,force_underflow 是 double 类型

这让我想到了我的第一个问题:变量“force_underflow”如何既是“double”类型又是“long double”类型?代码行中有什么东西吗:

   __asm __volatile("" : : "f" (x));

可以更改以满足编译器的要求吗?感谢您的任何/所有建议!

问候, 史蒂夫

【问题讨论】:

    标签: c compilation libc


    【解决方案1】:

    x86_64-linux-android-gcc 不是编译 glibc 的合适编译器;它针对x86_64-linux-android ABI,而不是x86_64-linux-gnu ABI。为了编译 glibc,您需要一个 linux-gnu 定位工具链。

    我没有事先了解前 ABI 的细节,但从错误消息中,听起来 x86 Android 没有明显的 long double 表示,但将其定义为与 double 相同的东西.但这只是使用错误目标编译器可能导致的多种破坏形式之一。其他破损甚至可能是无声的。您只需要为您的目标构建正确的交叉工具链。

    【讨论】:

    • 感谢您提供的重要信息。我构建了 x86_64-linux-android 交叉编译器,因为我的目标平台是 Google Pixel,用于一些需要 libpthread.a(来自 GNU libc)的软件。我现在必须重新考虑......
    猜你喜欢
    • 2022-10-06
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-20
    • 2017-03-18
    • 1970-01-01
    相关资源
    最近更新 更多