mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "schuster.simon@siemens-energy.com" <schuster.simon@siemens-energy.com>
Cc: "Dinh Nguyen" <dinguyen@kernel.org>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	linux-kernel@vger.kernel.org,
	"Chung-Lin Tang" <cltang@baylibre.com>
Subject: Re: [PATCH 1/2] nios2: remove libgcc for lshrdi3, ashldi3, ashrdi3, muldi3, and ucmpdi2
Date: Tue, 20 Oct 2026 14:55:28 +0200	[thread overview]
Message-ID: <426c73b7-b4dc-4b68-9aa5-6145a13280bc@app.fastmail.com> (raw)
In-Reply-To: <20261020123149.cyjzz4uo25oiiu2m@dev-vm-schuster>

On Tue, Oct 20, 2026, at 14:31, Simon Schuster wrote:
> On Tue, Oct 20, 2026 at 11:41:59AM +0200, Arnd Bergmann wrote:

> Wouldn't that fulfil the requirement as well? Only "vetted"/trustworthy
> symbols get exported/linked, while it is easy to add additional symbols
> if the need arises? (If we gracefully ignore the downsides, such as some
> degree of brittleness such as implicitly assuming that all
> dependent symbols reside in the same file as they will be switched
> to local, and the fact that this is a hack, and that we tie us more
> closely to gcc on architectures using said "hack").

That would work, but it would add complexity rather than simplifying
the build system.  Generally speaking I'd always try to do whatever
the more common architectures do, unless there is a strong reason
for it.

>> I also found a similar implemention for m32r that was still
>> GPLv2, maybe that one works, see https://github.com/gcc-mirror/gcc/commit/38b2d07632#diff-4de4f3b573100be00cf40045c85faaca8ded1f13ef80df1822889cbd6ad639a8
>
> Nice find, m32c-lib2.c seems identical to the modern nios2 lib2-divmod.c
> (save whitespace changes). This already covers:
> __divsi3
> __modsi3
> __udivsi3
> __umodsi3
>
> Regarding __divsi3_table:
>
> This basically seems to be an array of 16 x 16 (even though its
> linearized into memory) that caches the result of row_index / column_idx
> (with divisions by 0 being assigned to 0), so "reimplementation" should
> be trivial.
>
> Regarding __mulsi3:
>
> The iq2000 target seems to have a GPLv2 implementation; slight
> difference in declared datatypes (iq2000 uses unsigned, nios2 uses
> signed, I'd need to think a bit more about this), but should generally
> be viable.
> https://github.com/gcc-mirror/gcc/blob/releases/gcc-4.2/gcc/config/iq2000/lib2extra-funcs.c

I now found another copy that may be even closer to what you need in
https://git.openembedded.org/openembedded/tree/recipes/gcc/gcc-4.1.2/gcc-nios2.patch

> So we should probably be able to assemble a libgcc-free nios2 kernel
> runtime without the risk of introducing new bugs in potential
> reimplementations if desired.

That sounds great, yes. Can you add the C implementations to the
architecture-independent lib/ directory with corresponding
CONFIG_GENERIC_LIB_* symbols? That should help create the a
similar patch for arc and openrisc if we can motivate someone
to do that.

      Arnd

      reply	other threads:[~2026-10-20 12:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 16:50 Dinh Nguyen
2026-10-19 16:50 ` [PATCH 2/2] nios2: remove 64-bit division Dinh Nguyen
2026-10-19 21:14   ` Arnd Bergmann
2026-10-19 21:20 ` [PATCH 1/2] nios2: remove libgcc for lshrdi3, ashldi3, ashrdi3, muldi3, and ucmpdi2 Arnd Bergmann
2026-10-20  8:56   ` Simon Schuster
2026-10-20  9:41     ` Arnd Bergmann
2026-10-20 12:31       ` Simon Schuster
2026-10-20 12:55         ` Arnd Bergmann [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=426c73b7-b4dc-4b68-9aa5-6145a13280bc@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=cltang@baylibre.com \
    --cc=dinguyen@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schuster.simon@siemens-energy.com \
    --cc=thomas.weissschuh@linutronix.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

all inboxes | Powered by JetHome®