mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] lib: Add software mul/div helpers and use them from nios2
@ 2026-11-03 13:30 Simon Schuster
  2026-11-03 13:30 ` [PATCH v2 1/3] lib: extract 32bit mul/div helpers from nios2 into GENERIC_LIB Simon Schuster
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Simon Schuster @ 2026-11-03 13:30 UTC (permalink / raw)
  To: Dinh Nguyen, Andrew Morton, Arnd Bergmann
  Cc: Sasha Levin, linux-kernel, Vineet Gupta, Simon Schuster

Recently, there have been linking failures on nios2 regarding libgcc
symbols that we reexport to modules (in particular __mulsi3 [0], and
__divsi3_table [1]).

In the resulting discussion, Arnd suggested [2] dropping the libgcc
dependency altogether, as -- while specific functions might be fine --
libgcc does not expect to run in a kernel-like freestanding environment.

To this end, Dinh Nguyen was kind enough to locate and extract
GPLv2-compliant versions of the software mul/div/mod functions required
by nios2 gcc and integrate them into the kernel. As Arnd also suggested
[3] that these might be helpful to other smaller architectures (such as
arc or openrisc), I've further extracted them to lib/ with corresponding
CONFIG_GENERIC_LIB_* options that allow selectively enabling and
exporting these as required.

The patch series compiles mostly^4 fine in a nios2 allyesconfig
without modpost errors; a quick boot test on a regular build also
completed successfully.

Best regards,
Simon

0: https://lore.kernel.org/lkml/20261019-nios2-mulsi3-v1-1-4fd75b1bacef@linutronix.de/
1: https://lore.kernel.org/lkml/20261026234452.1086974-1-sashal@kernel.org/
2: https://lore.kernel.org/lkml/686f4ca2-0fb6-4a73-9cdb-0edcccafdd62@app.fastmail.com/
3: https://lore.kernel.org/lkml/426c73b7-b4dc-4b68-9aa5-6145a13280bc@app.fastmail.com/
4: There seems to be an unrelated issue in linux-next regarding
   CONFIG_PNFS_BLOCK. Furthermore -Wno-attribute-alias
   -Wno-missing-prototypes -Wno-missing-declarations and
   -Wno-unused-function were required due to unrelated Werror-related
   compilation issues; but as this series concerns compiler intrinsics
   that are never explicitly referenced in code and it links fine this
   seems acceptable to me.

Signed-off-by: Simon Schuster <schuster.simon@siemens-energy.com>
---
Changes in v2:
- Reorganised to directly add to lib/* skipping arch/nios2/lib/math.c
- Dropped __gcc_bcmp as it is not actually needed
- Link to v1: https://lore.kernel.org/r/20261030-nios2-remove-usage-of-libgcc-v1-0-4e341c66082e@siemens-energy.com

---
Dinh Nguyen (2):
      lib: extract 32bit mul/div helpers from nios2 into GENERIC_LIB
      nios2: Drop usage of libgcc in favour of GENERIC_LIB_*

Simon Schuster (1):
      nios2: export __divsi3_table

 arch/nios2/Kconfig              | 10 +++++
 arch/nios2/Makefile             |  4 +-
 arch/nios2/kernel/nios2_ksyms.c | 22 ----------
 arch/nios2/lib/Makefile         |  1 +
 arch/nios2/lib/math.c           | 24 +++++++++++
 include/linux/libgcc.h          | 10 +++++
 lib/Kconfig                     | 15 +++++++
 lib/Makefile                    | 10 +++++
 lib/divmod.c                    | 94 +++++++++++++++++++++++++++++++++++++++++
 lib/mulsi3.c                    | 24 +++++++++++
 10 files changed, 189 insertions(+), 25 deletions(-)
---
base-commit: a39c950806213f6861d00f90729acaaa21f2d95a
change-id: 20261030-nios2-remove-usage-of-libgcc-63d9d0faad62

Best regards,
-- 
Simon Schuster <schuster.simon@siemens-energy.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-04  4:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 13:30 [PATCH v2 0/3] lib: Add software mul/div helpers and use them from nios2 Simon Schuster
2026-11-03 13:30 ` [PATCH v2 1/3] lib: extract 32bit mul/div helpers from nios2 into GENERIC_LIB Simon Schuster
2026-11-04  4:23   ` Vineet Gupta
2026-11-03 13:30 ` [PATCH v2 2/3] nios2: export __divsi3_table Simon Schuster
2026-11-03 13:30 ` [PATCH v2 3/3] nios2: Drop usage of libgcc in favour of GENERIC_LIB_* Simon Schuster
2026-11-03 15:40 ` [PATCH v2 0/3] lib: Add software mul/div helpers and use them from nios2 Arnd Bergmann

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®