---
title: Rule2XSBody
url: 'https://docs.danami.com/warden/user-guide/antispam-plugins/rule2xsbody'
markdown: 'https://docs.danami.com/warden/user-guide/antispam-plugins/rule2xsbody.md'
date: '2026-10-02'
description: '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. How it works Warden enables the Mail::SpamAssassin::Plugin…'
taxonomy:
  category:
    - docs
  tag:
    - rule2xsbody
---

[](#)  [ Basics ](https://docs.danami.com/warden/)     [ User Guide ](https://docs.danami.com/warden/user-guide)     [ Anti-spam Plugins ](https://docs.danami.com/warden/user-guide/antispam-plugins)      Rule2XSBody    

# Rule2XSBody

> > > > > 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.

## How it works

Warden enables the `Mail::SpamAssassin::Plugin::Rule2XSBody` plugin in SpamAssassin. The plugin loads the compiled object files generated by `sa-compile` and evaluates the rules as native code instead of regular expressions.

## Install

```
// AlmaLinux 10
yum install spamassassin-compile

// AlmaLinux / CloudLinux / RHEL / Rocky Linux 8 and 9
yum install gcc re2c make perl-ExtUtils-MakeMaker

// Debian/Ubuntu
apt-get install gcc re2c make sa-compile
```

Navigate to Warden -> Settings -> Plugin Settings -> Enable the Rule2XSBody plugin. You can test to see if the rules compile successfully by running the command:

```
// compile the rules
/usr/bin/sa-compile

// If using SELinux apply the proper labels to the compiled rules
restorecon -R -v "/var/lib/spamassassin/compiled/"
```

You should see it compile the rules and copy them to your spamassassin compiled rules directory.

## SELinux Problems

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/"
```

## Settings

This plugin has no additional settings. It is not installed by default and can be enabled or disabled under `Warden -> Settings -> Plugin Settings -> Rule2XSBody`.

---

## Navigation

- Parent: [Anti-spam Plugins](https://docs.danami.com/warden/user-guide/antispam-plugins.md)
- Previous: [RelayCountry](https://docs.danami.com/warden/user-guide/antispam-plugins/relaycountry.md)
- Next: [RuleStatistics](https://docs.danami.com/warden/user-guide/antispam-plugins/rulestatistics.md)
