Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Apr 2026 09:52:12 -0400
From:      John Baldwin <jhb@FreeBSD.org>
To:        Andrew Turner <andrew@FreeBSD.org>, src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: e63eee84cad5 - main - libgcc_s: Add a linker script to link to libgcc
Message-ID:  <30459007-56a1-4edf-8b20-2921e8e2e420@FreeBSD.org>
In-Reply-To: <69ef4ad1.1c7d4.4b8c5d49@gitrepo.freebsd.org>

index | next in thread | previous in thread | raw e-mail

On 4/27/26 07:38, Andrew Turner wrote:
> The branch main has been updated by andrew:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=e63eee84cad59f63338a539e73bed07917932088
> 
> commit e63eee84cad59f63338a539e73bed07917932088
> Author:     Andrew Turner <andrew@FreeBSD.org>
> AuthorDate: 2026-04-27 10:54:18 +0000
> Commit:     Andrew Turner <andrew@FreeBSD.org>
> CommitDate: 2026-04-27 11:37:53 +0000
> 
>      libgcc_s: Add a linker script to link to libgcc
>      
>      When using outline atomics on arm64 the compiler will create a call to
>      a function that performs the atomic operation. This allows us to use
>      the fastest operation depending on the hardware.
>      
>      As these functions are implemented in libgcc create a linker script
>      so libraries that link against libgcc_s will include libgcc to pull
>      them in.

Some additional notes:

GCC only links with -lgcc_s (the shared library) when linking C++ executables
and libraries, but links with both -lgcc_s and -lgcc when linking C executables
and libraries.  clang does the same on most libgcc-using platforms like Linux,
except that for FreeBSD, clang treats C++ like C and links in both libraries
(this is probably an accidental bug in clang's FreeBSD toolchain driver, but
kind of moot).  Linux distributions use an ldscript for libgcc_s on all
architectures (not just aarch64) to handle this weirdness of GCC.

This is all pretty sad as GCC ships with libgcc and should "know" if libgcc_s
needs symbols from libgcc, but matching Linux is probably the path of least
friction going forward.  It would only be worth fixing the toolchain driver
in clang if it meant removing the custom libgcc code, but I suspect we will
always need it for existing FreeBSD versions, so it's not clear to me that it is
worth doing.

-- 
John Baldwin



home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?30459007-56a1-4edf-8b20-2921e8e2e420>