inflation / jpegxl-rs

GNU General Public License v3.0
62 stars 12 forks source link

Cross-compiling with vendored for x86_64-pc-windows-gnu fails #45

Closed gucki closed 5 months ago

gucki commented 6 months ago

The error is:

error: failed to run custom build command for `jpegxl-sys v0.10.2+libjxl-0.10.2`

Caused by:
  process didn't exit successfully: `/workspace/target/debug/build/jpegxl-sys-4d801a1eb282375b/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-pc-windows-gnu = None
  CMAKE_GENERATOR_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-pc-windows-gnu = None
  CMAKE_PREFIX_PATH_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-pc-windows-gnu = None
  CMAKE_x86_64_pc_windows_gnu = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/workspace/target/x86_64-pc-windows-gnu/debug/build/jpegxl-sys-69e95b23125de8a8/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/workspace/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jpegxl-src-0.10.4/libjxl" "-DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres" "-DBUILD_SHARED_LIBS=OFF" "-DBUILD_TESTING=OFF" "-DJPEGXL_ENABLE_TOOLS=OFF" "-DJPEGXL_ENABLE_DOXYGEN=OFF" "-DJPEGXL_ENABLE_MANPAGES=OFF" "-DJPEGXL_ENABLE_BENCHMARK=OFF" "-DJPEGXL_ENABLE_EXAMPLES=OFF" "-DJPEGXL_ENABLE_JNI=OFF" "-DJPEGXL_ENABLE_SJPEG=OFF" "-DJPEGXL_ENABLE_OPENEXR=OFF" "-DJPEGXL_ENABLE_JPEGLI=OFF" "-DCMAKE_SYSTEM_NAME=Windows" "-DCMAKE_SYSTEM_PROCESSOR=AMD64" "-DCMAKE_INSTALL_PREFIX=/workspace/target/x86_64-pc-windows-gnu/debug/build/jpegxl-sys-69e95b23125de8a8/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc" "-DCMAKE_BUILD_TYPE=Debug"
  -- CMAKE_SYSTEM_PROCESSOR is AMD64
  -- Compiled IDs C:GNU, C++:GNU
  -- Disabled AVX512 (set JPEGXL_ENABLE_AVX512 to enable it)
  -- Disabled AVX512_SPR (set JPEGXL_ENABLE_AVX512_SPR to enable it)
  -- Disabled AVX512_ZEN4 (set JPEGXL_ENABLE_AVX512_ZEN4 to enable it)
  -- Build type is 'Debug'
  -- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11")
  -- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
  -- Building with JPEGXL_VERSION=(unknown)
  -- Building tools:
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /workspace/target/x86_64-pc-windows-gnu/debug/build/jpegxl-sys-69e95b23125de8a8/out/build
  running: cd "/workspace/target/x86_64-pc-windows-gnu/debug/build/jpegxl-sys-69e95b23125de8a8/out/build" && MAKEFLAGS="-j --jobserver-fds=7,8 --jobserver-auth=7,8" "cmake" "--build" "." "--target" "install" "--config" "Debug"
  Consolidate compiler generated dependencies of target jxl_export
  Consolidate compiler generated dependencies of target brotlicommon
  Consolidate compiler generated dependencies of target jxl_threads
  [  0%] Built target jxl_export
  [  4%] Built target brotlicommon
  Consolidate compiler generated dependencies of target hwy
  [  5%] Building CXX object lib/CMakeFiles/jxl_threads.dir/threads/resizable_parallel_runner.cc.obj
  [  5%] Building CXX object lib/CMakeFiles/jxl_threads.dir/threads/thread_parallel_runner.cc.obj
  [  6%] Building CXX object lib/CMakeFiles/jxl_threads.dir/threads/thread_parallel_runner_internal.cc.obj
  Consolidate compiler generated dependencies of target brotlidec
  [  9%] Built target hwy
  Consolidate compiler generated dependencies of target brotlienc
  [ 11%] Built target brotlidec
  Consolidate compiler generated dependencies of target hwy_test
  Consolidate compiler generated dependencies of target hwy_list_targets
  [ 23%] Built target brotlienc
  Consolidate compiler generated dependencies of target jxl_cms
  [ 24%] Built target hwy_test
  [ 25%] Built target hwy_list_targets
  Consolidate compiler generated dependencies of target brotli
  [ 27%] Built target jxl_cms
  [ 27%] Built target brotli
  Consolidate compiler generated dependencies of target jxl_enc-obj
  [ 54%] Built target jxl_enc-obj
  Consolidate compiler generated dependencies of target jxl_dec-obj
  [ 96%] Built target jxl_dec-obj
  [ 97%] Built target jxl_dec-internal
  [ 97%] Built target jxl-internal
  [ 98%] Built target jxl_dec
  [ 98%] Built target jxl
  Consolidate compiler generated dependencies of target jxl_gauss_blur
  [100%] Built target jxl_gauss_blur

  --- stderr
  -- Compiler is not EMSCRIPTEN
  gmake: warning: -j12 forced in submake: resetting jobserver mode.
  In file included from /workspace/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jpegxl-src-0.10.4/libjxl/lib/threads/thread_parallel_runner.cc:15:
  /workspace/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jpegxl-src-0.10.4/libjxl/lib/threads/thread_parallel_runner_internal.h:141:20: error: ‘thread’ is not a member of ‘std’
    141 |   std::vector<std::thread> threads_;
        |                    ^~~~~~
  /workspace/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jpegxl-src-0.10.4/libjxl/lib/threads/thread_parallel_runner_internal.h:46:1: note: ‘std::thread’ is defined in header ‘<thread>’; did you forget to ‘#include <thread>’?
    45 | #include <vector>
    +++ |+#include <thread>
    46 |
  /workspace/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jpegxl-src-0.10.4/libjxl/lib/threads/thread_parallel_runner_internal.h:141:20: error: ‘thread’ is not a member of ‘std’
    141 |   std::vector<std::thread> threads_;
        |                    ^~~~~~

The build runs in a docker container, which basically looks like this:

FROM rust:1.77-bookworm

RUN apt update
RUN apt install -y mingw-w64 cmake
RUN rustup target add x86_64-pc-windows-gnu

WORKDIR /workspace
inflation commented 6 months ago

It's probably an upstream problem. Have you tried to build libjxl in this setup?

inflation commented 5 months ago

https://github.com/libjxl/libjxl/blob/main/doc/developing_with_crossroad.md#update-debian-alternatives

You need to use the posix threads version of mingw. Tested it works.

gucki commented 5 months ago

@inflation Thank you very much! I can confirm it works. Just in case it might help others, here's the Dockerfile I'm using for my builds:

FROM rust:1.77-bookworm

RUN apt update
RUN apt install -y mingw-w64 cmake
RUN update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
RUN update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
RUN update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
RUN update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix

RUN rustup target add x86_64-pc-windows-gnu