Skip to content

Conversation

@Eta0
Copy link
Contributor

@Eta0 Eta0 commented Nov 17, 2025

Improved compatibility + -- support

Howdy!

This PR has a few fixes for building the project, as well as a new feature or two, and a fix for a segfault.

New features

  • 7b9b642 You can now use -- to stop parsing CLI options and move on to positional arguments
    • Example: ect -9 -- -Image-.png
      • Treats -9 as an option
      • Treats -Image-.png as a filename

Following Unix argument passing conventions, specifying "--" by itself as a command line argument signifies that every argument that follows should be treated as positional rather than as an option, even if it starts with a dash. This allows for easily passing filenames as arguments that have names beginning with dashes.

  • 89a48eb On Windows, you can now use ect on files with paths with multi-byte characters, as well as on paths longer than 260 characters
    • This is achieved by adding a manifest file to Windows builds

Build improvements

  • 5aa1946 LTO is now enabled in CMake for release builds, where supported

Build fixes

  • 59b6a33 Building the project with CMake no longer fails if you don't have an external installation of zlib, or a previous, working build
    • Previously, configuring libpng would fail on a fresh build because its find_package call to locate zlib would fail on account of not being able to find the library file. The library file doesn't exist at configure time, since it is a target that is built at build time, so this required a workaround to force find_package to find the path that the built library will eventually take
    • This didn't fail in some environments (including CI, in particular) because libpng's find_package call would fall back to finding the system zlib for the first build, and would only pick up on the custom zlib on subsequent builds in the same build tree
    • This also means that some working builds of ect may be using an entirely wrong zlib library (whatever system version find_package found)
  • 2485c12 Building the project with C++11 no longer fails on some toolchains (e.g. with GCC from MinGW) due to missing definitions from headers
    • Some code #include-ing main.h was relying on the <filesystem> header to transitively include <cstdint>, and would break if <filesystem> wasn't included, even if it was not otherwise using <filesystem> at all
    • Now main.h just also includes <cstdint>
  • ab8138e Building the project with MinGW now links more-statically
    • In particular, libraries such as libgcc and libstdc++ were still being linked dynamically in some cases
    • Now CMakeLists.txt tries its darndest to make things static
  • f42973d Compiling with MSVC no longer fails due to usage of some GCC/Clang-specific extensions
  • 41321b8 Compiling with MSVC now more accurately detects when <filesystem> features can be enabled

Non-build fixes

  • ca11bac Multiple parts of LzFind.c have been changed to not violate strict aliasing rules
    • These were causing segfaults for me when compiler optimizations were enabled with MinGW GCC (specifically, on line 232 before these changes)

P.S.

Thanks for the cool project!
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠏⣼⣿⣿⣧⠈⢷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣾⣀⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⠋⣰⣿⣿⣿⣿⠗⠈⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣠⣤⣤⣶⣞⣿⠿⠟⢻⡏
⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⠃⣼⣿⣿⣿⣿⣿⡄⠀⣷⠐⣶⣶⣶⣤⣤⣀⠀⣠⣴⣾⣿⣿⠿⠛⢋⣉⣡⣤⣴⣾⠃⢸⠇
⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⠃⣼⣿⣿⣿⣿⣿⡿⠟⠀⣿⢀⣿⣿⣿⣿⣟⣡⣾⣿⣿⣿⠟⣡⣴⣿⣿⣿⣿⣿⣿⣿⠇⠈
⠀⠀⠀⠀⠀⢀⣾⣿⣿⡏⠰⣿⠿⠟⠻⢿⡟⠰⠖⠚⠛⣻⣿⣿⣿⣿⣿⣿⣿⣿⠟⠃⠘⠿⣿⣿⣿⣿⣿⣿⣿⡇⡰
⠀⠀⠀⠀⡀⣼⣿⣿⣿⡇⢀⣠⣶⡿⠗⣀⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣌⣙⠻⠿⠋⠉⡁⠁
⠀⠀⠀⣸⡇⣿⣿⣿⣿⣿⣿⡿⢋⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣄⣀⡀
⠀⠀⢰⣿⣿⣾⣿⣿⣿⡿⠋⣴⣿⣿⣿⡿⣿⣿⣿⣿⢛⣿⣿⣿⣿⠿⣿⡿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⠙⠁
⠀⠀⣾⣿⣿⣿⣿⣿⡿⢁⣾⣿⣿⣿⠋⣼⣿⣿⡿⠃⢸⣿⣿⣿⡏⢸⣿⡏⠀⠹⣿⣿⣧⠹⣿⣿⣿⣿⡻⣿⣷⡀
⠀⠀⣿⣿⣿⣿⣿⡿⢁⣾⣿⣿⣿⠃⣼⠿⠿⠟⠁⠠⠾⢿⣿⠏⢀⣿⣿⠃⣆⠀⢹⣿⣿⠀⢻⣿⣿⣿⡇⢿⣿⣷
⠀⠀⣿⣿⣿⣿⣿⠃⣼⣿⣿⣿⡇⠀⣴⠖⠀⠀⢀⡶⢤⡄⠁⠀⣼⡿⠃⣼⣿⡀⢸⣿⡿⠀⠘⣿⣿⣿⡇⢸⣿⣿⡇
⠀⠀⣿⣿⣿⣿⠇⠀⣿⣿⣿⣿⠀⠔⠁⠀⠁⠀⠀⠈⠁⠀⠁⢰⠟⣡⣾⣿⣿⠇⠀⢉⠁⠀⠀⠛⠿⣿⠇⣸⣿⣿⣷
⠀⠀⢿⣿⣿⣿⠀⢠⣿⣿⣿⣿⠀⠀⠀⠀⣤⣤⠀⠀⠀⠀⠀⠁⣾⣿⣿⣿⣿⣷⠀⠏⣼⡇⠀⣷⣦⡜⠀⣿⣿⣿⡏
⠀⠀⢸⣿⣿⡏⠀⠸⠿⠿⣿⣿⠀⣾⡇⠀⢿⠟⠀⠀⠀⠀⣦⣸⣿⣿⣿⣿⣿⢟⢀⡼⠿⠇⢠⣿⡿⠁⠀⣿⣿⣿⠃
⠀⠀⠘⣿⣿⠇⢀⣤⣶⣄⠈⢿⡀⢻⡇⠀⠀⠀⢀⡀⠀⢸⣿⣿⣿⣿⣿⣿⡟⠁⠀⠀⠀⠀⠀⠙⢠⡂⠀⣿⡿⠁
⠀⠀⠀⣿⡏⠀⣾⣿⣿⣿⠀⢸⣧⠘⣿⡀⠀⠀⠈⠁⢀⣾⣿⣿⣿⣿⣿⣿⣏⢀⣠⣤⣄⣠⣀⠀⢠⠁⠐⠋
⠀⠀⠀⣿⣧⠀⢿⣿⣿⣿⡄⠘⠿⣧⠸⣿⣦⣤⣤⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣯⠀⢸⡇
⠀⠀⠀⣿⠟⠀⢈⣛⠻⢿⣧⠀⠀⢈⣁⡘⣿⣿⣿⣿⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⢸⡇
⠀⠀⠀⠁⣠⣾⣿⣿⣷⣦⠙⢷⡄⠀⢻⣿⣿⣿⣿⣿⣿⣷⣌⠻⢿⣿⣿⢟⣡⣿⣿⣿⣿⣿⣿⣿⣿⠀⣿⣷
⠀⠀⡀⠀⣿⡿⠿⢛⣛⠛⠇⢸⣷⠀⠀⠙⠿⢿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠰⣿⣿⣇
⠀⢀⣿⠀⢹⣷⣿⣿⣿⣿⣦⡈⢿⠀⡄⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⡿⠿⠛⠛⠛⠋⠉⠀⠀⠀⠀⢿⣿⣿⡀
⠀⣼⣿⡀⢸⣿⣿⠿⠛⣛⡛⠃⢸⡆⠸⠀⢰⡀⠀⠀⠀⠀⠤⠠⠤⠡⠁⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠘⣿⣿⡇
⢰⣿⣿⡇⠀⢹⣷⣾⣿⣿⣿⡇⢈⣯⠀⠂⠸⣷⠀⠀⠀⠀⠀⠀⠠⠐⠀⠀⠀⠀⠀⠀⠀⠘⡄⠀⠀⠀⠀⣿⣿⣿
⣾⣿⣿⡇⠀⠀⢹⣟⣉⣉⣥⣤⠈⡿⠀⠀⢰⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⢠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿
⣿⣿⣿⡇⠀⠀⠀⠛⠛⠛⠛⠁⠀⠀⠀⢀⣾⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⡇

@fhanau
Copy link
Owner

fhanau commented Nov 27, 2025

Thank you for your suggested changes! Took a look at the changes and will have to think some more about some of them, but I just landed a build cleanup commit that obviates the need for 41321b8 (we'll always require filesystem to be supported, modern compilers should all have good C++17 support), and I cherry-picked 2485c12 as well as f42973d which are uncontroversial. I hope to look at the other changes in the coming days.

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