Sa-compile must be run in advance, in order to compile the ruleset using re2c and the C compiler.
This plugin will use native-code object files representing the ruleset, in order to provide significant speedups in rule evaluation.
// RHEL/Centos/AlmaLinux
yum install gcc re2c make perl-ExtUtils-MakeMaker
// Debian/Ubuntu
apt-get install gcc re2c make sa-compile
Edit the file /etc/mail/spamassassin/v320.pre
and remove the comment to enable the Rule2XSBody plugin
# Rule2XSBody - speedup by compilation of ruleset to native code
#
loadplugin Mail::SpamAssassin::Plugin::Rule2XSBody
You can test to see if the rules compile sucessfully by running the command:
/usr/bin/sa-compile
You should see it compile the rules and copy them to your spamassassin compiled rules directory.
With Rule2XSBody enabled when restarting Spamassassin you might see this if SELinux is enabled:
Oct 29 10:28:25 web spamd[19433]: logger: removing stderr method
Oct 29 10:28:27 web spamd[19477]: Can't load '/var/lib/spamassassin/compiled/5.016/3.004002/auto/Mail/SpamAssassin/CompiledRegexps/body_0/body_0.so' for module Mail::SpamAssassin::CompiledRegexps::body_0: /var/lib/spamassassin/compiled/5.016/3.004002/auto/Mail/SpamAssassin/CompiledRegexps/body_0/body_0.so: failed to map segment from shared object: Permission denied at /usr/share/perl5/XSLoader.pm line 68.
Oct 29 10:28:27 web spamd[19477]: at /var/lib/spamassassin/compiled/5.016/3.004002/Mail/SpamAssassin/CompiledRegexps/body_0.pm line 364.
Oct 29 10:28:27 web spamd[19477]: Can't load '/var/lib/spamassassin/compiled/5.016/3.004002/auto/Mail/SpamAssassin/CompiledRegexps/body_0/body_0.so' for module Mail::SpamAssassin::CompiledRegexps::body_0: /var/lib/spamassassin/compiled/5.016/3.004002/auto/Mail/SpamAssassin/CompiledRegexps/body_0/body_0.so: failed to map segment from shared object: Permission denied at /usr/share/perl5/XSLoader.pm line 68.
Oct 29 10:28:27 web spamd[19477]: at /var/lib/spamassassin/compiled/5.016/3.004002/Mail/SpamAssassin/CompiledRegexps/body_0.pm line 364.
Oct 29 10:28:27 web spamd[19477]: BEGIN failed--compilation aborted at /var/lib/spamassassin/compiled/5.016/3.004002/Mail/SpamAssassin/CompiledRegexps/body_0.pm line 365.
Oct 29 10:28:27 web spamd[19477]: Compilation failed in require at (eval 1591) line 1.
The fix is to re-apply the SELinux labels on the /var/lib/spamassassin/compiled/
directory:
restorecon -R -v "/var/lib/spamassassin/compiled/"