Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when compiling with mingw64, use __mingw_aligned_malloc() and __mingw_aligned_free() #121

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

liquidaty
Copy link

use __mingw_aligned_malloc in lieu of posix_memalign and __mingw_aligned_free in aligned_free_internal

With this change, I can successfully compile the library, and simplegrep.exe, using mingw64 (after setting env vars to point to the mingw64 toolchain) using the following steps (I'm cross-compiling from OSX, so the steps may be different / simpler on a native setup) and assuming my target PREFIX is /opt/mingw64. Note that the -DBUILD_AVX2=1 was necessary because otherwise AVX2 detection failed, and -DCMAKE_BUILD_TYPE=DEBUG fails for reasons I did not bother to investigate

cmake .. -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY -DCMAKE_C_INCLUDE_PATH=/opt/mingw64/include -DC_INCLUDE_PATH=/opt/mingw64/include -DFAT_RUNTIME=off -DCMAKE_INSTALL_NAME_TOOL= -DBUILD_AVX2=1 -DCMAKE_BUILD_TYPE=RELEASE

# remove -search_paths_first flag which will cause minGW's gcc to error. probably this should be a separate issue and fix, but here's the quick & dirty workaround
find . -name 'link.txt' -exec sed -i.bak 's#-Wl,-search_paths_first ##g' {} \;

# build as static binary to remove dependency on non-standard DLLs (and strip symbols, though that's probably not necessary)
find . -name 'link.txt' -exec sed -i.bak 's#../lib/libhs.a#../lib/libhs.a -static -Wl,--strip-all#g' {} \;

# build simplegrep.exe
make -C examples simplegrep

@liquidaty liquidaty changed the title fix to enable successful build with mingw64 when compiling with mingw64, use __mingw_aligned_malloc() and __mingw_aligned_free() Sep 8, 2022
@markos markos merged commit db2a6d6 into VectorCamp:develop Sep 9, 2022
@markos markos mentioned this pull request Sep 9, 2022
@liquidaty liquidaty deleted the mingw64-develop branch September 9, 2022 16:40
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.

2 participants