Skip to content

extlib: update zlib, libpng, and mimalloc to their latest releases#1611

Closed
iscgar wants to merge 3 commits intosolvespace:masterfrom
iscgar:iscgar/update-extlib-cmake
Closed

extlib: update zlib, libpng, and mimalloc to their latest releases#1611
iscgar wants to merge 3 commits intosolvespace:masterfrom
iscgar:iscgar/update-extlib-cmake

Conversation

@iscgar
Copy link
Contributor

@iscgar iscgar commented Aug 9, 2025

This takes care of the outdated libraries that use the upstream repositories directly, and should fix the build issues on macOS reported in #1579 and #1595. I have a separate branch that also updates pixman and cairo, but they require updating the SolveSpace forks first, and I'm not sure what the best way to tackle it is, given that both of them have a non default branch where the SolveSpace patches are added, so I can't just open a PR against them. I also want to update ANGLE while I'm at it, and it's taking longer than expected, so I wanted to get the low hanging fruit out of the way first.

This solves an issue with CMake 4.0.0, which doesn't support configs
for versions earlier than 3.5.
@iscgar
Copy link
Contributor Author

iscgar commented Aug 9, 2025

The macOS build issue seems unrelated to this change, and I'm not sure what's causing it. Interesting that we run into an ASan issue on Ubuntu with the new mimalloc version. I'll try to debug it and report back.

@iscgar
Copy link
Contributor Author

iscgar commented Aug 9, 2025

This is an upstream regression (mimalloc#1124), so I'm downgrading mimalloc to v2.2.3 in order to avoid it. I'll open a separate PR to fix two minor test issues that I found while investigating this.

iscgar added 2 commits August 10, 2025 01:15
This solves an issue with CMake 4.0.0, which doesn't support configs
for versions earlier than 3.5.
This solves an issue with CMake 4.0.0, which doesn't support configs
for versions earlier than 3.5.

This unfortunately also requires messing with the way we include zlib,
because the static libpng target isn't really compatible with the way
zlib is built.
@iscgar iscgar force-pushed the iscgar/update-extlib-cmake branch from 2b78236 to f6ac85a Compare August 9, 2025 22:15
@iscgar
Copy link
Contributor Author

iscgar commented Aug 9, 2025

The macOS issue indeed isn't related to this change (encountered 4 months ago by this HN commenter: https://news.ycombinator.com/item?id=43552607), but I have no idea what's causing it and how to fix it becuase I don't have access to a macOS setup.

Based on this CMake issue, I temporarily pushed a commit with the diff below, and it seems to work, so I opened #1614 to fix that, as it's not related to the changes in this PR. I'll rebase this and the other PRs on it after it's merged.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,7 +136,7 @@ if(ENABLE_OPENMP)
     find_package( OpenMP REQUIRED )
     if(OPENMP_FOUND)
         add_library(slvs_openmp INTERFACE)
-        target_compile_options(slvs_openmp INTERFACE ${OpenMP_CXX_FLAGS})
+        target_compile_options(slvs_openmp INTERFACE "SHELL:${OpenMP_CXX_FLAGS}")
         target_link_libraries(slvs_openmp INTERFACE
             ${OpenMP_CXX_LIBRARIES})
         target_include_directories(slvs_openmp SYSTEM INTERFACE

@ruevs
Copy link
Member

ruevs commented Aug 10, 2025

@iscgar Merged 0bf9cbb b9a9e26 592edbd

@ruevs
Copy link
Member

ruevs commented Aug 10, 2025

Offff mimalloc is a PITA, always has been, now the Emscripten builds fail :-(
https://github.com/solvespace/solvespace/actions/runs/16865637438/job/47772106561#step:4:155
https://github.com/solvespace/solvespace/actions/runs/16865637439/job/47772225844#step:4:618

As does all the Python stuff:
https://github.com/solvespace/solvespace/actions/runs/16865637440

@vespakoen can you take a look?

wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_free
wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_free
wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_free
wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_memalign
wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_memalign
wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_free
wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_memalign
wasm-ld: error: ../bin/solvespace.wasm.lto.libmimalloc.a(os.c.o at 177796).o: undefined symbol: emmalloc_memalign

@iscgar
Copy link
Contributor Author

iscgar commented Aug 10, 2025

The Python issue is an upstream mimalloc issue, which was fixed in 2.2.4, that we cannot use due to the issue mentioned above. I'll try to find a version that works later today, and report back if I find a good solution that doesn't require reverting the update altogether.

The WASM issue seems to be caused by Emscripten support in mimalloc, which layers it on top of emmalloc (see emscripten-core/emscripten#20651). Choosing to specify -sMALLOC=emmalloc would slow down allocations of everything that doesn't use the temporary heap, so I'm not sure it's the right choice. An alternative might be to just not build mimalloc with Emscripten, and instead specify -sMALLOC=mimalloc, so that the Emscripten mimalloc is used for regular allocations as well.

@iscgar iscgar deleted the iscgar/update-extlib-cmake branch August 10, 2025 20:52
@iscgar
Copy link
Contributor Author

iscgar commented Aug 10, 2025

#1616 should take care of both issues.

@ruevs
Copy link
Member

ruevs commented Aug 11, 2025

Thanks @iscgar for looking at this so quickly and finding a workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure on macOS 15.5 macOS build instructions in README don't work (again)

2 participants