This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix Configure's csym test for gcc's link time optimisation
authorH.Merijn Brand <merijn@lx09.procura.nl>
Mon, 22 Aug 2011 13:41:46 +0000 (15:41 +0200)
committerH.Merijn Brand <merijn@lx09.procura.nl>
Mon, 22 Aug 2011 13:41:46 +0000 (15:41 +0200)
This introduces a volatile into the test program so gcc cannot optimise
out the symbol itself as being unused.

U/compline/Csym.U [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index c9bef1c..8648d5a
@@ -97,13 +97,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()) return(0); else return(1); }"> try.c;
+                       echo "volatile int dummy = 0; $extern_C void *$1$tdc; void *(*(p()))$tdc { return dummy + &$1; } int main() { if(p()) 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()) return(0); else return(1); }"> try.c;
+               echo "volatile int dummy = 0; $extern_C void *$1$tdc; void *(*(p()))$tdc { return dummy + &$1; } int main() { if(p()) 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;