diff --git a/CMakeLists.txt b/CMakeLists.txt index a63f5ddcc6c..a1656161e76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(USE_LUAJIT "use luaJIT instead of lua" OFF) option(ENABLE_OPENSSL "enable openssl to support tls connection" OFF) option(ENABLE_IPO "enable interprocedural optimization" ON) option(ENABLE_UNWIND "enable libunwind in glog" ON) +option(PORTABLE "build a portable binary (disable arch-specific optimizations)" OFF) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) diff --git a/Dockerfile b/Dockerfile index f2210e1199c..661dab930e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,16 +17,17 @@ FROM ubuntu:focal as build +ARG MORE_BUILD_ARGS + # workaround tzdata install hanging ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -RUN apt update -RUN apt install -y git gcc g++ make cmake autoconf automake libtool python3 libssl-dev +RUN apt update && apt install -y git gcc g++ make cmake autoconf automake libtool python3 libssl-dev WORKDIR /kvrocks COPY . . -RUN ./x.py build -DENABLE_OPENSSL=ON +RUN ./x.py build -DENABLE_OPENSSL=ON -DPORTABLE=ON $MORE_BUILD_ARGS FROM ubuntu:focal diff --git a/cmake/rocksdb.cmake b/cmake/rocksdb.cmake index 87f49bccd5d..133ebd2eb47 100644 --- a/cmake/rocksdb.cmake +++ b/cmake/rocksdb.cmake @@ -48,6 +48,7 @@ FetchContent_MakeAvailableWithArgs(rocksdb USE_RTTI=ON ROCKSDB_BUILD_SHARED=OFF WITH_JEMALLOC=${COMPILE_WITH_JEMALLOC} + PORTABLE=${PORTABLE} ) add_library(rocksdb_with_headers INTERFACE)