MantisBT - CMake
View Issue Details
0014414CMakeCMakepublic2013-09-16 03:152016-06-10 14:31
Damian Kaczmarek 
Kitware Robot 
normalminoralways
closedmoved 
LinuxopenSUSE12.3
CMake 2.8.11.2 
 
0014414: Ninja: Running compiler from build dir makes it being run from bad relative directory
During my build setup I am creating "build/bin/ccache-arm-none-eabi-gcc"
My toolchain setup sets this binary:
set(CMAKE_C_COMPILER "${CCACHE_GCC_BINARY}" CACHE FORCE "")

Everything is fine when using "make", however when using "ninja" the following problem arose:
[6/1347] Building ASM object Project/CMakeFiles/Project_startup.dir/startup.s.obj
FAILED: ../bin/ccache-arm-none-eabi-gcc ... rest of command ...
/bin/sh: ../bin/ccache-arm-none-eabi-gcc: No such file or directory

I may try to provide a small test project setup if requested.
No tags attached.
related to 0015216closed Kitware Robot Ninja makes bad phony targets with parallel "sub" directory and custom CMAKE_LIBRARY_OUTPUT_DIRECTORY 
Issue History
2013-09-16 03:15Damian KaczmarekNew Issue
2013-10-12 11:02Peter KuemmelNote Added: 0034110
2013-10-13 11:11Damian KaczmarekNote Added: 0034114
2014-04-13 04:57Peter KuemmelNote Added: 0035681
2014-04-13 05:27Peter KuemmelSeverityblock => minor
2014-10-16 14:56Henry MillerNote Added: 0037037
2014-10-16 16:53Henry MillerNote Added: 0037038
2014-10-17 05:10Peter KuemmelNote Added: 0037039
2014-10-17 09:52Henry MillerNote Added: 0037041
2014-10-17 10:37Henry MillerNote Added: 0037042
2014-10-18 08:05Peter KuemmelNote Added: 0037045
2014-10-20 09:41Henry MillerNote Added: 0037056
2014-10-22 10:24Brad KingRelationship addedrelated to 0015216
2016-06-10 14:29Kitware RobotNote Added: 0042365
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0034110)
Peter Kuemmel   
2013-10-12 11:02   
Setting CMAKE_C_COMPILER by hand is very hairy. Try to set it before you call "project()" for the first time.
(0034114)
Damian Kaczmarek   
2013-10-13 11:11   
I am setting it with a toolchain configuration in CMAKE_TOOLCHAIN_FILE. It has always been valid.
(0035681)
Peter Kuemmel   
2014-04-13 04:57   
I assume it works when you use an absolute path for CCACHE_GCC_BINARY.
(0037037)
Henry Miller   
2014-10-16 14:56   
I have confirmed this with 2.8.12-2.

Even when I set an absolute path in my toolchain file, ninja is still using a relative path to the compiler, which breaks the build since the path is relative to the top of the build directory, not the subdirectory the build itself is run in.
(0037038)
Henry Miller   
2014-10-16 16:53   
Problem still exists with cmake 3.0.2.
(0037039)
Peter Kuemmel   
2014-10-17 05:10   
Could you please have a look at the Makefile and check if absolute paths are used?
(0037041)
Henry Miller   
2014-10-17 09:52   
The Makefile uses relative paths, even when a absolute path is given in the toolchain file.
(0037042)
Henry Miller   
2014-10-17 10:37   
Manually editing the generated rules.ninja file I was able to get a build, in all cases I change the relative to path to start with one .. instead of more than one.

rule CXX_COMPILER
   - remove one .. from the path
rule CXX_SHARED_LIBRARY_LINKER
   - remove one .. from the path
rule CXX_EXECUTABLE_LINKER
   - remove two .. (../..) from the path
rule CXX_MODULE_LIBRARY_LINKER
   - remove four .. (../../../..) from the path

I was able to complete my build without editing, but I suspect this is only because my build doesn't happen to use them - they all look wrong.
rule CXX_SHARED_LIBRARY_LINKER_RSP_FILE
rule CXX_EXECUTABLE_LINKER_RSP_FILE
rule CXX_STATIC_LIBRARY_LINKER
rule CXX_STATIC_LIBRARY_LINKER_RSP_FILE
rule CXX_MODULE_LIBRARY_LINKER_RSP_FILE

note, for the above my build tree looks like
   <source_root>/cross_build/<architecture>/toolchain_root
   <source_root>/cross_build/<architecture>/sysroot
   <source_root>/cross_build/<architecture>/buildDirectory
which is to say from my build directory the path to the compiler is ../toolchain_root/path/to/compiler
(0037045)
Peter Kuemmel   
2014-10-18 08:05   
I only see absolute paths in my rules.ninja.
Your compiler is within the source directory. Maybe this is the problem, or that the compiler is "created" at configure/build time.
Does it work with such a tree:
<source_root>
<cross_build>?
(0037056)
Henry Miller   
2014-10-20 09:41   
If I move my compiler outside of my source tree everything works.

Unfortunately my CI system is setup to clone to the root of the only writable directory and then run build scripts from that clone. (the same CI setup is used for many unrelated projects) Since the only place I can write is the build directory I have to install my compiler there.
(0042365)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.