Build fail on Ubuntu 24.04
Simon Chopin
simon.chopin@canonical.com
Thu Sep 5 14:01:08 GMT 2024
Hi Stefan,
Yes, it's a known problem, see
https://sourceware.org/bugzilla/show_bug.cgi?id=31928
We have a patch in the Ubuntu package, sending it for review on the ML has
been on my todo list for... way too long now.
On Thu, Sep 5, 2024 at 3:55 PM Stefan Liebler <stli@linux.ibm.com> wrote:
> Hi all,
>
> I've just recognized that building glibc on Ubuntu 24.04 currently fails
> with:
> wctomb.c:57:1: error: ‘artificial’ attribute ignored [-Werror=attributes]
> 57 | libc_hidden_def (wctomb)
> | ^~~~~~
> cc1: all warnings being treated as errors
>
>
> It turns out that gcc on Ubuntu automatically defines _FORTIFY_SOURCE:
> $ gcc -dumpspecs | grep FORTIFY
>
>
> %{!O0:%{O*:%{!D_FORTIFY_SOURCE=*:%{!U_FORTIFY_SOURCE:-D_FORTIFY_SOURCE=3}}}}
>
> Thus when compiling wctomb in stdlib/wctomb.c there is also the
> fortify-wrapper (with inline and __attribute__((artificial))). Later on
> after the implementation of wctomb, there is libc_hidden_def (wctomb).
> It tries to copy the artificial function attribute from the wrapper
> which leads to the fail:
> extern __typeof (wctomb) __EI_wctomb __attribute__((alias (""
> "__GI_wctomb"))) __attribute__ ((__copy__ (wctomb)));
>
> Here are some experiments:
> $ gcc -O2 -dM -E - < /dev/null | grep FORTIFY
> #define _FORTIFY_SOURCE 3
>
> $ gcc -O2 -Wp,-U_FORTIFY_SOURCE -dM -E - < /dev/null | grep FORTIFY
> #define _FORTIFY_SOURCE 3
>
> $ gcc -O2 -U_FORTIFY_SOURCE -dM -E - < /dev/null | grep FORTIFY
>
> $ gcc -O2 -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2 -dM -E - < /dev/null
> | grep FORTIFY
> #define _FORTIFY_SOURCE 3
>
> Thus as a workaround, one could configure with CFLAGS="-U_FORTIFY_SOURCE".
>
> From configure.ac:
> dnl Check if we support the requested _FORTIFY_SOURCE level
> dnl If not, then don't use it.
> dnl Note that _FORTIFY_SOURCE may have been set through FLAGS too.
> dnl _FORTIFY_SOURCE value will be selectively disabled for function that
> can't
> dnl support it
> no_fortify_source="-Wp,-U_FORTIFY_SOURCE"
> fortify_source="${no_fortify_source}"
> ...
> AS_IF([test "$libc_cv_fortify_source" = yes],
>
>
> [fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}"]
> )
>
> Does anybody know why "-Wp" is needed to bypass the compiler-driver and
> pass it directly to the preprocessor?
>
> Is it also fine to just use -U_FORTIFY_SOURCE?
> Or should the Ubuntu gcc somehow also check for -Wp,-U_FORTIFY_SOURCE?
>
> Looking into the Ubuntu glibc-sources, there is indeed the
> fix-fortify-source.patch from Matthias Klose which adjusts this plus
> follow-on adjustments:
> -no_fortify_source="-Wp,-U_FORTIFY_SOURCE"
> +no_fortify_source="-U_FORTIFY_SOURCE"
> ...
> AS_IF([test "$libc_cv_fortify_source" = yes],
> -
>
> [fortify_source="${fortify_source},-D_FORTIFY_SOURCE=${enable_fortify_source}"]
> + [fortify_source="${fortify_source}
> -D_FORTIFY_SOURCE=${enable_fortify_source}"]
> )
>
>
> Bye,
> Stefan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20240905/213f17a6/attachment.htm>
More information about the Libc-alpha
mailing list