freetype-sys icon indicating copy to clipboard operation
freetype-sys copied to clipboard

Linux Build CMake Error `--parallel` no longer supported

Open Jaffa-Cakes opened this issue 3 years ago • 2 comments

When using cargo build on Amazon Linux 5.2, I run into the following error. One of my dependencies depends on this library. After looking up the issue, it seems that --parallel has been removed from CMake since 3.20.

Reference: https://gitlab.kitware.com/cmake/cmake/-/issues/21978

This is preventing my entire project from building, I don't have a fix other than using an older CMake version.

error: failed to run custom build command for `freetype-sys v0.13.1`

Caused by:
  process didn't exit successfully: `/home/ec2-user/target/release/build/freetype-sys-c68579aa2b3671b8/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=FREETYPE2_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=FREETYPE2_STATIC
  cargo:rerun-if-env-changed=FREETYPE2_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
  CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
  CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-unknown-linux-gnu = None
  CMAKE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE = None
  CMAKE = None
  running: "cmake" "/home/ec2-user/.cargo/registry/src/github.com-1ecc6299db9ec823/freetype-sys-0.13.1/freetype2" "-DWITH_BZip2=OFF" "-DWITH_HarfBuzz=OFF" "-DWITH_PNG=OFF" "-DWITH_ZLIB=OFF" "-DCMAKE_INSTALL_PREFIX=/home/ec2-user/target/release/build/freetype-sys-44b141b68bdcfa7a/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- The C compiler identification is GNU 7.3.1
  -- The CXX compiler identification is GNU 7.3.1
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Creating directory /home/ec2-user/target/release/build/freetype-sys-44b141b68bdcfa7a/out/build/include/freetype/config
  -- Creating file /home/ec2-user/target/release/build/freetype-sys-44b141b68bdcfa7a/out/build/include/freetype/config/ftconfig.h
  -- Looking for unistd.h
  -- Looking for unistd.h - found
  -- Looking for fcntl.h
  -- Looking for fcntl.h - found
  -- Looking for stdint.h
  -- Looking for stdint.h - found
  -- Creating file /home/ec2-user/target/release/build/freetype-sys-44b141b68bdcfa7a/out/build/include/freetype/config/ftoption.h
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/ec2-user/target/release/build/freetype-sys-44b141b68bdcfa7a/out/build
  running: "cmake" "--build" "." "--target" "install" "--config" "Release" "--parallel" "2"

  --- stderr
  CMake Warning:
    Manually-specified variables were not used by the project:

      CMAKE_ASM_COMPILER
      CMAKE_ASM_FLAGS


  Unknown argument --parallel
  Unknown argument 2
  Usage: cmake --build <dir> [options] [-- [native-options]]
  Options:
    <dir>          = Project binary directory to be built.
    --target <tgt> = Build <tgt> instead of default targets.
    --config <cfg> = For multi-configuration tools, choose <cfg>.
    --clean-first  = Build target 'clean' first, then build.
                     (To clean only, use --target 'clean'.)
    --use-stderr   = Don't merge stdout/stderr output and pass the
                     original stdout/stderr handles to the native
                     tool so it can use the capabilities of the
                     calling terminal (e.g. colored output).
    --             = Pass remaining options to the native tool.
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', /home/ec2-user/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Jaffa-Cakes avatar Jan 10 '22 14:01 Jaffa-Cakes

I also ran into this issue. As mentioned in https://gitlab.kitware.com/cmake/cmake/-/issues/21978

Starting in CMake 3.20, the cmake command line now errors out when passed invalid flags. The -j flag is invalid when configuring a project ( what you are doing ). It should be passed when compiling the project ( cmake --build )

Since this problem is occurring in "cmake" "--build" "." "--target" "install" "--config" "Release" "--parallel" "2" it's not that cmake is too new. Actually it's most likely that cmake is too old. This is fixed in https://github.com/rust-lang/cmake-rs/commit/93856b272e101f2e29f423b809fb851e89f4b5ee but that commit has not been included in a release yet for some reason. Unfortunately the NUM_JOBS variable is set by cargo (here) and I'm not sure there's a good way to skip it, so I guess the answer is either upgrade to at least cmake 3.12 or wait for the next cmake-rs release (https://github.com/rust-lang/cmake-rs/issues/154).

josuf107 avatar Aug 18 '22 03:08 josuf107

As a workaround you can change the cmake version under [build-dependencies] to "<=0.1.45" until 0.1.49 comes out

josuf107 avatar Aug 18 '22 15:08 josuf107

This crate no longer uses cmake, so this won't happen any longer.

@bvssvni This can be closed.

waywardmonkeys avatar Aug 03 '24 00:08 waywardmonkeys