Dr. Brian Robert Callahan
academic, developer, with an eye towards a brighter techno-social life
I recently added support for Nils Weller's C compiler to oksh. It would be good for me to document which C compilers work on OpenBSD and any caveats that come with those compilers. The following table is accurate as of the time of writing, which corresponds to OpenBSD 6.9-beta.
If you know of any additional C compilers not on this list, please let me know so they can be tested and added.
Please be aware that many of these compilers lack some or all of the mitigations built into the in-base compiler. When in doubt, use the in-base compiler.
Compiler | Version | Executable name | How to obtain? | Notes |
---|---|---|---|---|
Clang | 10.0.1 | /usr/bin/cc |
Comes with OpenBSD | You should use this C compiler unless you have a compelling reason to use something else. |
Clang | 10.0.1 | /usr/local/bin/clang |
pkg_add llvm |
Very useful if you want a cross compiler. |
CompCert | 3.8 | /usr/local/bin/ccomp |
pkg_add compcert |
Verified compiler. Requires-D_ANSI_LIBRARY in CPPFLAGS and-Wl,-nopie in LDFLAGS to prevent errors. |
CParser | 1.22.1 | /usr/local/bin/cparser |
pkg_add cparser |
Research compiler from the Programming Paradigms Group - IPD Snelting at the Karlsruhe Institute of Technology. |
GCC | 4.2.1 | /usr/bin/gcc |
Comes with OpenBSD | Going away except for those few archs that lack LLVM support. |
GCC | 8.4.0 | /usr/local/bin/egcc |
pkg_add gcc |
Useful for ports that require GCC for one reason or another. Also useful for gfortran and GNAT support. |
GCC | 11.0.0 | User-dependent. I use /usr/local/gnu/bin/gcc |
Compile manually | I track gcc upstream. It essentially just works, with the exception of GNAT . It is highly recommended you use a newer GNU assembler than the in-base version 2.17. There is a newer version of gas available as a package. |
lacc | 0.0.1 | /usr/local/bin/lacc |
Port available here | amd64-only |
Nils Weller's C compiler | 0.8.3 | /usr/local/bin/nwcc |
Port available here | Probably dead upstream. Requires-Wl,-nopie in LDFLAGS to prevent errors. |
PCC | 1.0.0 | /usr/local/bin/pcc |
pkg_add pcc |
This is a very old version of PCC. |
PCC | 1.2.0 DEVEL | User-dependent. I use /usr/local/bin/pcc |
Compile manually | I track pcc upstream. Modern versions of PCC are unable to link programs compiled with -g when using ld.lld as the linker. I use my port of GNU gold as the linker for PCC. |
TCC | mob | /usr/local/bin/tcc |
pkg_add tcc |
Provides a complete toolchain in a single binary. |