Discussion:
[lfs-support] Please consider adding --with-gcc-arch=native in libffi configure
Don Cross
2018-06-30 00:32:37 UTC
Permalink
I wasn't sure whether to send this to lfs-support or lfs-dev. Since I'm not
a developer on LFS, I guessed the former. Apologies if my guess is
unhelpful.

I built LFS using jhalfs and the 8.2 version of the book on a machine with
an Intel G860 processor. The configure script for libffi guessed wrong
about the processor's capabilities, causing Python 3 to crash with an
invalid instruction exception.

I fixed this by changing the jhalfs script 115_libffi to let gcc determine
the architecture rather than the configure script itself:

./configure --prefix=/usr --disable-static --with-gcc-arch=native

See here for reference:
http://linuxfromscratch.org/lfs/view/development/chapter06/libffi.html

I would like to ask that the developers consider making this change to the
LFS book. This might possibly cause incorrect behavior on other CPU types,
although I would think gcc would do a better job than this buggy script.
So at the very least, it would be helpful to mention this problem and
solution on the libffi step (where the problem originates) and the Python 3
step (where it manifests itself as an "invalid instruction" exception).

It took me a couple of days to figure this out because I kept thinking the
problem was in Python 3. Now that I know what happened, search shows that
at least one other person has been bitten by this (Celeron G530 in their
case):

http://lists.linuxfromscratch.org/pipermail/lfs-support/2018-May/052008.html

Thanks for all the great work you guys do! This is a fantastic educational
resource.
- Don
Bruce Dubbs
2018-06-30 03:47:26 UTC
Permalink
Post by Don Cross
I wasn't sure whether to send this to lfs-support or lfs-dev. Since
I'm not a developer on LFS, I guessed the former. Apologies if my
guess is unhelpful.
I built LFS using jhalfs and the 8.2 version of the book on a machine
with an Intel G860 processor. The configure script for libffi guessed
wrong about the processor's capabilities, causing Python 3 to crash
with an invalid instruction exception.
I fixed this by changing the jhalfs script 115_libffi to let gcc
./configure --prefix=/usr --disable-static --with-gcc-arch=native
http://linuxfromscratch.org/lfs/view/development/chapter06/libffi.html
I would like to ask that the developers consider making this change to
the LFS book.  This might possibly cause incorrect behavior on other
CPU types, although I would think gcc would do a better job than this
buggy script.  So at the very least, it would be helpful to mention
this problem and solution on the libffi step (where the problem
originates) and the Python 3 step (where it manifests itself as an
"invalid instruction" exception).
It took me a couple of days to figure this out because I kept thinking
the problem was in Python 3.  Now that I know what happened, search
shows that at least one other person has been bitten by this (Celeron
I'll think abou this, but perhaps a note inserted may be better.  In
some cases, users want to
build on one system and copy it to a lsesser system.  Using native may
not be the best fir
that case.

I've created a ticket so we don't forget.

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

h
William Harrington
2018-06-30 04:44:03 UTC
Permalink
On Fri, 29 Jun 2018 22:47:26 -0500
Post by Don Cross
./configure --prefix=/usr --disable-static --with-gcc-arch=native
When was this added? From what I can tell from a search is that ImageMagick also has the configure option, but I can't find it in a GCC document. GCC has always used -march and -mtune. Is this an application specific option?

Sincerely,

William Harrington
--
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
Michael Shell
2018-06-30 09:27:34 UTC
Permalink
On Fri, 29 Jun 2018 20:32:37 -0400
Post by Don Cross
I built LFS using jhalfs and the 8.2 version of the book on a machine with
an Intel G860 processor. The configure script for libffi guessed wrong
about the processor's capabilities, causing Python 3 to crash with an
invalid instruction exception.
FWIW, I did file a bug report with libffi's developers:

https://sourceware.org/ml/libffi-discuss/2018/msg00033.html

Mailing list and contact info here:
https://sourceware.org/libffi/

However, there hasn't been any reply, so far.

At the very least, maybe there should be a warning message about this
issue on the LFS libffi page, including noting that it will typically
manifest as a python illegal instruction crash, which can happen
when building meson.


Cheers,

Mike Shell
--
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.wikiped
Bruce Dubbs
2018-07-03 16:19:49 UTC
Permalink
Post by Don Cross
I wasn't sure whether to send this to lfs-support or lfs-dev. Since I'm
not a developer on LFS, I guessed the former. Apologies if my guess is
unhelpful.
I built LFS using jhalfs and the 8.2 version of the book on a machine
with an Intel G860 processor. The configure script for libffi guessed
wrong about the processor's capabilities, causing Python 3 to crash with
an invalid instruction exception.
I fixed this by changing the jhalfs script 115_libffi to let gcc
./configure --prefix=/usr --disable-static --with-gcc-arch=native
In the libffi source directory, can you pelease tell us what the output
of ./config.guess

In my case it is x86_64-unknown-linux-gnu.

-- 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.wik
Don Cross
2018-07-03 19:51:13 UTC
Permalink
This post might be inappropriate. Click to display it.
Bruce Dubbs
2018-07-03 20:19:22 UTC
Permalink
Post by Don Cross
Post by Don Cross
I wasn't sure whether to send this to lfs-support or lfs-dev.
Since I'm
Post by Don Cross
not a developer on LFS, I guessed the former. Apologies if my
guess is
Post by Don Cross
unhelpful.
I built LFS using jhalfs and the 8.2 version of the book on a
machine
Post by Don Cross
with an Intel G860 processor. The configure script for libffi
guessed
Post by Don Cross
wrong about the processor's capabilities, causing Python 3 to
crash with
Post by Don Cross
an invalid instruction exception.
I fixed this by changing the jhalfs script 115_libffi to let gcc
./configure --prefix=/usr --disable-static --with-gcc-arch=native
In the libffi source directory, can you pelease tell us what the output
of ./config.guess
In my case it is x86_64-unknown-linux-gnu.
   -- Bruce
x86_64-unknown-linux-gnu
However, I believe the smoking gun is in the output of ./configure when
I leave out the --with-gcc-arch=native.  If I diff the output of
./configure without that native option (bad.txt) against the output with
--disable-static > bad.txt
--disable-static --with-gcc-arch=native > good.txt
106,110c106,108
< checking for x86 cpuid 0 output... d:756e6547:6c65746e:49656e69
< checking for x86 cpuid 1 output... 206a7:2100800:d9ae3bf:bfebfbff
< checking whether C compiler accepts -march=corei7-avx... yes
< checking for gcc architecture flag... -march=corei7-avx
< checking whether C compiler accepts -O3 -fomit-frame-pointer
-fstrict-aliasing -ffast-math -march=corei7-avx... yes
---
Post by Don Cross
checking whether C compiler accepts -march=native... yes
checking for gcc architecture flag... -march=native
checking whether C compiler accepts -O3 -fomit-frame-pointer
-fstrict-aliasing -ffast-math -march=native... yes
I'm not sure how ./configure comes up with corei7-avx, but the Intel
G860 does not support Advanced Vector eXtension instructions.
I think --with-gcc-arch=native is going to give the vast number of LFS
builders the correct output. If they are cross-compiling, they are going
to have to go through the pain of figuring out the target architecture
settings anyway, so they will be no worse off.
Thanks, that helps. I'll continue my investigation. there is a lot
going on in LFS right now so I will be making multiple updates in the
next few days.

-- 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/Posting
Loading...