Discussion:
[lfs-support] Error Compiling GCC pass 2
Keith Howard
2016-04-11 13:46:23 UTC
Permalink
Greetings!

I am using Knoppix 7, 2016 version as a host system.
I am following the LFS-systemd 7.9 book.
I have an AMD Athlon X2 system with 1GB of RAM.

I will put commands that I typed into the console, or info I received from
the console in single quotes; for example, 'ls -al'

I am receiving an error compiling GCC, pass 2
I simply run 'make', no options, no optimizations.

I am getting an error from 'ld' trying to load 'liblto_plugin.so'.
The error was 'wrong ELF class: ELFCLASS64'

Here is snippet from my console:

/bin/sh ../../../libgcc/../mkinstalldirs .
/mnt/lfs/sources/gcc-5.3.0/build/./gcc/xgcc
-B/mnt/lfs/sources/gcc-5.3.0/build/./gcc/
-B/tools/x86_64-unknown-linux-gnu/bin/
-B/tools/x86_64-unknown-linux-gnu/lib/ -isystem
/tools/x86_64-unknown-linux-gnu/include -isystem
/tools/x86_64-unknown-linux-gnu/sys-include -O2 -g -O2 -DIN_GCC -W
-Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition -isystem ./include -fpic
-mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector
-shared -nodefaultlibs -Wl,--soname=libgcc_s.so.1
-Wl,--version-script=libgcc.map -o ./libgcc_s.so.1.tmp -g -O2 -B./
_muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o _cmpdi2_s.o
_ucmpdi2_s.o _clear_cache_s.o _trampoline_s.o __main_s.o _absvsi2_s.o
_absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o
_mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o _ffssi2_s.o
_ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o _ctzsi2_s.o _ctzdi2_s.o
_popcount_tab_s.o _popcountsi2_s.o _popcountdi2_s.o _paritysi2_s.o
_paritydi2_s.o _powisf2_s.o _powidf2_s.o _powixf2_s.o _mulsc3_s.o
_muldc3_s.o _mulxc3_s.o _divsc3_s.o _divdc3_s.o _divxc3_s.o _bswapsi2_s.o
_bswapdi2_s.o _clrsbsi2_s.o _clrsbdi2_s.o _fixunssfsi_s.o _fixunsdfsi_s.o
_fixunsxfsi_s.o _fixsfdi_s.o _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o
_fixunsdfdi_s.o _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o
_floatdixf_s.o _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o
_divdi3_s.o _moddi3_s.o _udivdi3_s.o _umoddi3_s.o _udiv_w_sdiv_s.o
_udivmoddi4_s.o cpuinfo_s.o sfp-exceptions_s.o addtf3_s.o divtf3_s.o
multf3_s.o negtf2_s.o subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o
floatsitf_s.o floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o
floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o floatuntitf_s.o
extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o trunctfsf2_s.o
trunctfdf2_s.o trunctfxf2_s.o getf2_s.o letf2_s.o eqtf2_s.o _divtc3_s.o
_multc3_s.o _powitf2_s.o enable-execute-stack_s.o unwind-dw2_s.o
unwind-dw2-fde-dip_s.o unwind-sjlj_s.o unwind-c_s.o emutls_s.o libgcc.a -lc
&& rm -f ./libgcc_s.so && if [ -f ./libgcc_s.so.1 ]; then mv -f
./libgcc_s.so.1 ./libgcc_s.so.1.backup; else true; fi && mv
./libgcc_s.so.1.tmp ./libgcc_s.so.1 && ln -s libgcc_s.so.1 ./libgcc_s.so
/mnt/lfs/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/5.3.0/../../../../x86_64-lfs-linux-gnu/bin/ld:
/mnt/lfs/sources/gcc-5.3.0/build/./gcc/liblto_plugin.so: error loading
plugin: /mnt/lfs/sources/gcc-5.3.0/build/./gcc/liblto_plugin.so: wrong ELF
class: ELFCLASS64
collect2: error: ld returned 1 exit status
Makefile:947: recipe for target 'libgcc_s.so' failed
make[2]: *** [libgcc_s.so] Error 1
make[2]: Leaving directory
'/mnt/lfs/sources/gcc-5.3.0/build/x86_64-unknown-linux-gnu/libgcc'
Makefile:13653: recipe for target 'all-target-libgcc' failed
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory '/mnt/lfs/sources/gcc-5.3.0/build'
Makefile:880: recipe for target 'all' failed
make: *** [all] Error 2

'file -L liblto_plugin.so' indeed, shows that is a 64 bit binary....but I
thought we were compiling for $LFS_TGT, which is 'x86_64-lfs-linux-gnu'
Some Googling for similar problems seems to indicate that something was
possibly compiled 32bit...(?)
I don't know what to do to correct the problem (mostly because I don't know
what the problem is).
I could sure use some guidance, here.

Thanks in advance!
Ken Moffat
2016-04-12 15:11:01 UTC
Permalink
Post by Keith Howard
Greetings!
I am using Knoppix 7, 2016 version as a host system.
I am following the LFS-systemd 7.9 book.
I have an AMD Athlon X2 system with 1GB of RAM.
'file -L liblto_plugin.so' indeed, shows that is a 64 bit binary....but
I thought we were compiling for $LFS_TGT, which is
'x86_64-lfs-linux-gnu'
Hi Keith,
I'm just writing you because nobody has so far - and I'm really a newbie
when it comes to 32/64-bit CPU's, dists and compiling.
Is your CPU a 64-Bit?
x86_64-lfs-linux-gnu means 64-Bit (and most of the time it just says
x86_64-unknown-linux)
Both host CPU and Dist has to be 64-Bit in order to compile a 64-Bit LFS
System.
Best Regards
Michael
Michael, thanks for prompting me to take another look at this (I
don't touch systemd, was not sure if perhaps the build was
different - but this early on, there is not much that can differ).

Keith -

What does 'file' say about the programs you have compiled so far ?
It should say they are all ELF 64-bit, but at least one of them is
not. Looking at my (sysvinit) logs, the following seem worth
exploring:

/tools/bin/x86_64-lfs-linux-gnu-ld (binutils pass 1)
/tools/bin/x86_64-lfs-linux-gnu-gcc (gcc pass 1)
/tools/lib/ld-linux-x86-64.so.2 (glibc)
/tools/lib/libstdc++.so.6.0.21 (libstdc++)
/tools/bin/strings (binutils pass 2)

ĸen
--
This email was written using 100% recycled letters.
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http://en.wikipedia.org/wiki/Posti
Keith Howard
2016-04-12 15:11:35 UTC
Permalink
Michael,

Thanks for the response!
I'm new to this style of communication (mail list posting) so, I hope this
finds you!

Yes, my system is 64 bit.

It is older (about 8 years old....or a little more...), but it is an AMD X2
64 bit CPU.

Hope that helps.

Again, thanks!

Keith
Keith Howard
2016-04-12 15:15:23 UTC
Permalink
To be clear, a 'uname -a' provides:
Linux Microknoppix 4.2.6-64 #21 SMP PREEMPT Sun Dec 13 16:04:28 CET 2015
x86_64 GNU/Linux

So, it appears that my host distro is 64 bit, right?


Thanks!

Keith
Bruce Dubbs
2016-04-12 17:40:23 UTC
Permalink
Post by Keith Howard
Linux Microknoppix 4.2.6-64 #21 SMP PREEMPT Sun Dec 13 16:04:28 CET 2015
x86_64 GNU/Linux
So, it appears that my host distro is 64 bit, right?
Yes, but 'lscpu' is more definitive.

-- Bruce
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http:/
Keith Howard
2016-04-12 15:23:32 UTC
Permalink
Hi Ken,

Thanks for responding and thanks for your insight.

So, on first inspection o f Gnu ld (first pass):
'file -L /tools/bin/x86_64-lfs-linux-gnu-ld'

/tools/bin/x86_64-lfs-linux-gnu-ld: **ELF 32-bit** LSB executable, Intel
80386, version 1 (SYSV), dynamically linked, interpreter
/lib/ld-linux.so.2, for GNU/Linux 2.6.32,
BuildID[sha1]=7c0c43bcf162ed49211b7a13579955140b891b5a, not stripped

Whoa! It's 32 bit! What the heck did I do! <grumble>
So, clearly, I'll have to go back and compile those tools again.

Can anyone give me any tips on how to avoid this?
I just copied and pasted from the PDF to my console....I understand some of
this, but.....when I get into trouble I dunno what to do.

It seems I should set an environment variable or something for the
archetecture, no?
Is that 'cflags' or -m64 ?

Again, many thanks!

Keith
Bruce Dubbs
2016-04-12 17:46:57 UTC
Permalink
Post by Keith Howard
Hi Ken,
Thanks for responding and thanks for your insight.
'file -L /tools/bin/x86_64-lfs-linux-gnu-ld'
/tools/bin/x86_64-lfs-linux-gnu-ld: **ELF 32-bit** LSB executable, Intel
80386, version 1 (SYSV), dynamically linked, interpreter
/lib/ld-linux.so.2, for GNU/Linux 2.6.32,
BuildID[sha1]=7c0c43bcf162ed49211b7a13579955140b891b5a, not stripped
Whoa! It's 32 bit! What the heck did I do! <grumble>
So, clearly, I'll have to go back and compile those tools again.
Yes, it should be

/tools/bin/x86_64-lfs-linux-gnu-ld: ELF 64-bit LSB executable, x86-64,
version 1 (SYSV), dynamically linked, interpreter
/lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped
Post by Keith Howard
Can anyone give me any tips on how to avoid this?
I just copied and pasted from the PDF to my console....I understand some of
this, but.....when I get into trouble I dunno what to do.
Do not use the pdf for copy/paste. It is very problemmatic that you get
everything as is should be. Specifically the pdf sometimes adds spaces
after backslashes used for line continuation. That breaks the build.

-- Bruce
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-
Keith Howard
2016-04-12 15:33:12 UTC
Permalink
Gosh, guys....I'm so confused!

So, if I do a 'which ld' I get:
/tools/bin/ld

So, if I do a 'file -L /tools/bin/ld' , I get:
/tools/bin/ld: **ELF 64-bit** LSB executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /tools/lib64/ld-linux-x86-64.so.2, for
GNU/Linux 2.6.32, not stripped

It's 64 bit.....

So, where did the 32 bit version come from and how's come it's being used
instead of the one I get from 'which'?

Sorry.....very newb!

Thanks!

Keith
Ken Moffat
2016-04-12 17:53:19 UTC
Permalink
Post by Keith Howard
Gosh, guys....I'm so confused!
/tools/bin/ld
/tools/bin/ld: **ELF 64-bit** LSB executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /tools/lib64/ld-linux-x86-64.so.2, for
GNU/Linux 2.6.32, not stripped
It's 64 bit.....
So, where did the 32 bit version come from and how's come it's being used
instead of the one I get from 'which'?
Sorry.....very newb!
Thanks!
Keith
The 32-bit version came from the defaults on your host system. I am
not sure if knoppix includes a 6-bit compiler ? If it does, using
-m64 might allow you to build 64-bit binaries. From memory, knoppix
is slimmed down - I see from the cheat codes
https://translate.googleusercontent.com/translate_c?depth=1&hl=en&prev=search&rurl=translate.google.co.uk&sl=de&u=http://knoppix.net/wiki/Cheat_Codes&usg=ALkJrhjL7MCIqAa2rg0dL4xnjr4s0WpILg
that knoppix64 boots a 64-bit kernel, but it says nothing about
whether userspace is also 64-bit.

In the past, on multilib systems, exec'ing 'linux32' or 'linux64'
(as root) would change the environment [ I used to use that to build
32-bit ppc on a ppc64 ], but that will only work if everything is
present. In particular, you need the 64-bit libraries. Those might
be in /lib64, or they might be in /lib with the 32-bit in /lib32.

I find it odd that an x86 system which reports it is x86_64 would
default to building 32-bit programs, but apparently it does.

The /tools/bin/ld binary comes from pass 2 ad looks good. But
building on an x86_64 host system which defaults to 32-bit binaries
is an unexplored situation.

You did not mention how the other files look. If glibc is 64-bit
then I suppose you could try adding -m64 to your CFLAGS when you
compile. But I do not know if that will work (as always you need
freshly extracted source), and if it does I don't know if you will
be able to complete chapter 5 doing that.

ĸen
--
This email was written using 100% recycled letters.
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing i
Keith Howard
2016-04-12 19:21:21 UTC
Permalink
Forgive me, Guys....dunno how to reply to each of your responses
*individually*, so....

Bruce,

Thanks for responses.
I knew of 'lspci' and 'lsmod', did not know of 'lscpu'.....very cool!
Lot's of info.
Post by Bruce Dubbs
Do not use the pdf for copy/paste. It is very problemmatic that you get
everything as is should be. Specifically the pdf sometimes adds spaces
after backslashes used for line continuation. That breaks the build.
Just the PDF, or from the web browser as well? Afraid of making typos
and hosing everything.

That's why I would copy/paste.....

Again, thanks, Bruce!


Ken,

Man......I feel like such a dumb dumb!

Per your advice:

I checked my browser executable, 'iceweasel' and sure enough.....it is 32 bit!

I checked under root (/) for 'lib64'.....missing!

It seems that although 'uname -a' reveals a 64 bit kernel my
environment is actually 32bit!

I did some Googling and it appears that an AMD 64bit kernel can run
32bit binaries.

I gotta start over....... :(

<sigh>

Well, I can't thank you gentlemen enough for your generous sharing of time
and knowledge!

I, now, have a MUCH better understanding of what's going on.....I need a 64
version of Knoppix (or other Live distro) that actually has a 64bit kernel
AND a 64bit userland/dev setup.

Thank you both!

Keith
Bruce Dubbs
2016-04-12 19:44:13 UTC
Permalink
Post by Keith Howard
Forgive me, Guys....dunno how to reply to each of your responses
*individually*, so....
Bruce,
Thanks for responses.
I knew of 'lspci' and 'lsmod', did not know of 'lscpu'.....very cool!
Lot's of info.
Post by Bruce Dubbs
Do not use the pdf for copy/paste. It is very problemmatic that you get
everything as is should be. Specifically the pdf sometimes adds spaces
after backslashes used for line continuation. That breaks the build.
Just the PDF, or from the web browser as well? Afraid of making typos
and hosing everything.
That's why I would copy/paste.....
Copy/paste from a browser works well.
Post by Keith Howard
It seems that although 'uname -a' reveals a 64 bit kernel my
environment is actually 32bit!
I did some Googling and it appears that an AMD 64bit kernel can run
32bit binaries.
Yes, any 64-bit system can run a 32-bit OS.
Post by Keith Howard
I, now, have a MUCH better understanding of what's going on.....I need a 64
version of Knoppix (or other Live distro) that actually has a 64bit kernel
AND a 64bit userland/dev setup.
Try Debian.

http://cdimage.debian.org/debian-cd/8.4.0/amd64/iso-cd/

I suggest debian-8.4.0-amd64-xfce-CD-1.iso. You will need to add some
packages after the base install -- g++, make, etc. See the version check
script is section vii to ensure you have everything, Don't for get teh
symlinks.

-- Bruce
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http://en.wikipedia.org/wiki
Loading...