Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ endif()

check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
if(LEOPARD_PORTABLE_BUILD_TARGET)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${LEOPARD_PORTABLE_BUILD_TARGET}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ Addition in this finite field is XOR, and a vectorized memory XOR routine
is also used.


#### Portable builds

By default if your compiler supports native CPU architecture optimization, leopard will be compiled to use the available instruction sets. This is great for performance but not portability. If you're building leopard as part of a continuous-integration pipeline, the CPU architecture of the build systems will influence the instructions used in the output binary. This can result in binaries that contain illegal instructions when running on user CPUs. (SIGILL: Illegal operation.)

To prevent this, you can set the `LEOPARD_PORTABLE_BUILD_TARGET` cmake option to define the target architecture you want to build for.
For example: `cmake . -B build -G"MSYS Makefiles" -DLEOPARD_PORTABLE_BUILD_TARGET=x86-64-v3`

This allows you to build binaries that can run on any CPU that supports the selected instruction sets. Warning: Leopard relies on several instruction sets, and therefore cannot be built targetting any and all architectures your compiler may support.


#### References:

This library implements an MDS erasure code introduced in this paper:
Expand Down