Download

Current version: 1.3.1, November 18, 2025 (changes).

Here is the source code of spatch. It requires OCaml and optionally Python 2.5 to 2.7 or Python 3. If you plan to modify the SmPL grammar or you do a "make distclean", thus removing all generated files, then you will also need to install menhir.

The source code of the various releases is also available at GitHub.

We also provide pre-compiled versions of spatch:

Packages exist for several distributions:

It is also available on FlatHub (thanks to Jan Tojnar), which means you can install and run Coccinelle on any Flatpak-compatible distribution with:

flatpak install io.github.coccinelle.coccinelle
flatpak run io.github.coccinelle.coccinelle --help

On Linux and macOS, you can also install Coccinelle using brew:

brew install coccinelle

Finally, Francois Berenger has packaged Coccinelle for Opam, a widely available package manager for OCaml. Once Opam has been installed, coccinelle can be installed with the following commands:

opam update
opam install coccinelle

Example invocation: ./spatch -cocci_file foo.cocci foo.c . The output is in the file /tmp/foo.c which will contain the result of applying the semantic patch foo.cocci to the C file foo.c modulo a set of isomorphisms contained in standard.iso (standard.iso is by default located in /usr/local/share/coccinelle/standard.iso). It is also possible to apply spatch to all of the C files in a directory: ./spatch -cocci_file foo.cocci -dir foodir . If the semantic patch is not working as expected, it can be useful to use the option -debug to get a trace of the metavariable bindings used for each rule.

We also provide our current set of isomorphisms: standard.iso (colorized HTML version).

Some of our semantic patches and test files are also available: coccinelle-tests.tar.gz (21M).

Alexander Færøy has made a vim mode for use with Coccinelle semantic patches.