Skip to content

Commit

Permalink
Static Compilation With glibc (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayuii authored Oct 28, 2021
1 parent ae7f6a5 commit 40b5e2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ add_executable(ProofOfSpace
${BLAKE3_SRC}
)

option(BUILD_PROOF_OF_SPACE_STATICALLY "Build ProofOfSpace target statically" OFF)
IF (BUILD_PROOF_OF_SPACE_STATICALLY)
message("Statically build ProofOfSpace")
target_link_libraries(ProofOfSpace -static -Wl,--whole-archive -lrt -lpthread -Wl,--no-whole-archive)
ENDIF()

add_executable(RunTests
tests/test-main.cpp
tests/test.cpp
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ubuntu:20.04 as builder

ARG DEBIAN_FRONTEND=noninteractive
ARG BUILD_PROOF_OF_SPACE_STATICALLY=OFF

RUN apt-get update -y

Expand All @@ -20,7 +21,7 @@ COPY . .
RUN mkdir -p build

WORKDIR /app/build
RUN cmake ../
RUN cmake -DBUILD_PROOF_OF_SPACE_STATICALLY=${BUILD_PROOF_OF_SPACE_STATICALLY} ../
RUN cmake --build . -- -j `nproc`


Expand All @@ -29,4 +30,3 @@ FROM ubuntu:20.04
COPY --from=builder /app/build /app

CMD ["/app/ProofOfSpace"]

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ cmake ../
cmake --build . -- -j 6
```

## Static Compilation With glibc
### Statically compile ProofOfSpace
```bash
mkdir -p build && cd build
cmake -DBUILD_PROOF_OF_SPACE_STATICALLY=ON ../
cmake --build . -- -j 6
```

### Run tests

```bash
Expand Down

0 comments on commit 40b5e2d

Please sign in to comment.