LFS
我想在CentOS v. 7.6.1810
没有权限的情况下进行交叉编译sudo
(我想在服务器上自定义我的环境)。一个问题是全球有很多软件包已经过时(例如,python
2.7、4.8.5、3.82 gcc
)gmake
。
在这个设置中,我从第 4 章开始,LFS
到处都PATH
从更改/tools
为/path/to/my/folder/tools
(我相信我做得足够准确)。直到第 5.7 章,一切都很顺利。首先,Glibc 想要更新的 python 和 gmake。因此我遵循了 5.27.1 和 5.30.1 章节。
在此之后,一切都编译得很好,我在健全性检查步骤中被阻止了。我从文件夹中执行它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
)都在那里。
我尝试提供文件的符号链接,它适用于其他文件,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
更新 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 的启发并尝试进行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
更新 2我再次重新安装了 LFS (8.1),但这次我遵循了本期中描述的步骤。此外,我使用此处-Xlinker --verbose
评论中描述的解决方案来检查 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 步骤是不好的。不幸的是,我没有办法解决这个问题,但我想尽可能升级我的本地环境。谢谢!