No description
  • C 93.7%
  • Assembly 4.1%
  • CMake 1.4%
  • Makefile 0.6%
  • C++ 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-09-07 21:16:38 -06:00
.github Bump actions/checkout from 4 to 5 (#335) 2025-09-02 18:12:55 -04:00
aarch64 Fix BSD-specific types on Linux for aarch64 (#329) 2025-06-03 15:56:14 -04:00
amd64 Add stack markings for GNU to fmod assembly files (#307) 2024-08-04 18:12:41 -04:00
arm Remove unused Symbol.map files. 2015-02-01 19:41:55 +05:30
bsdsrc add missing weak references for long double functions 2021-05-20 23:31:35 +02:00
docs Update index.html 2025-03-07 16:05:45 -05:00
i387 Correctly round double precision sqrt (#256) 2022-01-19 18:43:52 -05:00
include Include cdefs-compat.h on s390 and powerpc 2025-06-21 00:49:03 +02:00
ld80 Fix undefined reference to __fpgetprec on i386 2016-06-23 23:32:31 -04:00
ld128 Fix compilation on AArch64 2017-10-21 09:58:16 -04:00
loongarch64 Fix fenv_t initializer (#308) 2024-11-09 08:40:26 -05:00
mips Using cdefs-compat.h and stdint.h instead <sys/types.h> 2018-06-04 09:38:27 +00:00
powerpc Make fenv methods static on additional platforms. 2021-02-01 13:48:31 +01:00
riscv64 Update riscv64 fenv.c initialization to fix warnings (#330) 2025-06-03 22:46:44 -04:00
s390 s390(x) port 2018-11-07 12:11:15 +01:00
src Fix missing functions on riscv64 2025-09-07 21:16:38 -06:00
test msys2 ci (#243) 2021-09-09 18:49:37 -04:00
wasm32 wasm32 support (#192) 2019-04-14 15:11:03 -07:00
.gitignore ci: test with openlibm-test (#327) 2025-05-21 10:44:49 -04:00
.mailmap Add mailmap 2012-08-24 20:53:18 +05:30
CMakeLists.txt cmake: Fix cmake error for 4.x (#333) 2025-08-15 17:22:40 +08:00
LICENSE.md Update references to JuliaLang to point to JuliaMath (#182) 2018-06-18 14:48:23 -07:00
Make.inc Add a Vim filetype hint for Make.inc alongside that for Emacs 2025-01-07 13:14:42 -08:00
Makefile ci: test with openlibm-test (#327) 2025-05-21 10:44:49 -04:00
openlibm.pc.in build: fix pkgconfig cflags and libdir variables (#284) 2024-01-10 09:52:08 +05:30
README.md CMake updates (#302) 2024-06-19 15:02:50 -04:00

OpenLibm

codecov

OpenLibm is an effort to have a high quality, portable, standalone C mathematical library (libm). It can be used standalone in applications and programming language implementations.

The project was born out of a need to have a good libm for the Julia programming language that worked consistently across compilers and operating systems, and in 32-bit and 64-bit environments.

Platform support

OpenLibm builds on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and DragonFly BSD. It builds with both GCC and clang. Although largely tested and widely used on the x86 and x86-64 architectures, OpenLibm also supports arm, aarch64, ppc64le, mips, wasm32, riscv, s390(x) and loongarch64.

Build instructions

GNU Make

  1. Use GNU Make to build OpenLibm. This is make on most systems, but gmake on BSDs.
  2. Use make USEGCC=1 to build with GCC. This is the default on Linux and Windows.
  3. Use make USECLANG=1 to build with clang. This is the default on OS X, FreeBSD, and OpenBSD.
  4. Use make ARCH=wasm32 to build the wasm32 library with clang.
  5. Architectures are auto-detected. Use make ARCH=i386 to force a build for i386. Other supported architectures are i486, i586, and i686. GCC 4.8 is the minimum requirement for correct codegen on older 32-bit architectures.

Cross Build Take riscv64 as example:

  1. install qemu-riscv64-static, gcc-riscv64-linux-gnu
  2. Cross build:
ARCH=riscv64
TRIPLE=$ARCH-linux-gnu
make ARCH=$ARCH TOOLPREFIX=$TRIPLE-  -j
make -C test ARCH=$ARCH TOOLPREFIX=$TRIPLE-  -j
  1. Run test with qemu:
qemu-$ARCH-static -L . -L /usr/$TRIPLE/  test/test-float
qemu-$ARCH-static -L . -L /usr/$TRIPLE/  test/test-double

CMake

  1. Create build directory with mkdir build and navigate into it with cd build.
  2. Run CMake to configure project and generate native build system with cmake /path/to/openlibm/ or generate project with build system of choice e.g. cmake /path/to/openlib/ -G "MinGW Makefiles".
  3. Build with the build system with cmake --build ..

Default CMake configuration builds a shared library, this can easily be configured using BUILD_SHARED_LIBS configuration option.

Acknowledgements

PowerPC support for openlibm was graciously sponsored by IBM.