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