diff --git a/CMakeLists.txt b/CMakeLists.txt index 163c967f3..c058801df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,8 +260,11 @@ else () message(STATUS "Valgrind headers not found -- disabling valgrind support") endif() -enable_c_flag_if_avail(-mtune=native C_FLAGS_REL LWAN_HAVE_MTUNE_NATIVE) -enable_c_flag_if_avail(-march=native C_FLAGS_REL LWAN_HAVE_MARCH_NATIVE) +option(MTUNE_NATIVE "Build with -mtune=native/-march=native" "ON") +if (MTUNE_NATIVE) + enable_c_flag_if_avail(-mtune=native C_FLAGS_REL LWAN_HAVE_MTUNE_NATIVE) + enable_c_flag_if_avail(-march=native C_FLAGS_REL LWAN_HAVE_MARCH_NATIVE) +endif () enable_c_flag_if_avail(-fstack-protector-explicit CMAKE_C_FLAGS LWAN_HAVE_STACK_PROTECTOR_EXPLICIT) diff --git a/Containerfile b/Containerfile index 077c7c119..c5092d4b4 100644 --- a/Containerfile +++ b/Containerfile @@ -3,7 +3,7 @@ RUN apk add --no-cache gcc make musl-dev cmake pkgconfig linux-headers \ luajit-dev sqlite-dev zlib-dev brotli-dev zstd-dev COPY . /lwan WORKDIR /lwan/build -RUN cmake .. -DCMAKE_BUILD_TYPE=Release +RUN cmake .. -DCMAKE_BUILD_TYPE=Release -DMTUNE_NATIVE=OFF RUN make -j FROM docker.io/library/alpine:3.14.2 diff --git a/README.md b/README.md index 6322db604..ba5055d1b 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,10 @@ names provided in the "Optional dependencies" section. The `-DUSE_SYSLOG=ON` option can be passed to CMake to also log to the system log in addition to the standard output. +If you're building Lwan for a distribution, it might be wise to use the +`-DMTUNE_NATIVE=OFF` option, otherwise the generated binary may fail to +run on some computers. + ### Tests ~/lwan/build$ make testsuite