Skip to content

CMake integration improvements + README update#22

Closed
WeGoToMars wants to merge 5 commits intomxmlnkn:masterfrom
WeGoToMars:master
Closed

CMake integration improvements + README update#22
WeGoToMars wants to merge 5 commits intomxmlnkn:masterfrom
WeGoToMars:master

Conversation

@WeGoToMars
Copy link
Contributor

Following up on mxmlnkn/rapidgzip#59

By the way, I see that you are currently working on adding support for compiling ISA-L for ARM, but the build couldn't be finished on my ARM Mac. Using the clang compiler, I get an error when assembling one of the files:

[ 61%] Building ASM object _deps/rapidgzip-build/src/CMakeFiles/isal_inflate.dir/external/isal/crc/aarch64/crc32_gzip_refl_pmull.S.o
<instantiation>:4:26: error: unexpected token in argument list movk x7, p4_low_b1, lsl 16

I was able to get it fixed by changing movk x7, p4_low_b1, lsl 16 to movk x7, p4_low_b1, lsl #16, but I assume ISA-L has general issues with ARM Macs and only GNU assembler is supported?

After disabling building ISA-L with an option, the rest of the project compiles without a problem on macOS (apart from one of the benchmarks that requires Linux/POSIX functions).

@mxmlnkn
Copy link
Owner

mxmlnkn commented Aug 3, 2025

By the way, I see that you are currently working on adding support for compiling ISA-L for ARM, but the build couldn't be finished on my ARM Mac. Using the clang compiler, I get an error when assembling one of the files:

[ 61%] Building ASM object _deps/rapidgzip-build/src/CMakeFiles/isal_inflate.dir/external/isal/crc/aarch64/crc32_gzip_refl_pmull.S.o
<instantiation>:4:26: error: unexpected token in argument list movk x7, p4_low_b1, lsl 16

I was able to get it fixed by changing movk x7, p4_low_b1, lsl 16 to movk x7, p4_low_b1, lsl #16, but I assume ISA-L has general issues with ARM Macs and only GNU assembler is supported?

Funny coincidence, and thanks for the feedback. Only GNU assembler being supported might be true. Was that 16 -> #16 the only change you had to do? In that case, it might be worth fixing upstream, or I can simply put it in my fork. Generally, I would expect ARM to work on macOS. The rapidgzip darwin-arm wheels don't seem to contain any isal functions based on a simple strings *.so | grep -i isal test. I could check how it is built in the CI, but debugging in the CI is always cumbersome as opposed to a local system.

After disabling building ISA-L with an option, the rest of the project compiles without a problem on macOS (apart from one of the benchmarks that requires Linux/POSIX functions).

Which benchmark? It might be easily fixable, if not, the benchmark could be guarded against macOS inside CMake. There is a commit for this.

@mxmlnkn mxmlnkn changed the title CMake intergration improvements + README update CMake integration improvements + README update Aug 3, 2025
@WeGoToMars
Copy link
Contributor Author

@mxmlnkn
The ISA-L's readme states that gas is required to build it for arm64. I opened the issue about it (intel/isa-l#352), but the check about gas has to be added to rapidgzip for now.

@mxmlnkn
Copy link
Owner

mxmlnkn commented Aug 5, 2025

I tried to get it to work with ISA-L on macOS (macos-13 (x86-64), macos-14/15) in Github Actions but failed to do so. I am running into a myriad of different errors, including weird SIGBUS errors after finally getting it to build!?

I think I'll have to disable ISA-L support for macOS, even though it seemed to have worked somewhat for you (did it? did all the tests run?) and your ISA-L issue even got fixed.

It is also no fun that have I to keep two parallel build systems (CMake and setup.py) up to date. And I have not yet found out how to compile multiarch fat binaries with setup.py for macOS, which it seems to try by default (-arch arm64 -arch x86_64 are both specified by default, which will always fail either the the .asm or .S compilation).

  • When NASM is installed, test-python.yml Python 3.8 macos-13 builds but fails with a BUS error?!

     Thread 0x00007ff8497bda00 (most recent call first):
       File "/Users/runner/work/indexed_bzip2/indexed_bzip2/src/tests/testGIL.py", line 227 in test_issue_26
       File "/Users/runner/[...]/python3.8/site-packages/_pytest/python.py", line 159 in pytest_pyfunc_call
       File "/Users/runner/[...]/python3.8/site-packages/pluggy/_callers.py", line 103 in _multicall
       File "/Users/runner/[...]/python3.8/site-packages/pluggy/_manager.py", line 120 in _hookexec
       File "/Users/runner/[...]/python3.8/site-packages/pluggy/_hooks.py", line 513 in __call__
       File "/Users/runner/[...]/python3.8/site-packages/_pytest/python.py", line 1627 in runtest
       File "/Users/runner/[...]/python3.8/site-packages/_pytest/runner.py", line 174 in pytest_runtest_call
       File "/Users/runner/[...]/python3.8/site-packages/pluggy/_callers.py", line 103 in _multicall
       File "/Users/runner/[...]/python3.8/site-packages/pluggy/_manager.py", line 120 in _hookexec
       File "/Users/runner/[...]/python3.8/site/Users/runner/work/_temp/890e760d-c018-41f5-9bc6-bff31889d574.sh: line 2:  9730 Bus error: 10           python3 -X dev -u -m pytest src/tests/testGIL.py
     src/tests/testGIL.py ..
    

    The build process has lots of warnings, so it could be a problem with multiarch building:

     nasm -Iexternal/isa-l/include -Iexternal/isa-l/igzip -Iexternal/isa-l "-f macho64" -DNOPIE --prefix=_ external/isa-l/crc/crc32_gzip_refl_by16_10.asm -o build/temp.macosx-13.7-x86_64-cpython-38/external/isa-l/crc/crc32_gzip_refl_by16_10.obj
     nasm -Iexternal/isa-l/include -Iexternal/isa-l/igzip -Iexternal/isa-l "-f macho64" -DNOPIE --prefix=_ external/isa-l/crc/crc32_gzip_refl_by8.asm -o build/temp.macosx-13.7-x86_64-cpython-38/external/isa-l/crc/crc32_gzip_refl_by8.obj
    
     g++ -bundle -undefined dynamic_lookup -L/usr/local/opt/sqlite/lib -L/usr/local/opt/sqlite/lib 
       build/rapidgzip.o 
       build/external/isa-l/crc/crc_base.o 
       build/external/isa-l/igzip/adler32_base.o 
       build/external/isa-l/igzip/encode_df.o 
       build/external/isa-l/igzip/flatten_ll.o 
       build/external/isa-l/igzip/huff_codes.o 
       build/external/isa-l/igzip/hufftables_c.o 
       build/external/isa-l/igzip/igzip.o 
       build/external/isa-l/igzip/igzip_base.o 
       build/external/isa-l/igzip/igzip_icf_base.o 
       build/external/isa-l/igzip/igzip_icf_body.o 
       build/external/isa-l/igzip/igzip_inflate.o 
       build/external/rpmalloc/rpmalloc/rpmalloc.o 
       build/external/zlib/adler32.o 
       build/external/zlib/crc32.o 
       build/external/zlib/deflate.o 
       build/external/zlib/inffast.o 
       build/external/zlib/inflate.o 
       build/external/zlib/inftrees.o 
       build/external/zlib/trees.o 
       build/external/zlib/zutil.o 
       build/external/isa-l/crc/crc32_gzip_refl_by16_10.obj 
       build/external/isa-l/crc/crc32_gzip_refl_by8.obj 
       build/external/isa-l/crc/crc32_gzip_refl_by8_02.obj 
       build/external/isa-l/crc/crc_multibinary.obj 
       build/external/isa-l/igzip/adler32_avx2_4.obj 
       build/external/isa-l/igzip/adler32_sse.obj 
       build/external/isa-l/igzip/encode_df_04.obj 
       build/external/isa-l/igzip/encode_df_06.obj 
       build/external/isa-l/igzip/igzip_body.obj 
       build/external/isa-l/igzip/igzip_decode_block_stateless_01.obj 
       build/external/isa-l/igzip/igzip_decode_block_stateless_04.obj 
       build/external/isa-l/igzip/igzip_deflate_hash.obj 
       build/external/isa-l/igzip/igzip_finish.obj 
       build/external/isa-l/igzip/igzip_gen_icf_map_lh1_04.obj 
       build/external/isa-l/igzip/igzip_gen_icf_map_lh1_06.obj 
       build/external/isa-l/igzip/igzip_icf_body_h1_gr_bt.obj 
       build/external/isa-l/igzip/igzip_icf_finish.obj 
       build/external/isa-l/igzip/igzip_inflate_multibinary.obj 
       build/external/isa-l/igzip/igzip_multibinary.obj 
       build/external/isa-l/igzip/igzip_set_long_icf_fg_04.obj 
       build/external/isa-l/igzip/igzip_set_long_icf_fg_06.obj 
       build/external/isa-l/igzip/igzip_update_histogram_01.obj 
       build/external/isa-l/igzip/igzip_update_histogram_04.obj 
       build/external/isa-l/igzip/proc_heap.obj 
       build/external/isa-l/igzip/rfc1951_lookup.obj 
       build/external/isa-l/igzip/stdmac.obj 
       build/external/isa-l/include/multibinary.obj 
       build/external/isa-l/include/reg_sizes.obj -L/Users/runner/hostedtoolcache/Python/3.8.18/x64/lib -o build/lib.macosx-13.7-x86_64-cpython-38/rapidgzip.cpython-38-darwin.so -flto=auto -mmacosx-version-min=10.15 -fstack-clash-protection
    
     ld: warning: no platform load command found in '/private/var/build-via-sdist/rapidgzip-0.14.5/
       build/external/isa-l/crc/crc32_gzip_refl_by16_10.obj', assuming: macOS
     ld: warning: no platform load command found in '/private/var/build-via-sdist/rapidgzip-0.14.5/
       build/external/isa-l/crc/crc32_gzip_refl_by8.obj', assuming: macOS
     ld: warning: no platform load command found in '/private/var/build-via-sdist/rapidgzip-0.14.5/
       build/external/isa-l/crc/crc32_gzip_refl_by8_02.obj', assuming: macOS
     ld: warning: no platform load command found in '/private/var/build-via-sdist/rapidgzip-0.14.5/
       build/external/isa-l/crc/crc_multibinary.obj', assuming: macOS
    
    
  • test-cpp.yml 'Check:' fails on macos for 'use_system_zlib: ON' even though it is installed with brew?!

    • I decidedly only search for static binaries for some reason and I guess brew only installs dynamic ones?
  • test-cpp.yml macos-13 ASAN timeout The address sanitizer on macOS-13 is simply excruciatingly slow. I have increased the timeout from 1500 s to 3000 s.

  • test-cpp.yml timeout on parallel test Check without Sanitizer and with ISA-L (macos-15, OFF) Maybe the same issue as above.

      28: Tests successful: 962 / 962
     27/28 Test #28: testCLI ..........................   Passed  1343.43 sec
     27: Testing "zeros.bgzip" without index (54032 B)
     27: Testing "zeros.bgzip" with generated index (54032 B)
     27: Testing "zeros.python3-gzip" without index (32641 B)
     27: Testing "zeros.python3-gzip" with generated index (32641 B)
     28/28 Test #27: testParallelGzipReader ...........***Timeout 1500.05 sec
    
     96% tests passed, 1 tests failed out of 28
    
     Total Test time (real) = 1543.17 sec
    
     The following tests FAILED:
          27 - testParallelGzipReader (Timeout)
     Errors while running CTest
     Output from these tests are in: /Users/runner/work/indexed_bzip2/indexed_bzip2/build-gcc/Testing/Temporary/LastTest.log
     Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
     ninja: build stopped: subcommand failed.
    
     Error: Process completed with exit code 8.
    
  • test-cpp.yml 'Check:" fails on macos-13 when NASM is installed with:

     2025-08-04T21:15:49.7325840Z [51/108] : && /usr/local/bin/cmake -E rm -f src/libisal_inflate.a && /usr/bin/ar qc src/libisal_inflate.a  
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_inflate.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/hufftables_c.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_base_aliases.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/encode_df.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_icf_base.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_icf_body.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_base.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/adler32_base.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/flatten_ll.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/huff_codes.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/proc_heap_base.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/crc/crc_base.c.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/include/reg_sizes.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/include/multibinary.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_inflate_multibinary.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_decode_block_stateless_01.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_decode_block_stateless_04.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/rfc1951_lookup.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/stdmac.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_deflate_hash.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_body.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_multibinary.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_update_histogram_01.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_update_histogram_04.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/encode_df_04.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/encode_df_06.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_finish.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_gen_icf_map_lh1_04.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_gen_icf_map_lh1_06.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_icf_body_h1_gr_bt.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_icf_finish.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_set_long_icf_fg_04.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/igzip_set_long_icf_fg_06.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/proc_heap.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/adler32_avx2_4.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/igzip/adler32_sse.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/crc/crc_multibinary.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/crc/crc32_gzip_refl_by16_10.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/crc/crc32_gzip_refl_by8_02.asm.o 
       src/CMakeFiles/isal_inflate.dir/external/isa-l/crc/crc32_gzip_refl_by8.asm.o && /usr/bin/ranlib src/libisal_inflate.a && /usr/local/bin/cmake -E touch src/libisal_inflate.a && :
     2025-08-04T21:15:49.8229040Z /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: src/libisal_inflate.a(multibinary.asm.o) has no symbols
     2025-08-04T21:15:49.9237150Z /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: src/libisal_inflate.a(stdmac.asm.o) has no symbols
     2025-08-04T21:15:50.0244070Z /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: src/libisal_inflate.a(multibinary.asm.o) has no symbols
     2025-08-04T21:15:50.1270880Z /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: src/libisal_inflate.a(stdmac.asm.o) has no symbols
      
     2025-08-04T21:17:14.4305950Z : && /Applications/Xcode_15.2.app/Contents/Developer/usr/bin/g++ -g -isysroot /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=10.15 -Wl,-search_paths_first -Wl,-headerpad_max_install_names  src/tests/rapidgzip/CMakeFiles/testGzipIndexFormat.dir/testGzipIndexFormat.cpp.o -o src/tests/rapidgzip/testGzipIndexFormat  src/libzlibstatic.a  src/libisal_inflate.a && :
     2025-08-04T21:17:14.5316230Z ld: Undefined symbols:
     2025-08-04T21:17:14.6339280Z   _crc32_gzip_refl, referenced from:
     2025-08-04T21:17:14.7309070Z       _isal_read_gzip_header in libisal_inflate.a[2](igzip_inflate.c.o)
     2025-08-04T21:17:14.7941000Z       _isal_read_gzip_header in libisal_inflate.a[2](igzip_inflate.c.o)
     2025-08-04T21:17:14.8944360Z       _update_checksum in libisal_inflate.a[2](igzip_inflate.c.o)
     2025-08-04T21:17:14.9949500Z       _isal_write_gzip_header in libisal_inflate.a[3](igzip.c.o)
     2025-08-04T21:17:15.0384110Z       _update_checksum in libisal_inflate.a[3](igzip.c.o)
     2025-08-04T21:17:15.0628710Z clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    It makes no sense because all crc32_gzip_refl files are built and linked. No idea what is still missing.
    Might be sensible to check whether the new ISA-L CMake build system can be used!
    But, it would not help me in writing a working setup.py. Although, I think there were some tries to build
    Python packages via CMake by numpy, if I remember correctly.

I tried using the new ISA-L CMake system but it also seems to be unfinished: intel/isa-l#61 (comment)

If you have time, could you try to run make check or src/tests/rapidgzip/testParallelGzipReader in a loop overnight to check it for deadlocks and BUS errors / race conditions? I have also added a commit raising the MACOSX deployment target as high as possible in the hope that it fixes some deadlock, which I only see on macOS. Probably could have raised it to 14.0 because 13 went EOL a week ago. There were some C++17+ features with threads and/or locks that did not work reliably in C++14, maybe it is something like that caused by a low deployment target. Again, debugging on platforms I do not have locally is a pain, and help would be welcome. A single backtrace from the deadlock and/or BUS error might already help wonders.

#include <rapidgzip/ParallelGzipReader.hpp>

int main() {
// Create a file reader for the gzipped file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this AI-generated?

@mxmlnkn
Copy link
Owner

mxmlnkn commented Aug 6, 2025

Merged manually.

@mxmlnkn mxmlnkn closed this Aug 6, 2025
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