Skip to content

Commit 28b2798

Browse files
committed
fix: do not use mimalloc on macos and solve windows build issues on github actions
1 parent a0a5bde commit 28b2798

File tree

4 files changed

+67
-32
lines changed

4 files changed

+67
-32
lines changed

Diff for: .github/workflows/release.yml

+29-6
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,34 @@ jobs:
174174
if: matrix.os == 'windows-2019'
175175

176176
- name: Build & Install Full SDK
177-
# Build your GpgFrontend with the given configuration
178177
run: |
179178
cmake -B ${{github.workspace}}/build-full-sdk -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGPGFRONTEND_BUILD_TYPE_FULL_SDK=ON
180179
cmake --build ${{github.workspace}}/build-full-sdk --config {{$env.BUILD_TYPE}} -- -v
181180
sudo cmake --install ${{github.workspace}}/build-full-sdk --config {{$env.BUILD_TYPE}}
181+
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-13' || matrix.os == 'macos-12' || matrix.os == 'macos-14'
182+
183+
- name: Build & Install Full SDK (Windows)
184+
shell: msys2 {0}
185+
run: |
186+
cmake -B ${{github.workspace}}/build-full-sdk -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGPGFRONTEND_BUILD_TYPE_FULL_SDK=ON
187+
cmake --build ${{github.workspace}}/build-full-sdk --config {{$env.BUILD_TYPE}} -- -v
188+
sudo cmake --install ${{github.workspace}}/build-full-sdk --config {{$env.BUILD_TYPE}}
189+
if: matrix.os == 'windows-2019'
182190

183191
- name: Build Integrated Modules
184-
# Build your GpgFrontend with the given configuration
185192
run: |
186193
cmake -S ${{github.workspace}}/modules -B ${{github.workspace}}/modules/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/modules/build/artifacts
187194
cmake --build ${{github.workspace}}/modules/build --config {{$env.BUILD_TYPE}} -- -v
188195
cmake --install ${{github.workspace}}/modules/build --config {{$env.BUILD_TYPE}}
196+
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-13' || matrix.os == 'macos-12' || matrix.os == 'macos-14'
197+
198+
- name: Build Integrated Modules (Windows)
199+
shell: msys2 {0}
200+
run: |
201+
cmake -S ${{github.workspace}}/modules -B ${{github.workspace}}/modules/build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/modules/build/artifacts
202+
cmake --build ${{github.workspace}}/modules/build --config {{$env.BUILD_TYPE}} -- -v
203+
cmake --install ${{github.workspace}}/modules/build --config {{$env.BUILD_TYPE}}
204+
if: matrix.os == 'windows-2019'
189205

190206
- name: Build & Export GpgFrontend (macOS)
191207
# Build your GpgFrontend with the given configuration
@@ -256,30 +272,37 @@ jobs:
256272
./linuxdeployqt-continuous-x86_64.AppImage ${{github.workspace}}/build/artifacts/AppDir/usr/share/applications/*.desktop -no-translations -extra-plugins=iconengines,platformthemes/libqgtk3.so -appimage -executable-dir=${{github.workspace}}/build/artifacts/AppDir/usr/modules/
257273
if: matrix.os == 'ubuntu-20.04'
258274

259-
- name: Configure CMake & Build Binary(Windows)
275+
- name: Configure CMake & Build Binary (Windows)
260276
shell: msys2 {0}
261277
run: |
262278
cd $(echo "/${{github.workspace}}" | sed 's/\\/\//g' | sed 's/://')
263279
mkdir build && cd build
264280
cmake -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGPGFRONTEND_BUILD_TYPE_STABLE=ON ..
265281
cmake --build . --config ${{env.BUILD_TYPE}} -- -j 4
266282
if: matrix.os == 'windows-2019'
283+
284+
- name: Copy Modules & Package (Windows)
285+
shell: msys2 {0}
286+
run: |
287+
cmake -E copy_directory ${{github.workspace}}/modules/build/artifacts/modules ${{github.workspace}}/build/artifacts/modules
288+
windeployqt-qt6 --force --libdir ${{github.workspace}}/build/artifacts --release ${{github.workspace}}/build/artifacts/GpgFrontend.exe
289+
if: matrix.os == 'windows-2019'
267290

268-
- name: Upload Artifact(Linux)
291+
- name: Upload Artifact (Linux)
269292
uses: actions/upload-artifact@master
270293
with:
271294
name: gpgfrontend-${{matrix.os}}-${{env.BUILD_TYPE}}-${{ github.sha }}
272295
path: ${{github.workspace}}/build/final-artifact/Gpg_Frontend*.AppImage*
273296
if: matrix.os == 'ubuntu-20.04'
274297

275-
- name: Upload Artifact(macOS)
298+
- name: Upload Artifact (macOS)
276299
uses: actions/upload-artifact@master
277300
with:
278301
name: gpgfrontend-${{matrix.os}}-${{env.BUILD_TYPE}}-${{ github.sha }}
279302
path: ${{github.workspace}}/build/final-artifact/*
280303
if: matrix.os == 'macos-13' || matrix.os == 'macos-12' || matrix.os == 'macos-14'
281304

282-
- name: Upload Artifact(Windows)
305+
- name: Upload Artifact (Windows)
283306
uses: actions/upload-artifact@master
284307
with:
285308
name: gpgfrontend-${{matrix.os}}-${{env.BUILD_TYPE}}-${{ github.sha }}

Diff for: src/CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,6 @@ if (BUILD_APPLICATION)
311311
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
312312
if (MINGW)
313313
add_executable(${AppName} WIN32 ${BASE_SOURCE} ${RESOURCE_FILES})
314-
# include qt dependencies
315-
if(NOT Qt6_DIR)
316-
add_custom_command(TARGET ${AppName} POST_BUILD
317-
COMMAND windeployqt --force --libdir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} --release ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.exe)
318-
else()
319-
add_custom_command(TARGET ${AppName} POST_BUILD
320-
COMMAND windeployqt-qt6.exe --force --libdir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} --release ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.exe)
321-
endif()
322314
elseif (LINUX AND NOT LINUX_INSTALL_SOFTWARE)
323315
add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES})
324316

Diff for: src/core/function/SecureMemoryAllocator.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#include "SecureMemoryAllocator.h"
3030

31+
#ifndef MACOS
32+
3133
#include <mimalloc.h>
3234

3335
namespace GpgFrontend {
@@ -38,10 +40,28 @@ auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* {
3840
}
3941

4042
auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* {
41-
auto* addr = realloc(ptr, size);
43+
auto* addr = mi_realloc(ptr, size);
4244
return addr;
4345
}
4446

4547
void SecureMemoryAllocator::Deallocate(void* p) { mi_free(p); }
4648

49+
#else
50+
51+
namespace GpgFrontend {
52+
53+
auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* {
54+
auto* addr = malloc(size);
55+
return addr;
56+
}
57+
58+
auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* {
59+
auto* addr = realloc(ptr, size);
60+
return addr;
61+
}
62+
63+
void SecureMemoryAllocator::Deallocate(void* p) { free(p); }
64+
65+
#endif
66+
4767
} // namespace GpgFrontend

Diff for: third_party/CMakeLists.txt

+17-17
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,35 @@
2323
#
2424
# SPDX-License-Identifier: GPL-3.0-or-later
2525

26-
2726
# json
2827
set(JSON_BuildTests OFF CACHE INTERNAL "")
2928

30-
if (MINGW)
29+
if(MINGW)
3130
add_subdirectory(libarchive EXCLUDE_FROM_ALL)
3231
endif()
3332

34-
set(MI_SECURE ON)
33+
if(NOT APPLE)
34+
set(MI_SECURE ON)
3535

36-
# fix the segment fault issue on M1 chip platform
37-
# refer to https://github.com/microsoft/mimalloc/issues/343
38-
if(APPLE)
39-
set(MI_OSX_ZONE ON)
40-
set(MI_OSX_INTERPOSE OFF)
41-
endif()
36+
# fix the segment fault issue on M1 chip platform
37+
# refer to https://github.com/microsoft/mimalloc/issues/343
38+
# if(APPLE)
39+
# set(MI_OSX_ZONE ON)
40+
# set(MI_OSX_INTERPOSE OFF)
41+
# endif()
4242

43-
# ASAN checking
44-
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND ENABLE_ASAN)
43+
# ASAN checking
44+
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND ENABLE_ASAN)
45+
# if(APPLE)
46+
# set(MI_OVERRIDE OFF)
47+
# endif()
4548

46-
if(APPLE)
47-
set(MI_OVERRIDE OFF)
49+
# set(MI_TRACK_VALGRIND ON)
50+
set(MI_TRACK_ASAN ON)
4851
endif()
4952

50-
# set(MI_TRACK_VALGRIND ON)
51-
set(MI_TRACK_ASAN ON)
53+
add_subdirectory(mimalloc EXCLUDE_FROM_ALL)
5254
endif()
5355

54-
add_subdirectory(mimalloc EXCLUDE_FROM_ALL)
55-
5656
set(INSTALL_GTEST OFF)
5757
add_subdirectory(googletest EXCLUDE_FROM_ALL)

0 commit comments

Comments
 (0)