Skip to content

Commit b059ff1

Browse files
committed
Attempt to optimized binaries for faster performance
1 parent c2d898f commit b059ff1

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

.github/workflows/check.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ jobs:
4848
$release_name = "karbo-cli-win64-$krb_ver"
4949
mkdir "$build_folder"
5050
cd "$build_folder"
51-
cmake -G "Visual Studio 17 2022" -A x64 -DBOOST_ROOT="$env:BOOST_ROOT" -DBOOST_INCLUDE_DIRS="$env:BOOST_ROOT/include" ..
51+
cmake -G "Visual Studio 17 2022" -A x64 `
52+
-DCMAKE_BUILD_TYPE=Release `
53+
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
54+
-DBOOST_ROOT="$env:BOOST_ROOT" `
55+
-DBOOST_INCLUDE_DIRS="$env:BOOST_ROOT/include" `
56+
..
5257
msbuild Karbowanec.sln /p:Configuration=Release /m /v:detailed
5358
cd src\Release
5459
Compress-Archive -Path *.exe -DestinationPath "$release_name.zip"
@@ -102,6 +107,7 @@ jobs:
102107
$krb_ver="${{ github.sha }}".SubString(0,7)
103108
$release_name="karbo-cli-win64-mingw-$krb_ver"
104109
echo "release_name=${release_name}" >> $env:GITHUB_OUTPUT
110+
105111
- name: Build
106112
shell: msys2 {0}
107113
id: build
@@ -111,6 +117,7 @@ jobs:
111117
cd build
112118
cmake .. -DCMAKE_BUILD_TYPE=Release -DSTATIC=ON
113119
cmake --build . --config Release
120+
114121
- name: Prepare release
115122
shell: msys2 {0}
116123
run: |
@@ -121,6 +128,7 @@ jobs:
121128
mv build/src/optimizer.exe build/karbo
122129
mv build/src/walletd.exe build/karbo
123130
mv build/src/vanitygen.exe build/karbo
131+
124132
- name: Upload To GH Artifacts
125133
uses: actions/upload-artifact@v4
126134
with:
@@ -170,6 +178,7 @@ jobs:
170178
171179
cmake .. \
172180
-DCMAKE_BUILD_TYPE=Release \
181+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
173182
-DCMAKE_OSX_ARCHITECTURES=arm64 \
174183
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
175184
-DOPENSSL_USE_STATIC_LIBS=ON \
@@ -225,7 +234,12 @@ jobs:
225234
release_name=Karbo-cli-ubuntu24.04-"$krb_ver"
226235
mkdir -p "$build_folder"
227236
cd "$build_folder"
228-
cmake -D ARCH=default -D CMAKE_BUILD_TYPE=Release -D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=true -D BOOST_IGNORE_SYSTEM_PATHS_DEFAULT=ON -D BOOST_ROOT=/usr ../..
237+
cmake -D ARCH=default -D CMAKE_BUILD_TYPE=Release \
238+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
239+
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \
240+
-D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=true \
241+
-D BOOST_IGNORE_SYSTEM_PATHS_DEFAULT=ON \
242+
-D BOOST_ROOT=/usr ../..
229243
make
230244
mkdir -p "$release_name"
231245
exeFiles=()

.github/workflows/release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ jobs:
4343
$release_name = "Karbo-cli-win64-$krb_ver"
4444
mkdir "$build_folder"
4545
cd "$build_folder"
46-
cmake -G "Visual Studio 17 2022" -A x64 -DBOOST_ROOT="$env:BOOST_ROOT" -DBOOST_INCLUDE_DIRS="$env:BOOST_ROOT/include" ..
46+
cmake -G "Visual Studio 17 2022" -A x64 `
47+
-DCMAKE_BUILD_TYPE=Release `
48+
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
49+
-DBOOST_ROOT="$env:BOOST_ROOT" `
50+
-DBOOST_INCLUDE_DIRS="$env:BOOST_ROOT/include" `
51+
..
4752
msbuild Karbowanec.sln /p:Configuration=Release /m /v:detailed
4853
cd src\Release
4954
Compress-Archive -Path *.exe -DestinationPath "$release_name.zip"
@@ -105,6 +110,7 @@ jobs:
105110
106111
cmake .. \
107112
-DCMAKE_BUILD_TYPE=Release \
113+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
108114
-DCMAKE_OSX_ARCHITECTURES=arm64 \
109115
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
110116
-DOPENSSL_USE_STATIC_LIBS=ON \
@@ -165,7 +171,12 @@ jobs:
165171
release_name=Karbo-cli-ubuntu24.04-"$krb_ver"
166172
mkdir -p "$build_folder"
167173
cd "$build_folder"
168-
cmake -D ARCH=default -D CMAKE_BUILD_TYPE=Release -D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=true -D BOOST_IGNORE_SYSTEM_PATHS_DEFAULT=ON -D BOOST_ROOT=/usr ../..
174+
cmake -D ARCH=default -D CMAKE_BUILD_TYPE=Release \
175+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
176+
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG" \
177+
-D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=true \
178+
-D BOOST_IGNORE_SYSTEM_PATHS_DEFAULT=ON \
179+
-D BOOST_ROOT=/usr ../..
169180
make
170181
cd src
171182
exeFiles=()

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,22 @@ if(ANDROID AND CMAKE_C_COMPILER_ID STREQUAL "Clang")
589589
endif()
590590
endif()
591591

592+
if (MSVC)
593+
add_compile_options(
594+
/O2 # Max optimization
595+
/Ob2 # Inline aggressively
596+
/Oi # Intrinsics
597+
/Ot # Favor speed
598+
/GL # Link-time code generation
599+
)
600+
601+
add_link_options(
602+
/LTCG # Link-time optimization
603+
)
604+
605+
add_compile_definitions(NDEBUG)
606+
endif()
607+
592608
include("${CMAKE_CURRENT_SOURCE_DIR}/src/version.cmake")
593609

594610
function (treat_warnings_as_errors dirs)

0 commit comments

Comments
 (0)