Skip to content

Commit ceb38be

Browse files
[Refactor:Plagiarism] Link Boost statically (#99)
### What is the current behavior? Boost is currently linked dynamically, which causes Lichen to be fragile when changes are made to the underlying operating system. ### What is the new behavior? Links Boost statically, using CMake instead of a manual compilation line. This change significantly reduced the size of the Lichen Docker image, at the expense of a much larger executable. Image size: ``` Initial: 2.1 GB Final: 1.5 GB ``` Executable size: ``` Initial: 3.4 MB Final: 7.2 MB ``` --------- Co-authored-by: Chris Reed <55092742+cjreed121@users.noreply.github.com>
1 parent 93c742b commit ceb38be

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ ARG DEBIAN_FRONTEND=noninteractive
55
# C++ and Python
66
RUN apt-get update \
77
&& apt-get install -y \
8-
libboost-all-dev \
98
python3.9 \
109
python3-pip \
1110
clang-14 \

compare_hashes/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(Lichen)
3+
set(CMAKE_CXX_STANDARD 14)
4+
5+
set(Boost_USE_STATIC_LIBS ON)
6+
find_package(Boost REQUIRED COMPONENTS
7+
system
8+
filesystem
9+
)
10+
11+
link_libraries("-static")
12+
13+
add_executable(Lichen
14+
compare_hashes.cpp
15+
submission.cpp
16+
)
17+
18+
target_link_libraries(Lichen
19+
Boost::system
20+
Boost::filesystem
21+
)
22+
23+
target_compile_options(Lichen PRIVATE
24+
-Wall
25+
-Wextra
26+
-Werror
27+
-g
28+
-O3
29+
-funroll-loops
30+
)
31+
target_link_options(Lichen PRIVATE
32+
-flto
33+
)
34+
35+
include_directories(/usr/local/submitty/Lichen/vendor)
36+
37+
set_target_properties(Lichen PROPERTIES OUTPUT_NAME compare_hashes.out)

install_lichen.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ fi
5454
####################################################################################################
5555
# compile & install the hash comparison tool
5656

57-
pushd "${lichen_repository_dir}" > /dev/null
58-
clang++ -I "${lichen_vendor_dir}" -lboost_system -lboost_filesystem -Wall -Wextra -Werror -g -O3 -flto -funroll-loops -std=c++11 compare_hashes/compare_hashes.cpp compare_hashes/submission.cpp -o "${lichen_installation_dir}/compare_hashes/compare_hashes.out"
57+
pushd "${lichen_installation_dir}/compare_hashes" > /dev/null
58+
cmake "$lichen_repository_dir/compare_hashes"
59+
cmake --build . --parallel "$(nproc)"
5960
if [ "$?" -ne 0 ]; then
6061
echo -e "ERROR: FAILED TO BUILD HASH COMPARISON TOOL\n"
6162
exit 1

0 commit comments

Comments
 (0)