Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker error w/ 'pp.o' if "-mieee-fp" is in CFLAGS: "multiple definition of `_LIB_VERSION'" #16086

Closed
p5pRT opened this issue Jul 23, 2017 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 23, 2017

Migrated from rt.perl.org#131786 (status was 'resolved')

Searchable as RT131786$

@p5pRT
Copy link
Author

p5pRT commented Jul 23, 2017

From kumba@gentoo.org

Created by kumba@gentoo.org

Compiling >=perl-5.24* with "-mieee-fp" in CFLAGS will cause the below
link-time error​:

x86_64-pc-linux-gnu-gcc -O2 -ggdb2 -pipe -march=ivybridge -mtune=ivybridge -mfpmath=sse -mieee-fp -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mpclmul -mpopcnt -mrdrnd -msahf -mxsave -mxsaveopt -mvzeroupper -mavx256-split-unaligned-load -mavx256-split-unaligned-store -maccumulate-outgoing-args -fstack-protector-all -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-loop-im -ftree-loop-linear -ftree-loop-ivcanon -fgcse-after-reload -fgcse-lm -fgcse-sm -fgcse-las -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -ftree-vectorize -flto=10 -fuse-linker-plugin -fstack-check=no -Wl,-O1 -Wl,--as-needed -Wl,-z,now -Wl,-z,relro -Wl,--sort-common -Wl,--hash-style=gnu -Wl,-flto -fno-lto -fno-use-linker-plugin -o miniperl \
  opmini.o perlmini.o gv.o toke.o perly.o pad.o regcomp.o dump.o util.o mg.o reentr.o mro_core.o keywords.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o globals.o perlio.o perlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o caretx.o dquote.o time64.o miniperlmain.o -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64/libieee.a​:(.data+0x0)​: multiple definition of `_LIB_VERSION'
pp.o​:(.data+0x0)​: first defined here
collect2​: error​: ld returned 1 exit status
make​: *** [makefile​:382​: lib/buildcustomize.pl] Error 1
make​: *** Waiting for unfinished jobs....

This was an issue a few years ago, in perl-5.8.x, and back then, was tied
to an issue in Glibc itself, but was fixed in PR14582 in ~2013 by making
_LIB_VERSION a weak symbol. Thus, it looks like this recurrence is in perl
itself.

A workaround is to drop "-mieee-fp" from CFLAGS when building perl and add
it back afterwards. I also think the use of link-time optimization (LTO)
may factor in here because to use LTO, the entire CFLAGS value had to be
passed to the linker in LDFLAGS. Not 100% sure on that.

An old Gentoo bug on the issue is here as Bug #296597​:
https://bugs.gentoo.org/show_bug.cgi?id=296597

Thanks!

--
Joshua Kinard
Gentoo/MIPS
kumba@​gentoo.org
6144R/F5C6C943 2015-04-27
177C 1972 1FB8 F254 BAD0 3E72 5C63 F4E3 F5C6 C943

Perl Info
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl 5.24.2:

Configured by Gentoo at Sun Jul 23 14:22:57 EDT 2017.

Summary of my perl5 (revision 5 version 24 subversion 2) configuration:

  Platform:
    osname=linux, osvers=4.12.0, archname=x86_64-linux-thread-multi
    uname='linux helcaraxe 4.12.0 #3 smp mon jul 3 03:10:58 edt 2017 x86_64 genuine intel(r) cpu @ 3.40ghz genuineintel gnulinux '
    config_args='-des -Dinstallprefix=/usr -Dinstallusrbinperl=n -Di_ndbm -Di_gdbm -Di_db -Dusethreads -DDEBUGGING=-g -Dinc_version_list=5.24.1/x86_64-linux-thread-multi 5.24.1 5.24.0/x86_64-linux-thread-multi 5.24.0  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dnoextensions=ODBM_File -Duseshrplib -Darchname=x86_64-linux-thread -Dcc=x86_64-pc-linux-gnu-gcc -Doptimize=-O2 -ggdb2 -pipe -march=ivybridge -mtune=ivybridge -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mpclmul -mpopcnt -mrdrnd -msahf -mxsave -mxsaveopt -mvzeroupper -mavx256-split-unaligned-load -mavx256-split-unaligned-store -maccumulate-outgoing-args -fstack-protector-all -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-loop-im -ftree-loop-linear -ftree-loop-ivcanon -fgcse-after-reload -fgcse-lm -fgcse-sm -fgcse-las -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -ftree-vectorize -flto=10 -fuse-linker-plugin -fstack-check=no -fno-lto -fno-use-linker-plugin -Dldflags=-O2 -ggdb2 -pipe -march=ivybridge -mtune=ivybridge -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mpclmul -mpopcnt -mrdrnd -msahf -mxsave -mxsaveopt -mvzeroupper -mavx256-split-unaligned-load -mavx256-split-unaligned-store -maccumulate-outgoing-args -fstack-protector-all -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-loop-im -ftree-loop-linear -ftree-loop-ivcanon -fgcse-after-reload -fgcse-lm -fgcse-sm -fgcse-las -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -ftree-vectorize -flto=10 -fuse-linker-plugin -fstack-check=no -Wl,-O1 -Wl,--as-needed -Wl,-z,now -Wl,-z,relro -Wl,--sort-common -Wl,--hash-style=gnu -Wl,-flto -fno-lto -fno-use-linker-plugin -Dprefix=/usr -Dsiteprefix=/usr/local -Dvendorprefix=/usr -Dscriptdir=/usr/bin -Dprivlib=/usr/lib64/perl5/5.24.2 -Darchlib=/usr/lib64/perl5/5.24.2/x86_64-linux-thread-multi -Dsitelib=/usr/local/lib64/perl5/5.24.2 -Dsitearch=/usr/local/lib64/perl5/5.24.2/x86_64-linux-thread-multi -Dvendorlib=/usr/lib64/perl5/vendor_perl/5.24.2 -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.24.2/x86_64-linux-thread-multi -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dvendorman1dir=/usr/share/man/man1 -Dvendorman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dlibperl=libperl.so.5.24.2 -Dlocincpth=/usr/include  -Dglibpth=/lib64 /usr/lib64  -Duselargefiles -Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Ud_csh -Dsh=/bin/sh -Dtargetsh=/bin/sh -Uusenm -Di_ndbm -Di_gdbm -Di_db -Dusethreads -DDEBUGGING=-g -Dinc_version_list=5.24.1/x86_64-linux-thread-multi 5.24.1 5.24.0/x86_64-linux-thread-multi 5.24.0  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dnoextensions=ODBM_File'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='x86_64-pc-linux-gnu-gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -ggdb2 -pipe -march=ivybridge -mtune=ivybridge -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mpclmul -mpopcnt -mrdrnd -msahf -mxsave -mxsaveopt -mvzeroupper -mavx256-split-unaligned-load -mavx256-split-unaligned-store -maccumulate-outgoing-args -fstack-protector-all -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-loop-im -ftree-loop-linear -ftree-loop-ivcanon -fgcse-after-reload -fgcse-lm -fgcse-sm -fgcse-las -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -ftree-vectorize -flto=10 -fuse-linker-plugin -fstack-check=no -fno-lto -fno-use-linker-plugin',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe'
    ccversion='', gccversion='7.1.0', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='x86_64-pc-linux-gnu-gcc', ldflags ='-O2 -ggdb2 -pipe -march=ivybridge -mtune=ivybridge -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mpclmul -mpopcnt -mrdrnd -msahf -mxsave -mxsaveopt -mvzeroupper -mavx256-split-unaligned-load -mavx256-split-unaligned-store -maccumulate-outgoing-args -fstack-protector-all -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-loop-im -ftree-loop-linear -ftree-loop-ivcanon -fgcse-after-reload -fgcse-lm -fgcse-sm -fgcse-las -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -ftree-vectorize -flto=10 -fuse-linker-plugin -fstack-check=no -Wl,-O1 -Wl,--as-needed -Wl,-z,now -Wl,-z,relro -Wl,--sort-common -Wl,--hash-style=gnu -Wl,-flto -fno-lto -fno-use-linker-plugin'
    libpth=/usr/local/lib64 /lib64 /usr/lib64 /usr/lib/gcc/x86_64-pc-linux-gnu/7.1.0/include-fixed /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.25.so, so=so, useshrplib=true, libperl=libperl.so.5.24.2
    gnulibc_version='2.25'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -ggdb2 -pipe -march=ivybridge -mtune=ivybridge -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mpclmul -mpopcnt -mrdrnd -msahf -mxsave -mxsaveopt -mvzeroupper -mavx256-split-unaligned-load -mavx256-split-unaligned-store -maccumulate-outgoing-args -fstack-protector-all -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-loop-im -ftree-loop-linear -ftree-loop-ivcanon -fgcse-after-reload -fgcse-lm -fgcse-sm -fgcse-las -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -ftree-vectorize -flto=10 -fuse-linker-plugin -fstack-check=no -fno-lto -fno-use-linker-plugin -O2 -ggdb2 -pipe -march=ivybridge -mtune=ivybridge -mfpmath=sse -mmmx -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mavx -mcx16 -mf16c -mfsgsbase -mfxsr -mpclmul -mpopcnt -mrdrnd -msahf -mxsave -mxsaveopt -mvzeroupper -mavx256-split-unaligned-load -mavx256-split-unaligned-store -maccumulate-outgoing-args -fstack-protector-all -fmodulo-sched -fmodulo-sched-allow-regmoves -ftree-loop-im -ftree-loop-linear -ftree-loop-ivcanon -fgcse-after-reload -fgcse-lm -fgcse-sm -fgcse-las -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -ftree-vectorize -flto=10 -fuse-linker-plugin -fstack-check=no -Wl,-O1 -Wl,--as-needed -Wl,-z,now -Wl,-z,relro -Wl,--sort-common -Wl,--hash-style=gnu -Wl,-flto -fno-lto -fno-use-linker-plugin'

Locally applied patches:
    gentoo/hints_hpux - Fix hpux hints
    gentoo/aix_soname - aix gcc detection and shared library soname support
    gentoo/EUMM-RUNPATH - https://bugs.gentoo.org/105054 cpan/ExtUtils-MakeMaker: drop $PORTAGE_TMPDIR from LD_RUN_PATH
    gentoo/config_over - Remove -rpath and append LDFLAGS to lddlflags
    gentoo/opensolaris_headers - Add headers for opensolaris
    gentoo/patchlevel - List packaged patches for perl-5.24.2(#1) in patchlevel.h
    gentoo/cleanup-paths - Cleanup PATH and shrpenv
    gentoo/enc2xs - Tweak enc2xs to follow symlinks and ignore missing @INC directories.
    gentoo/darwin-cc-ld - https://bugs.gentoo.org/297751 darwin: Use $CC to link
    gentoo/cpan_definstalldirs - Provide a sensible INSTALLDIRS default for modules installed from CPAN.
    gentoo/interix - Fix interix hints
    gentoo/create_libperl_soname - https://bugs.gentoo.org/286840 Set libperl soname
    gentoo/mod_paths - Add /etc/perl to @INC
    gentoo/EUMM_perllocalpod - cpan/ExtUtils-MakeMaker: remove targets that generate perllocal.pod
    gentoo/drop_fstack_protector - https://bugs.gentoo.org/348557 Don't force -fstack-protector on everyone
    gentoo/usr_local - Configure: Don't include sources in /usr/local/ for compiling perl
    gentoo/D-SHA-CFLAGS - https://bugs.gentoo.org/506818 Do not set custom CFLAGS in cpan/Digest-SHA
    gentoo/io_socket_ip_tests - cpan/IO-Socket-IP: Disable network tests
    gentoo/cygwin-libperl - Cygwin: avoid libperl.dll.dll.a
    gentoo/tests - Fixup EUMM perlocal.pod tests and customised SHA1s
    gentoo/zlib-1.2.9-backported-fixes - [rt#119762] Compress-Raw-Zlib: backport zlib 1.2.9+ fixes from upstream 2.073
    gentoo/gcc6-lto-configure - [RT#128131] fix symbol detection with gcc 6 link-time optimization
    debian/cpan-missing-site-dirs - Fix CPAN::FirstTime defaults with nonexisting site dirs if a parent is writable
    debian/makemaker-pasthru - Pass LD settings through to subdirectories
    fixes/memoize_storable_nstore - [rt.cpan.org #77790] Memoize::Storable: respect 'nstore' option not respected
    fixes/podman-pipe - Better errors for man pages from standard input
    fixes/respect_umask - Respect umask during installation
    fixes/net_smtp_docs - [rt.cpan.org #36038] Document the Net::SMTP 'Port' option
    fixes/document_makemaker_ccflags - [rt.cpan.org #68613] Document that CCFLAGS should include $Config{ccflags}
    fixes/parallel-manisort.patch - Fix parallel building

---
@INC for perl 5.24.2:
    /etc/perl
    /usr/local/lib64/perl5/5.24.2/x86_64-linux-thread-multi
    /usr/local/lib64/perl5/5.24.2
    /usr/lib64/perl5/vendor_perl/5.24.2/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.24.2
    /usr/local/lib64/perl5
    /usr/lib64/perl5/vendor_perl/5.24.1/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.24.1
    /usr/lib64/perl5/vendor_perl
    /usr/lib64/perl5/5.24.2/x86_64-linux-thread-multi
    /usr/lib64/perl5/5.24.2

---
Environment for perl 5.24.2:
    HOME=/root
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/lib64/rc/bin:/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/lib/colorgcc/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/7.1.0:/usr/x86_64-pc-linux-gnu/mips64-unknown-linux-gnu/gcc-bin/7.1.0:/opt/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 2017

From @tonycoz

On Sun, 23 Jul 2017 11​:57​:47 -0700, kumba@​gentoo.org wrote​:

Compiling >=perl-5.24* with "-mieee-fp" in CFLAGS will cause the below
link-time error​:
/usr/lib/gcc/x86_64-pc-linux-
gnu/7.1.0/../../../../lib64/libieee.a​:(.data+0x0)​: multiple definition
of `_LIB_VERSION'
pp.o​:(.data+0x0)​: first defined here
collect2​: error​: ld returned 1 exit status
make​: *** [makefile​:382​: lib/buildcustomize.pl] Error 1
make​: *** Waiting for unfinished jobs....

Does the attached patch against blead solve it for you?

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 2017

From @tonycoz

0001-perl-131786-avoid-a-duplicate-symbol-error-on-_LIB_V.patch
From 1f8c6189fff2830691e893877be135a1a40f7dd2 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 2 Aug 2017 16:15:06 +1000
Subject: (perl #131786) avoid a duplicate symbol error on _LIB_VERSION

For -flto -mieee-fp builds, the _LIB_VERSION definition in perl.c and
in libieee conflict, causing a build failure.

The test we perform in Configure checks only that such a variable exists
(and is declared), it doesn't check that we can *define* such a variable,
which the code in pp.c tried to do.

So rather than trying to define the variable, just initialize it during
our normal interpreter initialization.
---
 perl.c | 8 ++++++++
 pp.c   | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/perl.c b/perl.c
index 4370f48..563fb3b 100644
--- a/perl.c
+++ b/perl.c
@@ -286,6 +286,14 @@ perl_construct(pTHXx)
     PL_localpatches = local_patches;	/* For possible -v */
 #endif
 
+#if defined(LIBM_LIB_VERSION)
+    /*
+     * Some BSDs and Cygwin default to POSIX math instead of IEEE.
+     * This switches them over to IEEE.
+     */
+    _LIB_VERSION = _IEEE_;
+#endif
+
 #ifdef HAVE_INTERP_INTERN
     sys_intern_init();
 #endif
diff --git a/pp.c b/pp.c
index 8e27eac..46366c3 100644
--- a/pp.c
+++ b/pp.c
@@ -39,14 +39,6 @@
 extern Pid_t getpid (void);
 #endif
 
-/*
- * Some BSDs and Cygwin default to POSIX math instead of IEEE.
- * This switches them over to IEEE.
- */
-#if defined(LIBM_LIB_VERSION)
-    _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
-#endif
-
 static const STRLEN small_mu_len = sizeof(GREEK_SMALL_LETTER_MU_UTF8) - 1;
 static const STRLEN capital_iota_len = sizeof(GREEK_CAPITAL_LETTER_IOTA_UTF8) - 1;
 
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 10, 2017

From @tonycoz

On Tue, 01 Aug 2017 23​:17​:15 -0700, tonyc wrote​:

On Sun, 23 Jul 2017 11​:57​:47 -0700, kumba@​gentoo.org wrote​:

Compiling >=perl-5.24* with "-mieee-fp" in CFLAGS will cause the below
link-time error​:
/usr/lib/gcc/x86_64-pc-linux-
gnu/7.1.0/../../../../lib64/libieee.a​:(.data+0x0)​: multiple definition
of `_LIB_VERSION'
pp.o​:(.data+0x0)​: first defined here
collect2​: error​: ld returned 1 exit status
make​: *** [makefile​:382​: lib/buildcustomize.pl] Error 1
make​: *** Waiting for unfinished jobs....

Does the attached patch against blead solve it for you?

Applied as fa2e459.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 10, 2017

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Jun 11, 2018

From @tonycoz

On Wed, 09 Aug 2017 19​:00​:57 -0700, tonyc wrote​:

Applied as fa2e459.

It turns out this also fixes another issue​:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900739

Tony

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant