[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240109074843.GI19790@gate.crashing.org>
Date: Tue, 9 Jan 2024 01:48:43 -0600
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Xi Ruoyao <xry111@...111.site>
Cc: richard clark <richard.xnu.clark@...il.com>,
Mark Rutland <mark.rutland@....com>, gcc-help@....gnu.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: undefined reference to `__aarch64_cas4_sync' error on arm64 native build
On Tue, Jan 09, 2024 at 11:05:57AM +0800, Xi Ruoyao via Gcc-help wrote:
> But the Linux kernel cannot use neither libc.so nor libgcc.a.
I have built Linux using libgcc for many years. It is as easy as
+LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
+libs-y += $(LIBGCC)
> (I know
> some non-Linux kernel developers are overusing libgcc.a for kernels, but
> IMO this is just wrong and Linux developers also do not do this. If the
> Linux kernel needs a symbol from libgcc the developers just provide
> their own implementation.)
Yes, and often they have fallen behind. When they eventually catch up
they usually just copy the GCC code anyway.
Originally the only reasonable argument for not linking against libgcc
was so kernel code would not accidentally use double-length divisions.
There are other simple ways to have all uses of __divti3 and similar
create link errors, so that is not really a good argument.
libgcc is an essential part of the compiler. For most targets, for most
code, GCC will not generate function calls, there usually are faster (or
smaller) things it can do, but it still is necessary to have libgcc for
more uncommon things. Using a partial copy of it, behind the times,
and maybe even incompatible, is not a great idea.
Segher
Powered by blists - more mailing lists