Skip to content

Commit

Permalink
Make binaries more compatible by default (#206)
Browse files Browse the repository at this point in the history
* Make binaries more compatible by default

Turn `-march=native` off by default. This makes binaries more portable,
but may harm performance. However, fast paths look unaltered

* Change setting to on if specified.
  • Loading branch information
mjp41 authored May 28, 2020
1 parent 2c9ab30 commit 4c22c5b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ option(EXPOSE_EXTERNAL_RESERVE "Expose an interface to reserve memory using the
option(SNMALLOC_RUST_SUPPORT "Build static library for rust" OFF)
option(SNMALLOC_STATIC_LIBRARY "Build static libraries" ON)
option(SNMALLOC_QEMU_WORKAROUND "Disable using madvise(DONT_NEED) to zero memory on Linux" Off)
option(SNMALLOC_OPTIMISE_FOR_CURRENT_MACHINE "Compile for current machine architecture" Off)
set(CACHE_FRIENDLY_OFFSET OFF CACHE STRING "Base offset to place linked-list nodes.")
set(SNMALLOC_STATIC_LIBRARY_PREFIX "sn_" CACHE STRING "Static library function prefix")

Expand Down Expand Up @@ -169,12 +170,12 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
target_link_libraries(snmalloc_lib INTERFACE "-rdynamic")
endif()

if((${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") OR
(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") OR
(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm"))
if(SNMALLOC_OPTIMISE_FOR_CURRENT_MACHINE)
check_cxx_compiler_flag(-march=native SUPPORT_MARCH_NATIVE)
if (SUPPORT_MARCH_NATIVE)
add_compile_options(-march=native)
else()
message(WARNING "Compiler does not support `-march=native` required by SNMALLOC_OPTIMISE_FOR_CURRENT_MACHINE")
endif()
endif()

Expand Down

0 comments on commit 4c22c5b

Please sign in to comment.