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

gcc 6 link-time optimization (LTO) breaks Configure symbol detection (again) #15322

Closed
p5pRT opened this issue May 11, 2016 · 9 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented May 11, 2016

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

Searchable as RT128131$

@p5pRT
Copy link
Author

p5pRT commented May 11, 2016

From @mauke

Created by @mauke

I have gcc 6.1.1. Enabling link-time optimization makes the build fail because
Configure wrongly detects every symbol it tests for as available. It looks like this​:

% ./Configure -Doptimize='-O2 -flto' -Dusedevel -d
...
% make
...
cc -fstack-protector-strong -L/usr/local/lib -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
perl.h​:5806​:41​: warning​: type of ‘PL_nan’ does not match original declaration [-Wlto-type-mismatch]
INFNAN_NV_U8_DECL PL_nan;
  ^
perl.h​:5776​:34​: note​: ‘PL_nan’ was previously declared here
INFNAN_U8_NV_DECL PL_nan = { { DOUBLENANBYTES } };
  ^
perl.h​:5805​:41​: warning​: type of ‘PL_inf’ does not match original declaration [-Wlto-type-mismatch]
INFNAN_NV_U8_DECL PL_inf;
  ^
perl.h​:5740​:34​: note​: ‘PL_inf’ was previously declared here
INFNAN_U8_NV_DECL PL_inf = { { DOUBLEINFBYTES } };
  ^
/tmp/ccANWm8p.ltrans9.ltrans.o​: In function `Perl_more_bodies'​:
<artificial>​:(.text+0x9c3)​: undefined reference to `malloc_good_size'
/tmp/ccANWm8p.ltrans9.ltrans.o​: In function `Perl_sv_usepvn_flags'​:
<artificial>​:(.text+0x5062)​: undefined reference to `malloc_size'
<artificial>​:(.text+0x50e5)​: undefined reference to `malloc_size'
/tmp/ccANWm8p.ltrans25.ltrans.o​: In function `Perl_av_extend_guts'​:
<artificial>​:(.text+0x473b)​: undefined reference to `malloc_size'
/tmp/ccANWm8p.ltrans3.ltrans.o​: In function `PerlIOStdio_close'​:
<artificial>​:(.text+0x251b)​: undefined reference to `fdclose'
/tmp/ccANWm8p.ltrans13.ltrans.o​: In function `Perl_magic_set'​:
<artificial>​:(.text+0x72b6)​: undefined reference to `setproctitle'
<artificial>​:(.text+0x7d3c)​: undefined reference to `setrgid'
<artificial>​:(.text+0x7d4d)​: undefined reference to `setruid'
/tmp/ccANWm8p.ltrans15.ltrans.o​: In function `Perl_find_script.constprop.51'​:
<artificial>​:(.text+0x68e3)​: undefined reference to `strlcpy'
/tmp/ccANWm8p.ltrans16.ltrans.o​: In function `Perl_sv_vcatpvfn_flags.constprop.71'​:
<artificial>​:(.text+0x69f7)​: undefined reference to `isfinitel'
collect2​: error​: ld returned 1 exit status
makefile​:382​: recipe for target 'lib/buildcustomize.pl' failed
make​: *** [lib/buildcustomize.pl] Error 1

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.24.0:

Configured by mauke at Mon May  9 21:21:33 CEST 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=4.4.5-1-arch, archname=i686-linux
    uname='linux simplicio 4.4.5-1-arch #1 smp preempt thu mar 10 07:54:30 cet 2016 i686 gnulinux '
    config_args=''
    hint=previous, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -flto',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='6.1.1 20160501', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12, longdblkind=3
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-fstack-protector-strong -L/usr/local/lib -flto'
    libpth=/usr/local/lib /usr/lib/gcc/i686-pc-linux-gnu/6.1.1/include-fixed /usr/lib /lib /usr/local/lib /usr/lib/gcc/i686-pc-linux-gnu/6.1.1/include-fixed /usr/lib
    libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.23.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.23'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -flto -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.24.0:
    /home/mauke/usr/lib/perl5/site_perl/5.24.0/i686-linux
    /home/mauke/usr/lib/perl5/site_perl/5.24.0
    /home/mauke/usr/lib/perl5/5.24.0/i686-linux
    /home/mauke/usr/lib/perl5/5.24.0
    .


Environment for perl 5.24.0:
    HOME=/home/mauke
    LANG=en_US.UTF-8
    LANGUAGE=en_US
    LC_COLLATE=C
    LC_MONETARY=de_DE.UTF-8
    LC_TIME=de_DE.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/mauke/perl5/perlbrew/bin:/home/mauke/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
    PERLBREW_BASHRC_VERSION=0.73
    PERLBREW_HOME=/home/mauke/.perlbrew
    PERLBREW_ROOT=/home/mauke/perl5/perlbrew
    PERL_BADLANG (unset)
    PERL_UNICODE=SAL
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented May 11, 2016

From @mauke

On Wed May 11 13​:08​:44 2016, mauke- wrote​:

I have gcc 6.1.1. Enabling link-time optimization makes the build fail
because
Configure wrongly detects every symbol it tests for as available. It
looks like this​:

Patch attached.

@p5pRT
Copy link
Author

p5pRT commented May 11, 2016

From @mauke

0001-fix-symbol-detection-with-gcc-6-link-time-optimizati.patch
From 0e77e7b8233f908cb5a343397c7453e9c21ac0db Mon Sep 17 00:00:00 2001
From: Lukas Mai <l.mai@web.de>
Date: Wed, 11 May 2016 22:15:34 +0200
Subject: [PATCH] fix symbol detection with gcc 6 link-time optimization (RT
 #128131)

---
 Configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Configure b/Configure
index 33a6cac..1cd411a 100755
--- a/Configure
+++ b/Configure
@@ -6798,13 +6798,13 @@ yes)
 		if $contains $tlook $tf >/dev/null 2>&1; then
 			tval=true;
 		elif $test "$mistrustnm" = compile -o "$mistrustnm" = run; then
-			echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void *)main) return(0); else return(1); }"> try.c;
+			echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main(int argc, char **argv) { if(p() && p() != (void *)argv[0]) return(0); else return(1); }"> try.c;
 			$cc -o try $optimize $ccflags $ldflags try.c >/dev/null 2>&1 $libs && tval=true;
 			$test "$mistrustnm" = run -a -x try && { $run ./try$_exe >/dev/null 2>&1 || tval=false; };
 			$rm_try;
 		fi;
 	else
-		echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void *)main) return(0); else return(1); }"> try.c;
+		echo "$extern_C void *$1$tdc; void *(*(p()))$tdc { return &$1; } int main(int argc, char **argv) { if(p() && p() != (void *)argv[0]) return(0); else return(1); }"> try.c;
 		$cc -o try $optimize $ccflags $ldflags try.c $libs >/dev/null 2>&1 && tval=true;
 		$rm_try;
 	fi;
-- 
2.8.2

@p5pRT
Copy link
Author

p5pRT commented May 12, 2016

From @doughera88

On Wed, May 11, 2016 at 01​:08​:44PM -0700, l.mai@​web.de (via RT) wrote​:

I have gcc 6.1.1. Enabling link-time optimization makes the build fail because
Configure wrongly detects every symbol it tests for as available. It looks like this​:

Thank you for reporting this. One long-term fix in the next version of
metaconfig is to change the individual compiltion probes to correctly
call the relevant functions. This should ultimately fix this problem,
but I don't have any estimate on when that might land.

% ./Configure -Doptimize='-O2 -flto' -Dusedevel -d

--
  Andy Dougherty doughera@​lafayette.edu

@p5pRT
Copy link
Author

p5pRT commented May 12, 2016

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

@p5pRT
Copy link
Author

p5pRT commented May 14, 2016

From @arc

l.mai@​web.de via RT <perlbug-followup@​perl.org> wrote​:

On Wed May 11 13​:08​:44 2016, mauke- wrote​:

I have gcc 6.1.1. Enabling link-time optimization makes the build fail
because Configure wrongly detects every symbol it tests for as
available. It looks like this​:

Patch attached.

Thanks, applied as adec5bb, and
backported to metaconfig.git as
441695c09aebf58c88b0c9d0c42600fae89ce436.

For the benefit of anyone reading this in the future​: on a current
Debian testing ("Stretch") system, where AFAIK the default compiler is
GCC 5 but GCC 6 is available as an option, I also had to Configure
-Dar=gcc-ar-6 to get the build to succeed. Without that, building
libperl.a produced errors like this​:

/usr/bin/ar rc libperl.a op.o perl.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 DynaLoader.o
/usr/bin/ar​: op.o​: plugin needed to handle lto object
/usr/bin/ar​: perl.o​: plugin needed to handle lto object
/usr/bin/ar​: gv.o​: plugin needed to handle lto object
<snip>

So it's possible that further changes will be needed to support LTO,
in the absence of the probe changes that Andy refers to.

--
Aaron Crane ** http​://aaroncrane.co.uk/

@p5pRT
Copy link
Author

p5pRT commented May 14, 2016

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

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

From @khwilliamson

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

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

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

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

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

@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