mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] libgmp cflags
Date: Thu, 12 Dec 2024 13:01:41 +0100	[thread overview]
Message-ID: <Z1rQpV4k_JOubH9t@pengutronix.de> (raw)
In-Reply-To: <20241210-pesticide-garnet-ef57e562fa17@thorsis.com>

Hi,

On Tue, Dec 10, 2024 at 05:11:59PM +0100, Alexander Dahl wrote:
> I'm using nftables and on an armv5te target (microchip at91 sam9x60)
> the command `nft list ruleset` crashes with 'illegal instruction'.
> 
> BSP is on ptxdist-2024.05.0 with the latest libgmp 6.3 backported from
> master.  Toolchain is precompiled
> OSELAS.Toolchain-2023.07.1/arm-v5te-linux-gnueabi from
> debian.pengutronix.de, so overall nothing special.
> 
> `ptxdist prepare libgmp` gives this (somewhere in between):
> 
>     using ABI="32"
>           CC="arm-v5te-linux-gnueabi-gcc"
>           CFLAGS="-O2 -pedantic -fomit-frame-pointer -march=armv4 -mfloat-abi=softfp"
>           CPPFLAGS=""
>           MPN_PATH=" arm generic"
> 
> After staring at configure.ac and configure I guess they try to be
> smart here, but do not detect the actual arch.
> 
> Analzing the coredump with cgdb suggests it fails in __gmp_doprnt()
> shows this:
> 
>       1│ Dump of assembler code for function __gmp_doprnt:
>       2│    0xb6d69840 <+0>:     push    {r4, r5, r6, r7, r8, r9, r10, r11, lr}
>       3├──> 0xb6d69844 <+4>:     vpush   {d8}
>       4│    0xb6d69848 <+8>:     sub     sp, sp, #132    @ 0x84
> 
> That instruction seems to be some VFP related ARM floating point thing?
> 
> I tried adding this to rules/libgmp.make:
> 
> LIBGMP_CONF_ENV     := \
>     CFLAGS='-O2 -pedantic -g'
> 
> This gives almost the same output of prepare, but with "my" cflags
> only, so without -march or -mfloat-abi and then nft does not crash
> anymore.
> 
> I could use that as a workaround, but it seems to circumvent libgmp
> arch detection entirely, and so I'm not sure if that's the correct way
> here?
> 
> btw, you can see libgmp autoconf is not so super smart, because this is the
> output of `ptxdist prepare libgmp` on v7a target:
> 
>     using ABI="32"
>           CC="arm-v7a-linux-gnueabihf-gcc"
>           CFLAGS="-O2 -pedantic -fomit-frame-pointer -march=armv4 -mfloat-abi=hard"
>           CPPFLAGS=""
>           MPN_PATH=" arm generic"
> 
> So it's still -march=armv4 here.  But is that really necessary with
> the cross compiler at all?

Wow that detection is really confusing. And I'm not seeing anything there
that should be added to the CFLAGS. And somewhere in there I find: "Any
user CFLAGS, even an empty string, takes precedence".

So setting the CFLAGS works by design and I think it's the correct fix. But
please add a comment why this is necessary.

Michael

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2024-12-12 12:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-10 16:11 Alexander Dahl
2024-12-12 12:01 ` Michael Olbrich [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z1rQpV4k_JOubH9t@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox