rust-lang / cmake-rs

Rust build dependency for running cmake
https://docs.rs/cmake
Apache License 2.0
301 stars 121 forks source link

Issue with `0.1.49` on Windows i686 cross compilation #171

Open elast0ny opened 1 year ago

elast0ny commented 1 year ago

The latest patch bump of cmake-rs broke our CD/CI when cross compiling to Windows x86 on x86_64 Windows hosts.

The error logs are somewhat misleading but we were able to identify that the root cause was the automatic update from 0.1.48 to 0.1.49 :

error: failed to run custom build command for `my-crate-sys v2.0.12 (C:\tmp\my-crate\my-crate-sys)`

Caused by:
  process didn't exit successfully: `C:\tmp\my-crate\target\debug\build\my-crate-sys-3968ddac5f286e98\build-script-build` (exit code: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_i686-pc-windows-msvc = None
  CMAKE_TOOLCHAIN_FILE_i686_pc_windows_msvc = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_PREFIX_PATH_i686-pc-windows-msvc = None
  CMAKE_PREFIX_PATH_i686_pc_windows_msvc = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_i686-pc-windows-msvc = None
  CMAKE_i686_pc_windows_msvc = None
  TARGET_CMAKE = None
  CMAKE = None
  running: "cmake" "C:\\tmp\\my-crate\\my-crate-sys\\xgboost" "-G" "Ninja" "-DUSE_CUDA=OFF" "-DUSE_OPENMP=OFF" "-DBUILD_STATIC_LIB=ON" "-DCMAKE_INSTALL_PREFIX=C:\\tmp\\my-crate\\target\\i686-pc-windows-msvc\\debug\\build\\my-crate-sys-92f6057c6e2a7e9f\\out\\opt" "-DCMAKE_INSTALL_LIBDIR=C:\\tmp\\my-crate\\target\\i686-pc-windows-msvc\\debug\\build\\my-crate-sys-92f6057c6e2a7e9f\\out\\opt\\lib" "-DDMLC_LOG_CUSTOMIZE=1" "-DRABIT_CUSTOMIZE_MSG_=1" "-DFORCE_SHARED_CRT=ON" "-DCMAKE_CXX_FLAGS_DEBUG=/Z7 /EHs /MD" "-DCMAKE_C_FLAGS_DEBUG=/Z7 /EHs /MD" "-DCMAKE_CXX_FLAGS_RELEASE=/Z7 /EHs" "-DCMAKE_C_FLAGS_RELEASE=/Z7 /EHs" "-DCMAKE_SYSTEM_NAME=windows" "-DCMAKE_SYSTEM_PROCESSOR=x86" "-DCMAKE_C_FLAGS= -nologo -MD -Brepro" "-DCMAKE_C_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe" "-DCMAKE_CXX_FLAGS= -nologo -MD -Brepro" "-DCMAKE_CXX_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe" "-DCMAKE_ASM_FLAGS= -nologo -MD -Brepro" "-DCMAKE_ASM_COMPILER=C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe" "-DCMAKE_BUILD_TYPE=Debug"
  -- The CXX compiler identification is MSVC 19.28.29924.0
  -- The C compiler identification is MSVC 19.28.29924.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/HostX86/x86/cl.exe - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- CMake version 3.24.0-rc2
  -- Performing Test XGBOOST_MM_PREFETCH_PRESENT
  -- Performing Test XGBOOST_MM_PREFETCH_PRESENT - Success
  -- Performing Test XGBOOST_BUILTIN_PREFETCH_PRESENT
  -- Performing Test XGBOOST_BUILTIN_PREFETCH_PRESENT - Failed
  -- xgboost VERSION: 1.6.1
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
  -- Looking for pthread_create in pthreads
  -- Looking for pthread_create in pthreads - not found
  -- Looking for pthread_create in pthread
  -- Looking for pthread_create in pthread - not found
  -- Check if compiler accepts -pthread
  -- Check if compiler accepts -pthread - no
  -- Configuring incomplete, errors occurred!
  See also "C:/tmp/my-crate/target/i686-pc-windows-msvc/debug/build/my-crate-sys-92f6057c6e2a7e9f/out/build/CMakeFiles/CMakeOutput.log".
  See also "C:/tmp/my-crate/target/i686-pc-windows-msvc/debug/build/my-crate-sys-92f6057c6e2a7e9f/out/build/CMakeFiles/CMakeError.log".

  --- stderr
  CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find Threads (missing: Threads_FOUND)
  Call Stack (most recent call first):
    C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
    C:/Program Files/CMake/share/cmake-3.24/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    CMakeLists.txt:163 (find_package)

  thread 'main' panicked at '
  command did not execute successfully, got: exit code: 1

  build script failed, must exit now', C:\tmp\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.49\src\lib.rs:1104:5

One noticeable change from 0.1.48 is that the failing cmake command now has new arguments : "-DCMAKE_SYSTEM_NAME=windows" "-DCMAKE_SYSTEM_PROCESSOR=x86"

But its not clear to me why this would cause the failure seen above...

jrose-signal commented 1 year ago

I think this is the same as what we (belatedly) ran into here: https://github.com/rust-lang/cmake-rs/pull/158#issuecomment-1544695163

Which we found a workaround for: set CMAKE_SYSTEM_NAME to an empty string, which counts as defined for this crate, but unset for CMake itself. But we downgraded to 0.1.48 anyway.

thomcc commented 1 year ago

Does updating to 0.1.50 fix it? It should...

thomcc commented 1 year ago

My impression is these issues were fixed by https://github.com/rust-lang/cmake-rs/pull/176 (which appeared in 0.1.50)

thomcc commented 1 year ago

Oh, that only fixes it for iOS, of course. Hmm...

anvlkv commented 5 months ago

Hi, it seems I'm running into similar issue on macos/xcode/building for iOS

I'm getting this when trying to build libpd-rs which depends on cmake=0.1.50, I've also tried with 0.1.49 and getting the same error.

-- Configuring incomplete, errors occurred!

  --- stderr
  CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.

     Called from: [1]   /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpd-sys-0.2.1/libpd/CMakeLists.txt
  CMake Warning (dev) at CMakeLists.txt:2 (project):
    Policy CMP0025 is not set: Compiler id for Apple Clang is now AppleClang.
    Run "cmake --help-policy CMP0025" for policy details.  Use the cmake_policy
    command to set the policy and suppress this warning.

    Converting C compiler id "AppleClang" to "Clang" for compatibility.
  This warning is for project developers.  Use -Wno-dev to suppress it.

     Called from: [1]   /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpd-sys-0.2.1/libpd/CMakeLists.txt
  CMake Error at /usr/local/Cellar/cmake/3.29.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find Threads (missing: Threads_FOUND)
  Call Stack (most recent call first):
    /usr/local/Cellar/cmake/3.29.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
    /usr/local/Cellar/cmake/3.29.1/share/cmake/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    CMakeLists.txt:193 (find_package)

     Called from: [4]   /usr/local/Cellar/cmake/3.29.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake
                  [3]   /usr/local/Cellar/cmake/3.29.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake
                  [2]   /usr/local/Cellar/cmake/3.29.1/share/cmake/Modules/FindThreads.cmake
                  [1]   /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libpd-sys-0.2.1/libpd/CMakeLists.txt
  thread 'main' panicked at /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/4fd4797c2654977f545c9a91e2aa4e6cdbb38919/library/std/src/panicking.rs:645:5
     1: core::panicking::panic_fmt
               at /rustc/4fd4797c2654977f545c9a91e2aa4e6cdbb38919/library/core/src/panicking.rs:72:14
     2: cmake::fail
               at /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5
     3: cmake::run
               at /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1076:9
     4: cmake::Config::build
               at /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:813:13
     5: build_script_build::main
               at ./build.rs:227:31
     6: core::ops::function::FnOnce::call_once
               at /rustc/4fd4797c2654977f545c9a91e2aa4e6cdbb38919/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `libffi-sys v2.3.0`

Caused by:
  process didn't exit successfully: `/Users/anvlkv/Library/Developer/Xcode/DerivedData/YoganOme-eaufureccnthrwciwmokvwlekuow/Build/Intermediates.noindex/app_core.build/cargo_target/debug/build/libffi-sys-1e4bce6889f2e948/build-script-build` (exit status: 101)
  --- stdout
  checking build system type... x86_64-apple-darwin21.6.0
  checking host system type... aarch64-apple-ios
  checking target system type... aarch64-apple-ios
  continue configure in default builddir "./aarch64-apple-ios"
  ....exec /bin/sh .././configure "--srcdir=.." "--enable-builddir=aarch64-apple-ios" "ios"
  checking build system type... x86_64-apple-darwin21.6.0
  checking host system type... aarch64-apple-ios
  checking target system type... aarch64-apple-ios
  checking for gsed... sed
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  checking for aarch64-apple-ios-strip... no
  checking for strip... strip
  checking for a race-free mkdir -p... ../install-sh -c -d
  checking for gawk... no
  checking for mawk... no
  checking for nawk... no
  checking for awk... awk
  checking whether make sets $(MAKE)... yes
  checking whether make supports nested variables... yes
  checking for aarch64-apple-ios-gcc... clang
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables... 
  checking whether we are cross compiling... yes
  checking for suffix of object files... o
  checking whether the compiler supports GNU C... yes
  checking whether clang accepts -g... yes
  checking for clang option to enable C11 features... none needed
  checking whether clang understands -c and -o together... yes
  checking whether make supports the include directive... yes (GNU style)
  checking dependency style of clang... gcc3
  checking for aarch64-apple-ios-g++... no
  checking for aarch64-apple-ios-c++... no
  checking for aarch64-apple-ios-gpp... no
  checking for aarch64-apple-ios-aCC... no
  checking for aarch64-apple-ios-CC... no
  checking for aarch64-apple-ios-cxx... no
  checking for aarch64-apple-ios-cc++... no
  checking for aarch64-apple-ios-cl.exe... no
  checking for aarch64-apple-ios-FCC... no
  checking for aarch64-apple-ios-KCC... no
  checking for aarch64-apple-ios-RCC... no
  checking for aarch64-apple-ios-xlC_r... no
  checking for aarch64-apple-ios-xlC... no
  checking for aarch64-apple-ios-clang++... no
  checking for g++... g++
  checking whether the compiler supports GNU C++... yes
  checking whether g++ accepts -g... yes
  checking for g++ option to enable C++11 features... none needed
  checking dependency style of g++... gcc3
  checking dependency style of clang... gcc3
  checking for grep that handles long lines and -e... /usr/bin/grep
  checking for egrep... /usr/bin/grep -E
  checking how to print strings... printf
  checking for a sed that does not truncate output... /usr/bin/sed
  checking for fgrep... /usr/bin/grep -F
  checking for ld used by clang... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
  checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
  checking for BSD- or MS-compatible name lister (nm)... no
  checking for aarch64-apple-ios-dumpbin... no
  checking for aarch64-apple-ios-link... no
  checking for dumpbin... no
  checking for link... link -dump
  checking the name lister (nm) interface... BSD nm
  checking whether ln -s works... yes
  checking the maximum length of command line arguments... 786432
  checking how to convert x86_64-apple-darwin21.6.0 file names to aarch64-apple-ios format... func_convert_file_noop
  checking how to convert x86_64-apple-darwin21.6.0 file names to toolchain format... func_convert_file_noop
  checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
  checking for aarch64-apple-ios-file... no
  checking for file... file
  checking for aarch64-apple-ios-objdump... no
  checking for objdump... objdump
  checking how to recognize dependent libraries... unknown
  checking for aarch64-apple-ios-dlltool... no
  checking for dlltool... no
  checking how to associate runtime and link libraries... printf %s\n
  checking for aarch64-apple-ios-ar... no
  checking for ar... ar
  checking for archiver @FILE support... no
  checking for aarch64-apple-ios-strip... strip
  checking for aarch64-apple-ios-ranlib... no
  checking for ranlib... ranlib
  checking command to parse nm output from clang object... ok
  checking for sysroot... no
  checking for a working dd... /bin/dd
  checking how to truncate binary pipes... /bin/dd bs=4096 count=1
  checking for aarch64-apple-ios-mt... no
  checking for mt... no
  checking if : is a manifest tool... no
  checking for stdio.h... yes
  checking for stdlib.h... yes
  checking for string.h... yes
  checking for inttypes.h... yes
  checking for stdint.h... yes
  checking for strings.h... yes
  checking for sys/stat.h... yes
  checking for sys/types.h... yes
  checking for unistd.h... yes
  checking for dlfcn.h... yes
  checking for objdir... .libs
  checking if clang supports -fno-rtti -fno-exceptions... yes
  checking for clang option to produce PIC... -fPIC -DPIC
  checking if clang PIC flag -fPIC -DPIC works... yes
  checking if clang static flag -static works... no
  checking if clang supports -c -o file.o... yes
  checking if clang supports -c -o file.o... (cached) yes
  checking whether the clang linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... no
  checking dynamic linker characteristics... no
  checking how to hardcode library paths into programs... unsupported
  checking whether stripping libraries is possible... no
  checking if libtool supports shared libraries... no
  checking whether to build shared libraries... no
  checking whether to build static libraries... yes
  checking how to run the C++ preprocessor... /lib/cpp

  --- stderr
  rm: conftest.dSYM: is a directory
  configure: WARNING: using cross tools not prefixed with host triplet
  rm: conftest.dSYM: is a directory
  rm: conftest.dSYM: is a directory
  rm: conftest.dSYM: is a directory
  configure: error: in `/Users/anvlkv/Library/Developer/Xcode/DerivedData/YoganOme-eaufureccnthrwciwmokvwlekuow/Build/Intermediates.noindex/app_core.build/cargo_target/aarch64-apple-ios/debug/build/libffi-sys-88109915fa461874/out/libffi-build/aarch64-apple-ios':
  configure: error: C++ preprocessor "/lib/cpp" fails sanity check
  See `config.log' for more details
  thread 'main' panicked at /Users/anvlkv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libffi-sys-2.3.0/build/common.rs:8:5:
  Configuring libffi
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/4fd4797c2654977f545c9a91e2aa4e6cdbb38919/library/std/src/panicking.rs:645:5
     1: core::panicking::panic_fmt
               at /rustc/4fd4797c2654977f545c9a91e2aa4e6cdbb38919/library/core/src/panicking.rs:72:14
     2: core::panicking::panic_display
               at /rustc/4fd4797c2654977f545c9a91e2aa4e6cdbb38919/library/core/src/panicking.rs:256:5
     3: build_script_build::common::run_command
               at ./build/common.rs:8:5
     4: build_script_build::not_msvc::configure_libffi
               at ./build/not_msvc.rs:123:5
     5: build_script_build::not_msvc::build_and_link
               at ./build/not_msvc.rs:26:5
     6: build_script_build::main
               at ./build/build.rs:16:9
     7: core::ops::function::FnOnce::call_once
               at /rustc/4fd4797c2654977f545c9a91e2aa4e6cdbb38919/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
+ command -v rustup
+ rustup target list --installed
+ grep -Eq aarch64-apple-ios
+ echo 'error: cargo build failed'
error: cargo build failed
+ exit 1