0

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!

0

If you follow book step by step, there is no way LFS would not work. But if you skip steps, reshuffle things etc - you are on your own, because GNU Linux is too complicated beast even in this lightweight version.

So - follow the book, book is good. If you get errors - re-read the book, go back, check everything.

You wrote that you had to do out of order Python and gmake compilation. Why? If your host system does not meet LFS requirements - it will not work. So - does your host have Python 3.4 as per http://www.linuxfromscratch.org/lfs/view/stable/chapter02/hostreqs.html? Did you executed version-check.sh script? Did you check all versions it printed against the ones given in the book?

EDIT: When some packages like Python or gmake are too old on your host system and you can't change it, you can try compiling and installing them from sources locally, for your user only. You have to set prefix during configuration:

./configure --prefix=$HOME

And then you have to make some tweaks - add $HOME/bin to your PATH etc.

  • Yes, my host system does not have the system requirements. gmake v. 3.82 and python only 2.7. Unfrotunately, there is no way these packages can be upgraded globally. Maybe, I should try older LFS versions or some analogs to have an upgraded local environment? – gregoruar Jul 26 at 8:18
  • @gregoruar For older LFS version it's hard to package sources, so I wouldn't count on that. But you can compile/install old packages locally, in your home directory, please see my updated answer. – rsm Jul 26 at 17:01
  • Thank you. I decided to reformulate the question, as I have tried installing older version of LFS. – gregoruar Jul 30 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.