Yubico / yubikey-personalization

YubiKey Personalization cross-platform library and tool
https://developers.yubico.com/yubikey-personalization/
BSD 2-Clause "Simplified" License
300 stars 82 forks source link

Fails to build with gcc 10 in Fedora 32 #155

Closed wzzrd closed 4 years ago

wzzrd commented 4 years ago

Fedora 32 is switching to gcc 10. During the last rebuild, ykpers, the Fedora package for yubikey-personalization failed to build successfully, which might have / probably has to do with the switch to gcc 10.

Here's a snippet of the error during build. More build logs are here and here

I'm sorry, I lack the skills to fix this myself :/

libtool: link: DIE_RPATH_DIE="/usr/lib64:" gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -pthread -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o .libs/ykpersonalize ykpersonalize.o  ./.libs/libykpers-1.so ./.libs/libykpers_args.a /builddir/build/BUILD/ykpers-1.20.0/.libs/libykpers-1.so -L/usr/lib64 -lusb-1.0 -lyubikey -pthread
make[1]: Leaving directory '/builddir/build/BUILD/ykpers-1.20.0'
/usr/bin/ld: ./.libs/libykpers_args.a(ykpers-args.o):/builddir/build/BUILD/ykpers-1.20.0/ykpers-args.h:37: multiple definition of `optstring'; ykpersonalize.o:/builddir/build/BUILD/ykpers-1.20.0/ykpers-args.h:37: first defined here
/usr/bin/ld: ./.libs/libykpers_args.a(ykpers-args.o):/builddir/build/BUILD/ykpers-1.20.0/ykpers-args.h:36: multiple definition of `usage'; ykpersonalize.o:/builddir/build/BUILD/ykpers-1.20.0/ykpers-args.h:36: first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:731: ykpersonalize] Error 1
make: *** [Makefile:931: all-recursive] Error 1
RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.DnR8UK (%build)
    Bad exit status from /var/tmp/rpm-tmp.DnR8UK (%build)
Child return code was: 1
EXCEPTION: [Error()]
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mockbuild/trace_decorator.py", line 95, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.7/site-packages/mockbuild/util.py", line 746, in do_with_status
    raise exception.Error("Command failed: \n # %s\n%s" % (command, output), child.returncode)
mockbuild.exception.Error: Command failed: 
 # bash --login -c /usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/ykpers.spec
klali commented 4 years ago

Looking (very) quickly at this, can you try adding extern to the definitions of usage and optstring in the ykpers-args.h header?

I'm not immediately able to reproduce this so no verification if this works or not.

wzzrd commented 4 years ago

That seems to work!

Build is successful: https://koji.fedoraproject.org/koji/taskinfo?taskID=41494412

Only change I made was

 #include "ykpers.h"

-const char *usage;
-const char *optstring;
+extern const char *usage;
+extern const char *optstring;

 int args_to_config(int argc, char **argv, YKP_CONFIG *cfg, char *oathid,
           size_t oathid_len, const char **infname,

Thanks!

Is it possible to base a 1.20.1 release on this patch?

klali commented 4 years ago

I'll start with fixing that on master, no promises on release.

wzzrd commented 4 years ago

Fair enough. I'll carry a patch in the Fedora SRPM for now.