Re: copy lfs build to older CPU
"Xi Ruoyao" ([email protected] via lfs-support Mailing List) <[email protected]> Fri, 26 Sep 2025 23:09:33 +0800
| Newsgroups | gmane.linux.lfs.support |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 2025-09-26 at 22:56 +0800, Xi Ruoyao wrote:
> On Fri, 2025-09-26 at 15:54 +0200, Thomas Seeling wrote:
> > Hallo,
> > > dmesg should show exactly which file contains the offending instruction.
> > > Like:
> > >
> > > [10066.276138] traps: a.out[100368] trap invalid opcode ip:7f0720a5f100 sp:7ffdcdaafd58 error:0 in t.so[1100,7f0720a5f000+1000]
> > >
> > > And which exact files have you replaced?
> >
> > I followed the instructions on the libffi and gmp packages, then used
> > "make DESTDIR=" to catch the files, transferred exactly the freshly
> > compiled files to the target and rebooted to make sure the new files are
> > there and not some cached old.
> >
> > Still got the error below. dmesg showed nothing.
>
> Try "sudo sysctl debug.exception-trace=1" before running the crashing
> program.
>
> > Compiling the first few files went through, and it choked here:
>
> >
> > make[1]: Entering directory '/sources/ethtool-5.0'
> > CC sff-common.o
> > sff-common.c: In function "convert_mw_to_dbm":
> > sff-common.c:29:9: internal compiler error: Illegal instruction
> > 29 | return (10. * log10(mw / 1000.)) + 30.;
> > | ^~~~~~
>
> This seems the first place where GCC invokes GMP (as it needs to
> calculate the correctly rounded value of some FP operations using MPFR).
Oh-oh. I found something in MPFR:
configure:4602: checking for CC and CFLAGS in gmp.h
configure:4635: result: CC=gcc CFLAGS=-O2 -fomit-frame-pointer -m64 -mtune=nehalem -march=nehalem
So the problem seems MPFR has inherited the -march= option used when GMP
was built, thus MPFR itself can contain instructions that the target CPU
does not support.
The book says:
If you want to deploy the LFS system onto a system with a different
CPU, when you build Section 8.22, “GMP-6.3.0” and Section 8.51,
“Libffi-3.5.2” you must follow the notes about overriding the
architecture-specific optimization to produce libraries suitable for
both the host system and the system(s) where you'll deploy the LFS
system. Otherwise you'll get Illegal Instruction errors running LFS.
If you strictly follow it there won't be a problem: if you built GMP with -
-host=none-linux-gnu in the first place, gmp.h would not contain -
march=xxxx so MPFR will be built fine.
But if you've already finish the book, simply rebuilding GMP will not be
enough. You'll need to rebuild at least MPFR ("at least" because we don't
know if there are more packages reading CFLAGS from gmp.h).
So to me we should just make it clear that rebuilding GMP is not enough,
i.e. you need to make the thing correct when you build GMP *the first
time* in LFS.
--
Xi Ruoyao <[email protected]>
--
http://lists.linuxfromscratch.org/sympa/info/lfs-support
Unsubscribe: See the above information page