I want to cross-compile LFS on CentOS v. 7.6.1810 with no sudo rights (I want to customize my environment on server). One problem is that globally a lot of packages are outdated (for instance, python
2.7, gcc
4.8.5, gmake
3.82).
In this setting I started from the 4-th chapter of LFS and changed everywhere PATH from /tools to /path/to/my/folder/tools (I believe I did it accurately enough). It all went well until chapter 5.7. First, Glibc wanted to have newer python and gmake. Therefore I followed 5.27.1 and 5.30.1 chapters.
After this, everything compiles well, and I was stopped on the sanity check step (http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html). I executed it from the sources/glibc/build folder, and got an error:
> 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
I checked /path/to/my/folder/tools/lib/, and all wanted files (crt1.o, crti.o, libc.so.6, libc_nonshared.a, ld-linux-x86-64.so.2) are there.
I tried providing symbolic links to files and it worked for crt1.o and crti.o but not for the others.
> 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
I tried changing LD_LIBRARY_PATH
.However, doing so rises weird segmantation errors, when calling ls
, cat
and other tools. Making LD_LIBRARY_PATH=''
helps return things back.
> export LD_LIBRARY_PATH=/path/to/my/folder/tools/lib
> ls
Segmentation fault (core dumped)
> export LD_LIBRARY_PATH=/path/to/my/folder/tools/lib64
> ls
Segmentation fault (core dumped)
> export LD_LIBRARY_PATH=''
> ls
...Dispalays content of the directory...
UPDATE: Now I reinstalled older version LFS (8.1), so that I had all prerequisites fulfilled from the start. Once again I started from the 4-th chapter and no errors rose until the notorious check. The suggestion from Tim was helpful in the way the system was not ruined, but segmentation error did not allow a.out to be created:
> 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
Inspired by the similar issue https://stackoverflow.com/questions/15928925/lfs-7-2-glibc-2-16-0-make-error and tried to change LD_LIBRARY_PATH
accordingly. It does not seem to work.
> 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
Can you please give a suggestion, how to deal with this nasty ld
problem. I know that it is not good to skip LFS steps. Unfortunately, I have no way to fix this, but I want to upgrade my local environment as much as possible. Thank you!