[cmake-developers] Build failure due to {cd bindir} failed on Windows/Ninja

Ben Boeckel ben.boeckel at kitware.com
Mon Jan 1 09:42:53 EST 2018


On Fri, Dec 29, 2017 at 13:32:54 -0800, Jom O'Fisher wrote:
> >> Ninja should be using relative paths for the build tree and absolute
> for anything outside of it.
> That appears to be the case, so I need a better theory. I noticed another
> difference between compilation phase and link phase. The link phase is
> bracketed by cmd.exe /C "cd . && <actual-link-command> && cd .".
> I'm wondering problem those "cd ." calls are solving? Their presences is
> what's causing everything to be wrapped in "cmd /C"

They're the "no-op" of the PRE_LINK and POST_LINK commands for targets.

> Here's the error that encapsulates the failure
> 
> CMake Error at D:/Android/sdk/cmake/3.6.3155560/share/cmake-3.6/
> Modules/CMakeTestCCompiler.cmake:61 (message):
>   The C compiler
>   "D:/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/
> windows-x86_64/bin/clang.exe"
>   is not able to compile a simple test program.
>   It fails with the following output:
>    Change Dir: D:/src/MyApplication/app/.externalNativeBuild/cmake/
> debug/armeabi/CMakeFiles/CMakeTmp
> 
>   Run Build Command:"D:\Android\sdk\cmake\3.6.3155560\bin\ninja.exe"
>   "cmTC_0dcd8"
>   [1/2] Building C object CMakeFiles/cmTC_0dcd8.dir/testCCompiler.c.o
>   [2/2] Linking C executable cmTC_0dcd8
>   FAILED: cmd.exe /C "cd .  &&
>   D:\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\
> windows-x86_64\bin\clang.exe
>   --target=armv5te-none-linux-androideabi
>   --gcc-toolchain=D:/Android/sdk/ndk-bundle/toolchains/arm-
> linux-androideabi-4.9/prebuilt/windows-x86_64
>   --sysroot=D:/Android/sdk/ndk-bundle/sysroot -isystem
>   D:/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
>   -D__ANDROID_API__=14 -g -DANDROID -ffunction-sections -funwind-tables
>   -fstack-protector-strong -no-canonical-prefixes -march=armv5te
>   -mtune=xscale -msoft-float -fno-integrated-as -mthumb -Wa,--noexecstack
>   -Wformat -Werror=format-security -Wl,--exclude-libs,libgcc.a --sysroot
>   D:/Android/sdk/ndk-bundle/platforms/android-14/arch-arm -Wl,--build-id
>   -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined
>   -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now
>   -Wl,--gc-sections -Wl,-z,nocopyreloc
>   CMakeFiles/cmTC_0dcd8.dir/testCCompiler.c.o -o cmTC_0dcd8 -lm && cd ."
>   clang.exe: error: no such file or directory:
>   'CMakeFiles/cmTC_0dcd8.dir/testCCompiler.c.o'
>   ninja: build stopped: subcommand failed.

You can pass `--debug-trycompile` to keep the output of the try compile
step. Running the command manually may help to narrow down the problem.
The tools mentioned here may also help:

    https://stackoverflow.com/questions/3847745/systrace-for-windows

--Ben


More information about the cmake-developers mailing list