与较新的glibc的clang汇编为Sysroot

发布于 2025-01-24 18:11:47 字数 1841 浏览 2 评论 0原文

我正在尝试使用ubuntu 22.04的sysroot从ubuntu 20.04映像进行编译,而我遇到了很多麻烦,得到这样的链接器错误:

/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_symbind_alt@GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_preinit@GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_fatal_printf@GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__nptl_change_stack_perm@GLIBC_PRIVATE'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

使用完全相同的Ubuntu 22.04,使用完全相同的调用效果很好编译器和完全相同的系统。

这是我的设置:

// test.cpp
int main(){}

compile命令:

clang++ --sysroot ../build_rootfs/x86_64_jammy test.cpp

where ../ build_rootfs/x86_64_jammy是一个使用Multistrap创建的SYSRoot(如果相关,我可以共享最小的多式配置,但是考虑到同一Sysroot可以从Ubuntu 22.04,Ubuntu 22.04,,sysroot工作, Sysroot似乎不是

我尝试的问题:

  • 使用
  • clang 14,无论是从apt.llvm.org而言,都可以使用clang 14,而从二进制中

,GCC可以通过通过来编译它。 l/usr/lib/x86_64-linux-gnu/9 -l/usr/lib/x86_64-linux-gnu(即使使用-sysroot),但是这是 因为这链接到主机系统上的库。

似乎很奇怪, ,但是我看不到主机GLIBC版本在从SYSROOT中编译时将如何重要,而且似乎没有任何链接器输入来自主机系统,所以出了什么问题?

这个景点这个景点 具有Clang on Clang on clang on clang on clang on clang of clang on gopal of copal of cpal of clang in focal of clang和clang of clang和clang of clang和clang j of clang of clang in j of clang in 。

I'm trying to compile with a sysroot for Ubuntu 22.04 from a Ubuntu 20.04 image, and I'm having quite a bit of trouble, getting linker errors like these:

/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_symbind_alt@GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_preinit@GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_fatal_printf@GLIBC_PRIVATE'
/usr/bin/ld: ../build_rootfs/x86_64_jammy/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__nptl_change_stack_perm@GLIBC_PRIVATE'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The exact same invocation works fine from a Ubuntu 22.04, using the exact same compiler and exact same sysroot.

Here's my setup:

// test.cpp
int main(){}

Compile command:

clang++ --sysroot ../build_rootfs/x86_64_jammy test.cpp

Where ../build_rootfs/x86_64_jammy is a sysroot created with multistrap (I can share a minimized multistrap config if it's relevant, but considering the same sysroot works fine from Ubuntu 22.04, the sysroot seems to not be the issue.

Things I have tried:

  • Using lld--same result
  • Using clang 14, both from apt.llvm.org and from the binary tarball

Notably, GCC is able to compile it by passing -L/usr/lib/x86_64-linux-gnu/9 -L/usr/lib/x86_64-linux-gnu (yes, even when compiling with --sysroot), but this seems strange as this is linking to libraries on the host system. Adding these flags does let the compilation succeed, but compiling from clang on 22.04 works fine without loading any of the system libraries (allegedly).

I assume this is an issue with glibc verisons, but I can't see how the host glibc version would matter when compiling from a sysroot, and it doesn't seem like any of the linker inputs are actually from the host system, so what's going wrong?

This gist has the verbose logs from clang on focal, gcc on focal, and clang on jammy for reference.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

め可乐爱微笑 2025-01-31 18:11:47

终于找到了我做错了什么 - $ rootfs/lib64/ld-linux-x86-64.so.2/lib/x86_64-linux-linux-gnu/ld-2.31的符号链接。

Finally found what I did wrong--$rootfs/lib64/ld-linux-x86-64.so.2 was a symlink to /lib/x86_64-linux-gnu/ld-2.31.so, so fixing it to be a relative instead of absolute symlink fixed it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文