我想在没有 sudo
权限的情况下在 CentOS v. 7.6.1810
上交叉编译 LFS
(我想在服务器)。一个问题是全局范围内有很多包已过时(例如,python
2.7、gcc
4.8.5、gmake
3.82)。
在此设置中,我从 LFS
的第 4 章开始,将 PATH
从 /tools
更改为 /path/to/my/folder/tools
(我相信我做得足够准确)。一切顺利,直到第 5.7 章。首先,Glibc 想要更新的 python 和 gmake。
因此,我遵循了 5.27.1 和 5.30.1 章节。
在此之后,一切都编译良好,我在 the sanity check step 上停止了.我从 sources/glibc/build
文件夹中执行它,并得到一个错误:
> echo 'int main(){}' > dummy.c
> $LFS_TGT-gcc dummy.c
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc.so.6 inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc_nonshared.a inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/ld-linux-x86-64.so.2 inside /path/to/my/folder
collect2: error: ld returned 1 exit status
我检查了/path/to/my/folder/tools/lib/
,所有想要的文件(crt1.o
,crti.o
、libc.so.6
、libc_nonshared.a
、ld-linux-x86-64.so.2
)都在那里。
我尝试提供文件的符号链接(symbolic link),它适用于 crt1.o
和 crti.o
但不适用于其他文件。
> ln -s /path/to/my/folder/tools/lib/crt1.o crt1.o
> ln -s /path/to/my/folder/tools/lib/crti.o crti.o
> ln -s /path/to/my/folder/tools/lib/libc_nonshared.a libc_nonshared.a
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc.so.6 inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc_nonshared.a inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/ld-linux-x86-64.so.2 inside /path/to/my/folder
collect2: error: ld returned 1 exit status
UPDATE 1 现在我重新安装了旧版本 LFS (8.1)
,这样一开始我就满足了所有先决条件。我再次从第 4 章开始,直到臭名昭著的检查才出现错误。 Tim 的建议对系统没有被破坏的方式很有帮助,但是段错误不允许创建 a.out:
> echo 'int main(){}' > dummy.c
> LD_LIBRARY_PATH=/path/to/my/folder/tools/lib $LFS_TGT-gcc dummy.c
Segmentation fault (core dumped)
> readelf -l a.out | grep ': /path/to/my/folder/tools'
readelf: a.out: Error: No such file
受到类似问题的启发LFS 7.2 glibc-2.16.0 make error并尝试相应地更改 LD_LIBRARY_PATH
。它似乎不起作用。
> echo 'int main(){}' > dummy.c
> LD_LIBRARY_PATH=/path/to/my/folder/tools/libgcc/x86_64-lfs-linux-gnu/7.2.0 $LFS_TGT-gcc dummy.c
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc.so.6 inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc_nonshared.a inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/ld-linux-x86-64.so.2 inside /path/to/my/folder
collect2: error: ld returned 1 exit status
> readelf -l a.out | grep ': /path/to/my/folder/tools'
readelf: a.out: Error: No such file
UPDATE 2 我再次重新安装了 LFS (8.1),但这次我遵循了本 issue 中描述的步骤。 .另外,我使用了评论中描述的 -Xlinker --verbose
解决方案 here检查 ld 日志。现在看来,也许它无法打开提到的库。仍然无法正常工作,但日志似乎发生了一些变化。
> LFS_TGT-gcc -Xlinker --verbose dummy.c
==================================================
attempt to open crt1.o failed
attempt to open crti.o failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtbegin.o succeeded
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtbegin.o
attempt to open /tmp/ccRQA7iH.o succeeded
/tmp/ccRQA7iH.o
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.a succeeded
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libc.a failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/../lib/libc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/../lib/libc.a failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/libc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/libc.a failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib64/libc.so failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib64/libc.a failed
attempt to open /path/to/my/folder/tools/lib/libc.so failed
attempt to open /path/to/my/folder/tools/lib/libc.a failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib/libc.so failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib/libc.a failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.a succeeded
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtend.o succeeded
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtend.o
attempt to open crtn.o failed
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find -lc
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
你能给个建议吗,如何处理这个讨厌的 ld
问题。我知道跳过 LFS 步骤是不好的。不幸的是,我没有办法解决这个问题,但我想尽可能地升级我的本地环境。谢谢!
最佳答案
我正在和您一样在不同的目录中编译 LFS。 我遵循了与您相同的步骤。并且得到了完全相同的结果。
但我想我有一个提示,你没有提到:
/path/to/my/folder/tools/bin/x86_64-lfs-linux-gnu-ld /path/to/my/folder/tools/lib/libc.so.6
给出警告:
x86_64-lfs-linux-gnu-ld:警告:找不到入口符号 _start;没有设置起始地址
希望这可以帮助发现问题。
关于c - LFS 5.7.Glibc-2.29 的完整性检查失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57218729/