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

perl 5.20.2 fails to compile with gcc 5.1.0 -flto -O2 #14689

Closed
p5pRT opened this issue May 4, 2015 · 11 comments
Closed

perl 5.20.2 fails to compile with gcc 5.1.0 -flto -O2 #14689

p5pRT opened this issue May 4, 2015 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented May 4, 2015

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

Searchable as RT125096$

@p5pRT
Copy link
Author

p5pRT commented May 4, 2015

From steffen@hauihau.de

Created by steffen@hauihau.de

Compiling perl 5.20.2 with GCC 5.1.0 reintroduced the issue reported in bug #113022. I was told, that you should use "__attribute__ ((used))" to check for the availability of functions. This small patch fixes the issue​:

Inline Patch
--- a/Configure.orig	2015-05-04 11:51:34.170517546 +0200
+++ b/Configure	2015-05-04 11:51:58.025516693 +0200
@@ -7954,13 +7954,13 @@
 		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; __attribute__ ((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void *)main) 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; __attribute__ ((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void *)main) 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;
Perl Info

Flags:
    category=install
    severity=low

Site configuration information for perl 5.20.2:

Configured by Gentoo at Tue Apr 28 18:25:50 CEST 2015.

Summary of my perl5 (revision 5 version 20 subversion 2) configuration:
   
  Platform:
    osname=linux, osvers=4.0.0-hauihau, archname=x86_64-linux
    uname='linux schlepptop 4.0.0-hauihau #1 smp preempt mon apr 13 14:35:51 cest 2015 x86_64 intel(r) core(tm) i7-2620m cpu @ 2.70ghz genuineintel gnulinux '
    config_args='-des -Duseshrplib -Darchname=x86_64-linux -Dcc=x86_64-pc-linux-gnu-gcc -Doptimize=-march=native -O2 -pipe -ggdb -floop-interchange -floop-strip-mine -floop-block -ftree-loop-distribution -fira-loop-pressure -ftree-vectorize -ftree-loop-linear -flto=5 -fuse-linker-plugin -fno-lto -Dldflags=-Wl,-O1 -Wl,--as-needed -march=native -O2 -pipe -ggdb -floop-interchange -floop-strip-mine -floop-block -ftree-loop-distribution -fira-loop-pressure -ftree-vectorize -ftree-loop-linear -flto=5 -fuse-linker-plugin -Wl,-znow -Wl,--sort-common -Wl,--hash-style=gnu -Wl,--enable-new-dtags -fno-lto -Dprefix=/usr -Dinstallprefix=/usr -Dsiteprefix=/usr/local -Dvendorprefix=/usr -Dscriptdir=/usr/bin -Dprivlib=/usr/lib64/perl5/5.20.2 -Darchlib=/usr/lib64/perl5/5.20.2/x86_64-linux -Dsitelib=/usr/local/lib64/perl5/5.20.2 -Dsitearch=/usr/local/lib64/perl5/5.20.2/x86_64-linux -Dvendorlib=/usr/lib64/perl5/vendor_perl/5.20.2 -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.20.2/x86_64-linux -Dman1dir=/u
 sr/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.20.2 -Dlocincpth=/usr/include  -Dglibpth=/lib64 /usr/lib64  -Duselargefiles -Dd_semctl_semun -Dcf_by=Gentoo -Dmyhostname=localhost -Dperladmin=root@localhost -Dinstallusrbinperl=n -Ud_csh -Uusenm -Di_ndbm -Di_gdbm -Di_db -DDEBUGGING=-g -Dinc_version_list=5.20.0/x86_64-linux 5.20.0 5.20.1/x86_64-linux 5.20.1  -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dnoextensions=ODBM_File'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='x86_64-pc-linux-gnu-gcc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-march=native -O2 -pipe -ggdb -floop-interchange -floop-strip-mine -floop-block -ftree-loop-distribution -fira-loop-pressure -ftree-vectorize -ftree-loop-linear -flto=5 -fuse-linker-plugin -fno-lto',
    cppflags='-fwrapv -fno-strict-aliasing -pipe'
    ccversion='', gccversion='5.1.0', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    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 ='-Wl,-O1 -Wl,--as-needed -march=native -O2 -pipe -ggdb -floop-interchange -floop-strip-mine -floop-block -ftree-loop-distribution -fira-loop-pressure -ftree-vectorize -ftree-loop-linear -flto=5 -fuse-linker-plugin -Wl,-znow -Wl,--sort-common -Wl,--hash-style=gnu -Wl,--enable-new-dtags -fno-lto'
    libpth=/usr/local/lib64 /lib64 /usr/lib64 /usr/lib/gcc/x86_64-pc-linux-gnu/5.1.0/include-fixed /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib
    libs=-lnsl -lnm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -lnm -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.20.so, so=so, useshrplib=true, libperl=libperl.so.5.20.2
    gnulibc_version='2.20'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -march=native -O2 -pipe -ggdb -floop-interchange -floop-strip-mine -floop-block -ftree-loop-distribution -fira-loop-pressure -ftree-vectorize -ftree-loop-linear -flto=5 -fuse-linker-plugin -fno-lto -Wl,-O1 -Wl,--as-needed -march=native -O2 -pipe -ggdb -floop-interchange -floop-strip-mine -floop-block -ftree-loop-distribution -fira-loop-pressure -ftree-vectorize -ftree-loop-linear -flto=5 -fuse-linker-plugin -Wl,-znow -Wl,--sort-common -Wl,--hash-style=gnu -Wl,--enable-new-dtags -fno-lto'

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 - [PATCH] Add headers for opensolaris
    gentoo/patchlevel - List packaged patches for perl-5.20.2(#1) in patchlevel.h
    gentoo/cpanplus_definstalldirs - Configure CPANPLUS to use the site directories by default.
    gentoo/cleanup-paths - [PATCH] Cleanup PATH and shrpenv
    gentoo/enc2xs - Tweak enc2xs to follow symlinks and ignore missing @INC directories.
    gentoo/enc2xs_checksums -
    gentoo/darwin-cc-ld - https://bugs.gentoo.org/297751 [PATCH] darwin: Use $CC to link
    gentoo/cpan_definstalldirs - Provide a sensible INSTALLDIRS default for modules installed from CPAN.
    gentoo/interix - [PATCH] Fix interix hints
    gentoo/create_libperl_soname - https://bugs.gentoo.org/286840 [PATCH] Set libperl soname
    gentoo/mod_paths - Add /etc/perl to @INC
    gentoo/EUMM_delete_packlist -
    gentoo/drop_fstack_protector - https://bugs.gentoo.org/348557 [PATCH] Don't force -fstack-protector on everyone
    gentoo/usr_local - [PATCH] Remove /usr/local paths
    gentoo/D-SHA-CFLAGS - https://bugs.gentoo.org/506818 [PATCH] Do not set custom CFLAGS in cpan/Digest-SHA
    gentoo/io_socket_ip_tests -
    debian/cpan-missing-site-dirs - Fix CPAN::FirstTime defaults with nonexisting site dirs if a parent is writable
    debian/regcomp-mips-optim - Downgrade the optimization of regcomp.c on mips and mipsel due to a gcc-4.9 bug
    debian/perldoc-less-R - Tell the 'less' pager to allow terminal escape sequences
    debian/makemaker-pasthru - Pass LD settings through to subdirectories
    fixes/net_smtp_docs - [rt.cpan.org #36038] Document the Net::SMTP 'Port' option
    fixes/memoize_storable_nstore - [rt.cpan.org #77790] Memoize::Storable: respect 'nstore' option not respected
    fixes/document_makemaker_ccflags - [rt.cpan.org #68613] Document that CCFLAGS should include $Config{ccflags}


@INC for perl 5.20.2:
    /etc/perl
    /usr/local/lib64/perl5/5.20.2/x86_64-linux
    /usr/local/lib64/perl5/5.20.2
    /usr/lib64/perl5/vendor_perl/5.20.2/x86_64-linux
    /usr/lib64/perl5/vendor_perl/5.20.2
    /usr/local/lib64/perl5
    /usr/lib64/perl5/vendor_perl/5.20.1
    /usr/lib64/perl5/vendor_perl
    /usr/lib64/perl5/5.20.2/x86_64-linux
    /usr/lib64/perl5/5.20.2
    .


Environment for perl 5.20.2:
    HOME=/home/steffen
    LANG=de_DE.utf8
    LANGUAGE (unset)
    LC_ALL=de_DE.utf8
    LC_MEASUREMENT=de_DE.utf8
    LC_MONETARY=de_DE.utf8
    LC_NUMERIC=de_DE.utf8
    LC_PAPER=de_DE.utf8
    LC_TIME=de_DE.utf8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/steffen/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/5.1.0
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented May 7, 2015

From @tonycoz

On Mon May 04 03​:02​:16 2015, steffen@​hauihau.de wrote​:

Compiling perl 5.20.2 with GCC 5.1.0 reintroduced the issue reported
in bug #113022. I was told, that you should use "__attribute__
((used))" to check for the availability of functions. This small patch
fixes the issue​:

--- a/Configure.orig 2015-05-04 11​:51​:34.170517546 +0200
+++ b/Configure 2015-05-04 11​:51​:58.025516693 +0200
@​@​ -7954,13 +7954,13 @​@​
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; __attribute__
((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p() && p()
!= (void *)main) 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; __attribute__ ((used))
void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void
*)main) 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;

Not every compiler supports gcc's extensions, so we need to probe for
__attribute__ ((used)) before we use it.

The attached patch is against bleadperl, detected __attribute__((used)), and if
found uses it in the csym code.

If you want to test this againt 5.20 you should be able to copy Configure from blead and apply that patch to it, or copy Configure from​:

http​://perl5.git.perl.org/perl.git/blob_plain/refs/heads/tonyc/attribute-used​:/Configure

I couldn't reproduce the problem you were having however - with your options with gcc 5.1.0 malloc_size wasn't being detected (Debian oldstable.)

Tony

@p5pRT
Copy link
Author

p5pRT commented May 7, 2015

From @tonycoz

0001-perl-125096-detect-attribute-used-and-use-it.patch
From f65b96ad9dca9dcda19fe9a85ffd5d27811d2961 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 7 May 2015 10:44:39 +1000
Subject: [PATCH] [perl #125096] detect attribute used and use it

gcc with -O2 -flto builds can optimize out all the references to
the function we're probing for, mark the function as used to
avoid that.
---
 Configure |   36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/Configure b/Configure
index 0a405d3..98cb7fe 100755
--- a/Configure
+++ b/Configure
@@ -388,6 +388,7 @@ d_attribute_nonnull=''
 d_attribute_noreturn=''
 d_attribute_pure=''
 d_attribute_unused=''
+d_attribute_used=''
 d_attribute_warn_unused_result=''
 d_printf_format_null=''
 d_backtrace=''
@@ -6737,6 +6738,10 @@ case "$3" in
 -a) tf=libc.tmp; tdc="[]";;
 *) tlook="^$1\$"; tf=libc.list; tdc="()";;
 esac;
+case "$d_attribute_used" in
+    define) attrused="__attribute__ ((used))" ;;
+    *)      attrused= ;;
+esac;
 case "$d_cplusplus" in
     $define)	extern_C="extern \"C\""	;;
     *)		extern_C="extern"	;;
@@ -6753,7 +6758,7 @@ 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; $attrused void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void *)main) 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;
@@ -6852,6 +6857,34 @@ $rm_try
 set d_longdbl
 eval $setvar
 
+: Look for GCC-style attribute used
+case "$d_attribute_used" in
+'')
+echo " "
+echo "Checking whether your compiler can handle __attribute__((used)) ..." >&4
+$cat >attrib.c <<'EOCP'
+#include <stdio.h>
+int used_somewhere(void) __attribute__((used));
+EOCP
+if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
+	if $contains 'warning' attrib.out >/dev/null 2>&1; then
+		echo "Your C compiler doesn't support __attribute__((used))."
+		val="$undef"
+	else
+		echo "Your C compiler supports __attribute__((used))."
+		val="$define"
+	fi
+else
+	echo "Your C compiler doesn't seem to understand __attribute__ at all."
+	val="$undef"
+fi
+;;
+*) val="$d_attribute_used" ;;
+esac
+set d_attribute_used
+eval $setvar
+$rm -f attrib*
+
 : see if ldexpl exists
 set ldexpl d_ldexpl
 eval $inlibc
@@ -23793,6 +23826,7 @@ d_attribute_nonnull='$d_attribute_nonnull'
 d_attribute_noreturn='$d_attribute_noreturn'
 d_attribute_pure='$d_attribute_pure'
 d_attribute_unused='$d_attribute_unused'
+d_attribute_used='$d_attribute_used'
 d_attribute_warn_unused_result='$d_attribute_warn_unused_result'
 d_backtrace='$d_backtrace'
 d_bcmp='$d_bcmp'
-- 
1.7.10.4

@p5pRT
Copy link
Author

p5pRT commented May 7, 2015

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

@p5pRT
Copy link
Author

p5pRT commented May 7, 2015

From @Tux

On Wed, 6 May 2015 17​:49​:27 -0700, "Tony Cook via RT"
<perlbug-followup@​perl.org> wrote​:

On Mon May 04 03​:02​:16 2015, steffen@​hauihau.de wrote​:

Compiling perl 5.20.2 with GCC 5.1.0 reintroduced the issue reported
in bug #113022. I was told, that you should use "__attribute__
((used))" to check for the availability of functions. This small patch
fixes the issue​:

--- a/Configure.orig 2015-05-04 11​:51​:34.170517546 +0200
+++ b/Configure 2015-05-04 11​:51​:58.025516693 +0200
@​@​ -7954,13 +7954,13 @​@​
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; __attribute__
((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p() && p()
!= (void *)main) 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; __attribute__ ((used))
void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void
*)main) 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;

Not every compiler supports gcc's extensions, so we need to probe for
__attribute__ ((used)) before we use it.

The attached patch is against bleadperl, detected __attribute__((used)), and if
found uses it in the csym code.

If you want to test this againt 5.20 you should be able to copy Configure from blead and apply that patch to it, or copy Configure from​:

http​://perl5.git.perl.org/perl.git/blob_plain/refs/heads/tonyc/attribute-used​:/Configure

I couldn't reproduce the problem you were having however - with your options with gcc 5.1.0 malloc_size wasn't being detected (Debian oldstable.)

Tony

[ Not high priority, as this involves *A LOT* of work ]

There are plans to move the meta/dist framework towards a newer version
As perl has modified quite a lot of the underlying meta-units, this may
cause hundreds of units to change *and check* before such an
integration can be accepted.

That said, here's the feedback from the future :)

--8<---
The current dist (SVN version, not yet found the time / inclination
to migrate to git) has switched to compile-time tests whenever
possible since 2008.

In particular, the current intsize.U unit uses "static asserts"
to detect through compile-time errors whether an assertion holds.
This allows to compute the size of all types via compile tests,
without having to run anything.

Even IEEE float endianness is now determined without running a program.
No static assert here however​: look at d_ieee754.U.

The rationale for moving out of run-tests is that it prevents
cross-compilation to occur. But when you cross-compile, you
always have a compiler handy... Since at some point I had to
cross-compile gtk-gnutella with MinGW, I had to move away from
run-tests as much as possible!
-->8---

As I do not have unlimited resources, and if I had they were to be
shared amongst several other areas of interest, this might take some
time to settle.

In summary, Yes, moving to compile-only is a good plan and certainly an
improvement once done, but I rather start from upriver and pick piece
by piece, giving feedback upriver so future differences stay low and
maintenance cost are not raised by every change.

--
H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/
using perl5.00307 .. 5.21 porting perl5 on HP-UX, AIX, and openSUSE
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/
http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

@p5pRT
Copy link
Author

p5pRT commented May 7, 2015

From steffen@hauihau.de

Am 07.05.2015 um 02​:49 schrieb Tony Cook via RT​:

On Mon May 04 03​:02​:16 2015, steffen@​hauihau.de wrote​:

Compiling perl 5.20.2 with GCC 5.1.0 reintroduced the issue reported
in bug #113022. I was told, that you should use "__attribute__
((used))" to check for the availability of functions. This small patch
fixes the issue​:

--- a/Configure.orig 2015-05-04 11​:51​:34.170517546 +0200
+++ b/Configure 2015-05-04 11​:51​:58.025516693 +0200
@​@​ -7954,13 +7954,13 @​@​
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; __attribute__
((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p() && p()
!= (void *)main) 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; __attribute__ ((used))
void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() != (void
*)main) 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;

Not every compiler supports gcc's extensions, so we need to probe for
__attribute__ ((used)) before we use it.

The attached patch is against bleadperl, detected __attribute__((used)), and if
found uses it in the csym code.

If you want to test this againt 5.20 you should be able to copy Configure from blead and apply that patch to it, or copy Configure from​:

http​://perl5.git.perl.org/perl.git/blob_plain/refs/heads/tonyc/attribute-used​:/Configure

I couldn't reproduce the problem you were having however - with your options with gcc 5.1.0 malloc_size wasn't being detected (Debian oldstable.)

Tony

Hi Tony,

your patch does not cleanly apply (hunk #4 must be after #1). After
adjusting this, the functions are still found. You forgot to patch the
else section, which gets executed when $runnm is false (which was the
case on my system). After I fixed this as well, your patch makes perl
compile successfully.

@p5pRT
Copy link
Author

p5pRT commented May 7, 2015

From steffen@hauihau.de

Am 07.05.2015 um 08​:35 schrieb H. Merijn Brand via RT​:

[ Not high priority, as this involves *A LOT* of work ]

There are plans to move the meta/dist framework towards a newer version
As perl has modified quite a lot of the underlying meta-units, this may
cause hundreds of units to change *and check* before such an
integration can be accepted.

That said, here's the feedback from the future :)

--8<---
The current dist (SVN version, not yet found the time / inclination
to migrate to git) has switched to compile-time tests whenever
possible since 2008.

In particular, the current intsize.U unit uses "static asserts"
to detect through compile-time errors whether an assertion holds.
This allows to compute the size of all types via compile tests,
without having to run anything.

Even IEEE float endianness is now determined without running a program.
No static assert here however​: look at d_ieee754.U.

The rationale for moving out of run-tests is that it prevents
cross-compilation to occur. But when you cross-compile, you
always have a compiler handy... Since at some point I had to
cross-compile gtk-gnutella with MinGW, I had to move away from
run-tests as much as possible!
-->8---

As I do not have unlimited resources, and if I had they were to be
shared amongst several other areas of interest, this might take some
time to settle.

In summary, Yes, moving to compile-only is a good plan and certainly an
improvement once done, but I rather start from upriver and pick piece
by piece, giving feedback upriver so future differences stay low and
maintenance cost are not raised by every change.

The fix is a trivial change, so please include it in the next release.

@p5pRT
Copy link
Author

p5pRT commented Dec 9, 2015

From @jkeenan

On Thu May 07 09​:01​:57 2015, steffen@​hauihau.de wrote​:

Am 07.05.2015 um 02​:49 schrieb Tony Cook via RT​:

On Mon May 04 03​:02​:16 2015, steffen@​hauihau.de wrote​:

Compiling perl 5.20.2 with GCC 5.1.0 reintroduced the issue reported
in bug #113022. I was told, that you should use "__attribute__
((used))" to check for the availability of functions. This small
patch
fixes the issue​:

--- a/Configure.orig 2015-05-04 11​:51​:34.170517546 +0200
+++ b/Configure 2015-05-04 11​:51​:58.025516693 +0200
@​@​ -7954,13 +7954,13 @​@​
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; __attribute__
((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p() &&
p()
!= (void *)main) 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; __attribute__ ((used))
void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() !=
(void
*)main) 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;

Not every compiler supports gcc's extensions, so we need to probe for
__attribute__ ((used)) before we use it.

The attached patch is against bleadperl, detected
__attribute__((used)), and if
found uses it in the csym code.

If you want to test this againt 5.20 you should be able to copy
Configure from blead and apply that patch to it, or copy Configure
from​:

http​://perl5.git.perl.org/perl.git/blob_plain/refs/heads/tonyc/attribute-
used​:/Configure

I couldn't reproduce the problem you were having however - with your
options with gcc 5.1.0 malloc_size wasn't being detected (Debian
oldstable.)

Tony

Hi Tony,

your patch does not cleanly apply (hunk #4 must be after #1). After
adjusting this, the functions are still found. You forgot to patch the
else section, which gets executed when $runnm is false (which was the
case on my system). After I fixed this as well, your patch makes perl
compile successfully.

Tony​: Could we get an update on the status of this ticket?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jul 10, 2019

From @tonycoz

On Wed, 09 Dec 2015 15​:53​:32 -0800, jkeenan wrote​:

On Thu May 07 09​:01​:57 2015, steffen@​hauihau.de wrote​:

Am 07.05.2015 um 02​:49 schrieb Tony Cook via RT​:

On Mon May 04 03​:02​:16 2015, steffen@​hauihau.de wrote​:

Compiling perl 5.20.2 with GCC 5.1.0 reintroduced the issue
reported
in bug #113022. I was told, that you should use "__attribute__
((used))" to check for the availability of functions. This small
patch
fixes the issue​:

--- a/Configure.orig 2015-05-04 11​:51​:34.170517546 +0200
+++ b/Configure 2015-05-04 11​:51​:58.025516693 +0200
@​@​ -7954,13 +7954,13 @​@​
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;
__attribute__
((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p() &&
p()
!= (void *)main) 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; __attribute__
((used))
void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() !=
(void
*)main) 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;

Not every compiler supports gcc's extensions, so we need to probe
for
__attribute__ ((used)) before we use it.

The attached patch is against bleadperl, detected
__attribute__((used)), and if
found uses it in the csym code.

If you want to test this againt 5.20 you should be able to copy
Configure from blead and apply that patch to it, or copy Configure
from​:

http​://perl5.git.perl.org/perl.git/blob_plain/refs/heads/tonyc/attribute-
used​:/Configure

I couldn't reproduce the problem you were having however - with
your
options with gcc 5.1.0 malloc_size wasn't being detected (Debian
oldstable.)

Tony

Hi Tony,

your patch does not cleanly apply (hunk #4 must be after #1). After
adjusting this, the functions are still found. You forgot to patch
the
else section, which gets executed when $runnm is false (which was the
case on my system). After I fixed this as well, your patch makes perl
compile successfully.

Tony​: Could we get an update on the status of this ticket?

Thank you very much.

I believe this was fixed in a different way by adec5bb.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2019

From @tonycoz

On Tue, 09 Jul 2019 21​:26​:06 -0700, tonyc wrote​:

On Wed, 09 Dec 2015 15​:53​:32 -0800, jkeenan wrote​:

On Thu May 07 09​:01​:57 2015, steffen@​hauihau.de wrote​:

Am 07.05.2015 um 02​:49 schrieb Tony Cook via RT​:

On Mon May 04 03​:02​:16 2015, steffen@​hauihau.de wrote​:

Compiling perl 5.20.2 with GCC 5.1.0 reintroduced the issue
reported
in bug #113022. I was told, that you should use "__attribute__
((used))" to check for the availability of functions. This small
patch
fixes the issue​:

--- a/Configure.orig 2015-05-04 11​:51​:34.170517546 +0200
+++ b/Configure 2015-05-04 11​:51​:58.025516693 +0200
@​@​ -7954,13 +7954,13 @​@​
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;
__attribute__
((used)) void *(*(p()))$tdc { return &$1; } int main() { if(p()
&&
p()
!= (void *)main) 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; __attribute__
((used))
void *(*(p()))$tdc { return &$1; } int main() { if(p() && p() !=
(void
*)main) 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;

Not every compiler supports gcc's extensions, so we need to probe
for
__attribute__ ((used)) before we use it.

The attached patch is against bleadperl, detected
__attribute__((used)), and if
found uses it in the csym code.

If you want to test this againt 5.20 you should be able to copy
Configure from blead and apply that patch to it, or copy
Configure
from​:

http​://perl5.git.perl.org/perl.git/blob_plain/refs/heads/tonyc/attribute-
used​:/Configure

I couldn't reproduce the problem you were having however - with
your
options with gcc 5.1.0 malloc_size wasn't being detected (Debian
oldstable.)

Tony

Hi Tony,

your patch does not cleanly apply (hunk #4 must be after #1). After
adjusting this, the functions are still found. You forgot to patch
the
else section, which gets executed when $runnm is false (which was
the
case on my system). After I fixed this as well, your patch makes
perl
compile successfully.

Tony​: Could we get an update on the status of this ticket?

Thank you very much.

I believe this was fixed in a different way by
adec5bb.

I've looked over it again and I still think so, so closing.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2019

@tonycoz - Status changed from 'open' 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