Subject: Re: [PATCH v2] powerpc: Replace the obsolete address of the FSF

From: Segher Boessenkool <[email-masked]>
Date: Sun, 13 Jul 2025 09:01:14 -0500

On Sat, Jul 12, 2025 at 11:48:16PM +0100, Maciej W. Rozycki wrote:
> On Fri, 11 Jul 2025, Richard Fontana wrote:
>  I don't know what the legal status of the statement referred is, however 
> the original exception as published[1] by FSF says:
> 
> '"GCC" means a version of the GNU Compiler Collection, with or without 
> modifications, governed by version 3 (or a specified later version) of the 
> GNU General Public License (GPL) with the option of using any subsequent 
> versions published by the FSF.'

(which is likely the wrong license, the code in the kernel was taken
from something GPLv2).

> which I think makes it clear that "GCC" is a collection of "GNU compilers" 
> and therefore the two terms are synonymous to each other for the purpose 
> of said exception (in the old days "GCC" stood for "GNU C Compiler", but 
> the old meaning makes no sense anymore now that we have compilers for Ada, 
> Fortran and many other languages included in GCC).

Since, what, 2001?  If this matters for these files, they were forked
*very* long ago!

And, of course, the much better way to solve these self-inflicted
problems is to just use the libgcc that your version of GCC want to use,
the one it ships with itself, it being a necessary portion of the
compiler!

Here, an old patch of mine, this one for SuperH (I have stacks of such
patches, for many archs):

===
commit 9289694955c6105fb6bcc35fbf9ce7acddd60674
Author: Segher Boessenkool <[email-masked]>
Date:   Mon Nov 24 09:36:50 2014 -0800

    sh: Use libgcc
    
    Building the kernel with non-ancient compilers fails, because some
    newer libgcc functions are missing from the kernel's clone of it.
    Use the compiler's libgcc, instead.

diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 5c8776482530..eae83b76f17c 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -171,6 +171,8 @@ KBUILD_CFLAGS		+= -pipe $(cflags-y)
 KBUILD_CPPFLAGS		+= $(cflags-y)
 KBUILD_AFLAGS		+= $(cflags-y)
 
+LIBGCC		:= $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
+
 ifeq ($(CONFIG_MCOUNT),y)
   KBUILD_CFLAGS += -pg
 endif
@@ -180,6 +182,7 @@ ifeq ($(CONFIG_DWARF_UNWINDER),y)
 endif
 
 libs-y			:= arch/sh/lib/	$(libs-y)
+libs-y += $(LIBGCC)
 
 BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
 	       uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
index eb473d373ca4..2acb2d8c0366 100644
--- a/arch/sh/lib/Makefile
+++ b/arch/sh/lib/Makefile
@@ -6,11 +6,6 @@
 lib-y  = delay.o memmove.o memchr.o \
 	 checksum.o strlen.o div64.o div64-generic.o
 
-# Extracted from libgcc
-obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \
-	 ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \
-	 udiv_qrnnd.o
-
 udivsi3-y			:= udivsi3_i4i-Os.o
 
 ifneq ($(CONFIG_CC_OPTIMIZE_FOR_SIZE),y)
===

Segher