1

LFS我想在CentOS v. 7.6.1810没有权限的情况下进行交叉编译sudo(我想在服务器上自定义我的环境)。一个问题是全球有很多软件包已经过时(例如,python2.7、4.8.5、3.82 gccgmake

在这个设置中,我从第 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.ocrti.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 步骤是不好的。不幸的是,我没有办法解决这个问题,但我想尽可能升级我的本地环境。谢谢!

4

3 回答 3

2

我正在像你一样在不同的目录中编译 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;未设置起始地址

希望这可以帮助发现问题。

于 2019-08-11T00:03:02.530 回答
0

从 gcc 脚本中检查这一行中 glibc 的--with-glibc-version=2.11 \版本以及主机系统要求的版本。

于 2022-01-13T10:21:39.317 回答
0

此命令将为LD_LIBRARY_PATH整个 shell 更新:

export LD_LIBRARY_PATH=/path/to/my/folder/tools/lib

您只想为一个命令更新它。试试这个:

LD_LIBRARY_PATH=/path/to/my/folder/tools/lib $LFS_TGT-gcc dummy.c

更新:所以那没有用......试试这个怎么样?

$LFS_TGT-gcc -L/path/to/my/folder/tools/lib dummy.c
于 2019-07-26T17:10:45.533 回答