Re: general question about compiling for weaker CPU

"Xi Ruoyao" ([email protected] via lfs-support Mailing List) <[email protected]> Fri, 26 Sep 2025 22:49:08 +0800
Newsgroups gmane.linux.lfs.support
Message-ID <[email protected]>
On Fri, 2025-09-26 at 16:09 +0200, Thomas Seeling wrote:
> Hallo,
> 
> my recent problem and my not-so-elegant solution - using a KVM with CPU 
> set to "core2duo" - made me think about generating a distro for general 
> use, like Fedora, Redhat, Debian, Ubuntu and all the other "vendors" do.
> 
> Obviously they cannot let the compiler optimize for the CPU on the build 
> machine, they have to restrict *all* packages to the lowest common 
> denominator they intend to support, e.g. the weakest 64-bit CPU there 
> is, and communicate those supported CPU levels. Never thought about that 
> before :-)
> 
> I understand the "LFS_TGT" variable is intended for this purpose.
> Do I also need to define the gcc setting "-march=<target>" in CFLAGS, 
> e.g. target="x86-64" or target="core2" (from the gcc man page at 
> https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)?
> What would the correct setting be to e.g. build for the "core2duo", 
> which was more or less the first generation of 64-bit CPUs from intel?

No.  x86-64 means the baseline and *it is the default unless you
override it with --with-arch=something building GCC*.

Still you didn't really diagnosed the root cause of your previous
failure out.  That just shouldn't happen.  Either you did something
wrong or we are missing a package that need to be handled in the book.

There's not a general way to ensure that: even if you have -march=x86-64
in CFLAGS the build system of a package can still *append* another -
march= option *after* your setting and override it.

Let's just fix the bug, no matter if it's in your build process or the
book, instead of trying to invent a silver bullet that we cannot
implement at all.

-- 
Xi Ruoyao <[email protected]>

-- 
http://lists.linuxfromscratch.org/sympa/info/lfs-support
Unsubscribe: See the above information page