[PATCH v2 23/28] Enable --no-undefined-version by default
H.J. Lu
hjl.tools@gmail.com
Wed Oct 29 01:58:15 GMT 2025
On Wed, Oct 29, 2025 at 1:13 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> Recent lld version default to --no-undefined-version, which triggers
> errors when building multiple libraries. For ld.so on x86_64 it fails
> with:
>
> ld.lld: error: version script assignment of 'GLIBC_2.4' to symbol '__stack_chk_guard' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '__nptl_set_robust_list_avail' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '__pointer_chk_guard' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '_dl_starting_up' failed: symbol not defined
>
> While for libc.so:
>
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_clearerr' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fgetc' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fileno' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_freopen' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fscanf' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fseek' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_peekc_unlocked' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stderr_' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stdin_' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stdout_' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_pclose' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_perror' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_rewind' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_scanf' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_setbuf' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_setlinebuf' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_wdefault_setbuf' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_wfile_setbuf' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '__ctype32_tolower' failed: symbol not defined
> ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '__ctype32_toupper' failed: symbol not defined
> ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
>
> The version script is created with multiple missing symbols to simplify
> the build for multiple ABIs, each of which may have different symbols.
> For instance, __stack_chk_guard is defined by default. This avoids
> requiring each ABI to add this symbol to its version script, depending
> on the stack protector ABI it uses.
>
> The libc.so warnings do show unused symbols being defined (like
> _IO_clearerr), which might trigger potential errors depending on how
> symbols are exported. However, since we already have ABI checks for
> missing and extra symbols, the linker's extra checks are not really
> necessary.
>
> The --no-undefined-version is the default for ld.bfd.
> ---
> Makerules | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/Makerules b/Makerules
> index 7714888cdc..caa1e43faa 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -508,7 +508,9 @@ ifeq ($(build-shared),yes)
> map-file = $(firstword $($(@F:.so=-map)) \
> $(addprefix $(common-objpfx), \
> $(filter $(@F:.so=.map),$(version-maps))))
> -load-map-file = $(map-file:%=-Wl,--version-script=%)
> +# The map version is created with multiple symbols that might not be
> +# exported depending of the ABI.
> +load-map-file = $(map-file:%=-Wl,--version-script=%) -Wl,--undefined-version
> endif
>
> # Compiler arguments to use to link a shared object with libc and
> --
> 2.43.0
>
LGTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
--
H.J.
More information about the Libc-alpha
mailing list