Closed kentfredric closed 7 years ago
MakeMaker has no concept of LTO, and doesn't take it into account when statically linking a library. Setting the ar
/full_ar
configuration entries to gcc-ar when enabling -flto
should help.
@kentfredric what's the output of perl -MConfig -E 'say $Config{ar}; say $Config{full_ar}'
on the box in question?
perl -MConfig -E 'say $Config{ar}; say $Config{full_ar}'
ar
/usr/bin/ar
However, I've tried numerous things getting it to work:
AR=x86_64-pc-linux-gnu-ar
( This is the result of a query function to ask for the users full AR )CFLAGS
like -fno-lto
as OPTIMIZE=
( doesn't work because Perl's flags come afterwards, usurping them )CFLAGS/LDFLAGS
to make ( doesn't work because you hardcode perls cflags in the makefile )AR_STATIC_ARGS="cr --plugin liblto_plugin.so"
# this of course doesn't work because the plugin path is not fully qualified, but I don't know how to generically do this on whatever compiler / version the end user has.None of which have gotten my anywhere
Could you please try the latest master
?
Excellent. That works :) :+1:
fix released as CryptX-0.046
Thanks for your time
@Leont On some other platforms that might need to be llvm-ar (conjecture, not verified)
what about 86cab48 (removing -flto)?
@kentfredric could you please test again the latest master?
git --no-pager log --oneline -1
86cab48 remove -flto
git clean -fdx
...
etc
...
All tests successful.
Files=101, Tests=23414, 26 wallclock secs ( 3.85 usr 0.46 sys + 23.24 cusr 1.57 csys = 29.12 CPU)
Result: PASS
Great!
It seems safer to go this way (stripping -flto).
what about 86cab48 (removing -flto)?
That's sounds safe and sane.
The alternative is that people with -flto
in their flags should also have their ar
set to match. The default can be fixed in perl core, but that's unlikely to happen before 5.28. I'm expecting this sort of issue nt to be unique to this distribution.
released as CryptX-0.047
FYI I've just fixed this now in cperl: Required changes were on Configure to properly set the arflags (with the full plugin path), and the llvm-ar, plus EUMM to set AR_STATIC_ARGS to be based on arflags, not hardcoded to 'cr'.
perl5 is totally not lto ready, cperl just switched now to -flto by default. So you were right to strip -flto.
you can work around this in modern perls by changing compile flags for perl itself to set config correctly. I'm able to build perl and 800 cpan modules with LTO
Configure -ders -Accflags='-Dar=gcc-ar -Dnm=gcc-nm ...'
I've fixed that in cperl, btw
I've been able to get both perl interpreter and cpan modules to compile with LTO and our own optimization flags. The only one out of 800 I had a problem with is URI::XS because it uses CMake and I can't figure out how to configure ranlib to be gcc-ranlib. Perl Config sets it to ':' unlike nm/ar and setting it to a real value causes mod_perl build to fail
Unfortunately cperl is too many revs back since we try to keep up to the latest, even when we don't necessarily use modern features. We are migrating to signatures and 'use v5.36' implicit warnings/strict though. 5.38 has some perf improvements too
Perf is our biggest concern so are there any commits that makes substantial improvements w/o breaking compatibility? We can patch our builds and have taken a few early fixes (not failing on int wrap and fixing resource copying on clones for example)
When perl 5.24.1 is compiled with -flto
Compile stage emits:
And tests fail:
This may be related to compiling perl with GCC6, which itself needed this patch to work: https://raw.githubusercontent.com/gentoo-perl/perl-patchset/perl-5.24/patches/gentoo/gcc6-lto-configure.diff
However, switching back to GCC5 to compile CryptX does not resolve the problem.
Its not clear at this stage to me where the problem lies, but it may be partly --as-needed also to blame.
But I'd hazard to guess that the missing symbol being saferp_desc indicates a link-ordering or symbol visibility bug.
I don't have much experience with LTO bugs , and I only test this configuration now because an end-user of ours reported it: https://bugs.gentoo.org/583532 , some reports indicate the issue is using "ar" instead of "gcc-ar", but I'm not sure where that comes from ( http://stackoverflow.com/questions/39236917/using-gccs-link-time-optimization-with-static-linked-libraries )
This may even be a bug for EUMM as I've seen a similar compile error to this in the last week