Skip to content

Commit

Permalink
Fix Docker image may crash if running on the AMD platform (#1602)
Browse files Browse the repository at this point in the history
RocksDB PORTABLE was set to 0 after #1516 and it may return an illegal instruction error
when running on the AMD platform. This PR fixes this issue by changing the default value
of PORTABLE to 1 so that it can compile the rocksdb without platform special instructions.
  • Loading branch information
ovaistariq authored and git-hulk committed Aug 1, 2023
1 parent 66088c0 commit 3fe7b82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apk update && apk add git gcc g++ make cmake ninja autoconf automake libtool
WORKDIR /kvrocks

COPY . .
RUN ./x.py build -DENABLE_OPENSSL=ON -DCMAKE_BUILD_TYPE=Release -j $(nproc) $MORE_BUILD_ARGS
RUN ./x.py build -DENABLE_OPENSSL=ON -DPORTABLE=1 -DCMAKE_BUILD_TYPE=Release -j $(nproc) $MORE_BUILD_ARGS

FROM alpine:3.16

Expand Down
7 changes: 6 additions & 1 deletion x.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def build(dir: str, jobs: Optional[int], ghproxy: bool, ninja: bool, unittest: b

makedirs(dir, exist_ok=True)

cmake_options = ["-DCMAKE_BUILD_TYPE=RelWithDebInfo", "-DPORTABLE=0"]
cmake_options = ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"]
if ghproxy:
cmake_options.append("-DDEPS_FETCH_PROXY=https://ghproxy.com/")
if ninja:
Expand All @@ -119,6 +119,11 @@ def build(dir: str, jobs: Optional[int], ghproxy: bool, ninja: bool, unittest: b
cmake_options += ["-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"]
if D:
cmake_options += [f"-D{o}" for o in D]

portable_flag_enabled = any("DPORTABLE" in o for o in cmake_options)
if not portable_flag_enabled:
cmake_options.append("-DPORTABLE=0")

run(cmake, str(basedir), *cmake_options, verbose=True, cwd=dir)

if skip_build:
Expand Down

0 comments on commit 3fe7b82

Please sign in to comment.