cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.21k stars 354 forks source link

zig build error: UnknownOperatingSystem, on aarch64 opencv-rs version 0.91.2 #1479

Closed DennisZhangOiler closed 2 months ago

DennisZhangOiler commented 2 months ago

Checklist

Describe your issue

without specific zig version, it's able to be compiled, with zig version = 2.27, following log reported:

The following warnings were emitted during compilation:

warning: opencv@0.91.2: error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-calib3d.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/calib3d.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-core.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/core.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/c7e00ddeaf254fbf-manual-core.o" "-c" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp/manual-core.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-dnn.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/dnn.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-features2d.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/features2d.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-flann.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/flann.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-highgui.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/highgui.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-imgcodecs.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/imgcodecs.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-imgproc.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/imgproc.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-ml.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/ml.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-objdetect.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/objdetect.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-photo.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/photo.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:rerun-if-env-changed=CXX_aarch64-unknown-linux-gnu
warning: opencv@0.91.2: error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-stitching.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/stitching.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-video.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/video.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).cargo:warning=error: UnknownOperatingSystem
warning: opencv@0.91.2: ToolExecError: Command "/target/.zig-cache/cargo-zigbuild/0.17.3/zigcxx-aarch64-unknown-linux-gnu.2.27.sh" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=aarch64-unknown-linux-gnu" "-std=c++14" "-I" "/home/dennis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.91.2/src_cpp" "-I" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out" "-I" "." "-I" "/opencv/platforms/linux/build/install/include/opencv4" "-Wall" "-Wextra" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/0de9285bc4b8b0c1-videoio.o" "-c" "/target/aarch64-unknown-linux-gnu/debug/build/opencv-bb13004260793875/out/videoio.cpp" with args zigcxx-aarch64-unknown-linux-gnu.2.27.sh did not execute successfully (status code exit status: 1).

error: failed to run custom build command for `opencv v0.91.2`

What target(s) are you cross-compiling for?

aarch64-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.5 (6d097fb 2024-04-12)

Example

No response

Additional information / notes

My dockerfile:

ARG CROSS_BASE_IMAGE
FROM $CROSS_BASE_IMAGE

# requirements of bindgen, see https://rust-lang.github.io/rust-bindgen/requirements.html
RUN DEBIAN_FRONTEND=noninteractive apt install -y llvm-dev libclang-dev clang 

# cross compile opencv, see https://docs.opencv.org/4.x/d0/d76/tutorial_arm_crosscompile_with_cmake.html
RUN DEBIAN_FRONTEND=noninteractive apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
RUN apt install -y \
    git \
    cmake \
    pkgconf \
    build-essential \
    ninja-build \
    crossbuild-essential-armhf \
    crossbuild-essential-arm64
RUN git clone --depth 1 --branch '4.1.1' https://github.com/opencv/opencv.git && \
    cd opencv/platforms/linux && \
    mkdir build && \
    cd build && \
    cmake -DCMAKE_TOOLCHAIN_FILE=../aarch64-gnu.toolchain.cmake ../../.. && \
    make && \
    make install

ENV CMAKE_PREFIX_PATH="/opencv/platforms/linux/build/install"
Emilgardis commented 2 months ago

This should be fixed by bumping the version to 0.17.5

https://github.com/cross-rs/cross/blob/6d097fb548ec121c2a0faf1c1d8ef4ca360d6750/docker/zig.sh#L122

Feel free to submit a PR

see https://github.com/rust-cross/cargo-zigbuild/pull/199

DennisZhangOiler commented 2 months ago

@Emilgardis Thank you so much! How can I manually fix this? Or should I open a PR and reference to this issue?