1

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. 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

UPDATE 1 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 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

UPDATE 2 I once again reinstalled LFS (8.1), but this time I followed steps described in this issue. Also, I used -Xlinker --verbose solution described in the comments here to inspect ld logs. Now it seems, that maybe it cannot open the mentioned libraries. Still not working, but log seems to have changed a bit.

> 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

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!

3 Answers 3

2

I'm on a path of compiling LFS in a different directory just like you. I followed the same steps as you have. And have gotten the exact same results.

But I think I have one hint, you haven't mentioned:

/path/to/my/folder/tools/bin/x86_64-lfs-linux-gnu-ld /path/to/my/folder/tools/lib/libc.so.6

Gives warning:

x86_64-lfs-linux-gnu-ld: warning: cannot find entry symbol _start; not setting start address

Hope this can help uncover the problem.

1
  • Thank you for the fact that I am not alone here:) After Update 2 it seems libc.so.6 is not needed, and it even was not isnstalled, when I was bulding glibc. Now, I provided symbolic links to crtn.o crt1.o and crti.o at the root of my folder, and only cannot find -lc error stays. People say that in this case libc.a library is absent. In a while, I will rewrite my post.
    – gregoruar
    Aug 14, 2019 at 10:44
0

This command will update LD_LIBRARY_PATH for the entire shell:

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

you only want it updated for the one command. Try this instead:

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

Update: So that didn't work... how about trying this?

$LFS_TGT-gcc -L/path/to/my/folder/tools/lib dummy.c
3
  • Thank you! I tried what you proposed, but the same fatal error arises: Segmentation fault (core dumped) Now I am at loss what to do(
    – gregoruar
    Jul 30, 2019 at 13:02
  • I tried your second suggestion, but it did not work either. I did some homework on my own, please, see the UPDATE 2
    – gregoruar
    Jul 31, 2019 at 10:52
  • @gregoruar, sorry I'm about out of ideas. Maybe someone else can help.
    – Tim
    Jul 31, 2019 at 16:36
0

check version of glibc in this line --with-glibc-version=2.11 \ from gcc script with version of host system requirements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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