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
Comments
From steffen@hauihau.deCreated by steffen@hauihau.deCompiling 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
|
From @tonycozOn Mon May 04 03:02:16 2015, steffen@hauihau.de wrote:
Not every compiler supports gcc's extensions, so we need to probe for The attached patch is against bleadperl, detected __attribute__((used)), and if 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 |
From @tonycoz0001-perl-125096-detect-attribute-used-and-use-it.patchFrom 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
|
The RT System itself - Status changed from 'new' to 'open' |
From @TuxOn Wed, 6 May 2015 17:49:27 -0700, "Tony Cook 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 That said, here's the feedback from the future :) --8<--- In particular, the current intsize.U unit uses "static asserts" Even IEEE float endianness is now determined without running a program. The rationale for moving out of run-tests is that it prevents As I do not have unlimited resources, and if I had they were to be In summary, Yes, moving to compile-only is a good plan and certainly an -- |
From steffen@hauihau.deAm 07.05.2015 um 02:49 schrieb Tony Cook via RT:
Hi Tony, your patch does not cleanly apply (hunk #4 must be after #1). After |
From steffen@hauihau.deAm 07.05.2015 um 08:35 schrieb H. Merijn Brand via RT:
The fix is a trivial change, so please include it in the next release. |
From @jkeenanOn Thu May 07 09:01:57 2015, steffen@hauihau.de wrote:
Tony: Could we get an update on the status of this ticket? Thank you very much. -- |
From @tonycozOn Wed, 09 Dec 2015 15:53:32 -0800, jkeenan wrote:
I believe this was fixed in a different way by adec5bb. Tony |
From @tonycozOn Tue, 09 Jul 2019 21:26:06 -0700, tonyc wrote:
I've looked over it again and I still think so, so closing. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#125096 (status was 'resolved')
Searchable as RT125096$
The text was updated successfully, but these errors were encountered: