Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Config sets optimisation compilation flags (-O/-g)!by bliako (Monsignor) |
on Jan 28, 2019 at 17:41 UTC ( [id://1229081]=perlquestion: print w/replies, xml ) | Need Help?? |
bliako has asked for the wisdom of the Perl Monks concerning the following question: When compiling C embeding Perl scripts one is better to use the compilation flags (CFLAGS/LDFLAGS) and compiler suggested by Config and ExtUtils::Embed (which derives them from former) like so:
In my system (Config v5.026002, Perl v5.26.2 + updated linux) I have just noticed that suggested CFLAGS include optimisation flags -g -O2 which void completely any optimisation flags I may want to use. For example I was trying to debug a script embeded in a C program and kept getting:
Until I realised what was going on and spent another hour trying to remove them using Gnu make's primitive string-substitution options*. I mean, I am not used to tell my computer:
and still to get optimised-out code in the debugger! Should this behaviour be filed as a bug with Config and if yes, where does one file bugs for that module? bw, bliako *) To cut my losses I finally resorted to gsed rendering my dist completely un-portable. Perl should be better choice. Update:I will mention that there is an m4 macro which returns Perl's compiled CFLAGS etc. This is in the case when one has a C project which embeds a Perl interpreter and one does not want to use a Perl Makefile.PL but want to use Gnu Autotools. So the macro is AX_PERL_EXT (https://www.gnu.org/software/autoconf-archive/ax_perl_ext.html). When one uses it in a configure.ac file like AX_PERL_EXT(0.0) various variables will be created like PERL_EXT_LDFLAGS which one can use in the various Makefile.am of the project. Based on that macro, other macros can be created to filter out unwanted optimisations inside the Perl oneline, thus avoiding the need to do string substs using Makefile ancient ways. It was a long learning curve so I thought it's worth "polluting" this little corner of the Monastery.
Back to
Seekers of Perl Wisdom
|
|