Well sure, because you need one, and only one, file that actually
defines it.
Previously every file that included the header created a definition
which meant you could wind up with multiple definitions if more than
one file included it.
Now no file that includes the header will create a definition unless
the file contains a definition of the variable (ie without extern) so
if there isn't such a file already then you will need to choose an
appropriate file and add the definition to it.
Tom
On 23/01/2020 15:48, Robert-André Mauchin wrote:
On Tuesday, 21 January 2020 13:35:03 CET Miro Hrončok wrote:
> Hello,
>
> we try to rebuild all Python packages against Python 3.9 and report the
> failures. I've seen several similar failures in a row now that can be
> reproduced
in Fedora rawhide with the new gcc version.
>
> ld errors on multiple definitions of ..., for example:
>
> ld:
> tests/bp_account.o:/builddir/build/BUILD/kernel-5.4.fc32/linux-5.4/tools/per
> f/tests/bp_account.c:22:
multiple definition of `the_var';
> tests/bp_signal.o:/builddir/build/BUILD/kernel-5.4.fc32/linux-5.4/tools/perf
> /tests/bp_signal.c:38:
first defined here
>
> This is a known thing in gcc 10:
>
>
https://gcc.gnu.org/gcc-10/porting_to.html#common
>
> "Default to -fno-common
>
> A common mistake in C is omitting extern when declaring a global variable in
> a
header file. If the header is included by several files it results in
> multiple definitions of the same variable. In previous GCC versions this
> error is ignored. GCC 10 defaults to -fno-common, which means a linker
> error will now be reported. To fix this, use extern in header files when
> declaring global variables, and ensure each global is defined in exactly
> one C file. As a workaround, legacy C code can be compiled with -fcommon.
>
>
> int x; // tentative definition - avoid in header files
>
> extern int y; // correct declaration in a header file"
>
>
> Here are some packages affected:
>
>
> nemo-extensions
>
https://bugzilla.redhat.com/show_bug.cgi?id=1793470
>
> thunarx-python
>
https://src.fedoraproject.org/rpms/thunarx-python/pull-request/1
>
> kernel-tools
>
https://bugzilla.redhat.com/show_bug.cgi?id=1793473
>
>
>
https://bugzilla.redhat.com/show_bug.cgi?id=1793424
>
> gnome-abrt, glusterfs...
>
>
>
> Before I go and file dozens of bugzillas, do we want to handle this somehow
> better?
> --
> Miro Hrončok
> --
> Phone: +420777974800
> IRC: mhroncok
> _______________________________________________
> devel mailing list -- devel(a)lists.fedoraproject.org
> To unsubscribe send an email to devel-leave(a)lists.fedoraproject.org
> Fedora Code of Conduct:
>
https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List
> Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines List
> Archives:
>
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
How to fix the affected packages? For some I ised extern and it worked but for
other using extern resulted in error like:
/usr/bin/ld: /builddir/build/BUILD/uTox-0.17.1/src/xlib/main.c:590: undefined
reference to `font_small_lineheight'
Lots of undefined reference despite the var being marked as global. All the
packages I have to fix have deadish upstream.
Any help appreciated.
Best regards,
Robert-André
_______________________________________________
devel mailing list -- devel(a)lists.fedoraproject.org
To unsubscribe send an email to devel-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org