Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

"YCM-Generator/fake-toolchain/Unix/clang" is not able to compile a simple test program #19

Closed
andrewrk opened this issue Jun 18, 2015 · 8 comments

Comments

@andrewrk
Copy link

[nix-shell:~/dev/genesis]$ ~/Downloads/YCM-Generator/config_gen.py . --verbose
Running cmake in '/run/user/1000/tmpVUUWXy'...
$ cmake /home/andy/dev/genesis
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang -- broken
CMake Error at /nix/store/l2w8cfzgh72ggz00afgig2scywz0snk0-cmake-3.2.2/share/cmake-3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler
  "/home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang" is not able
  to compile a simple test program.

  It fails with the following output:

   Change Dir: /run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp



  Run Build
  Command:"/nix/store/hv8pgyn6a0a5h9dyd7s7cwh5105gykj5-gnumake-4.1/bin/make"
  "cmTryCompileExec2779557708/fast"

  /nix/store/hv8pgyn6a0a5h9dyd7s7cwh5105gykj5-gnumake-4.1/bin/make -f
  CMakeFiles/cmTryCompileExec2779557708.dir/build.make
  CMakeFiles/cmTryCompileExec2779557708.dir/build

  make[1]: Entering directory '/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp'

  /nix/store/l2w8cfzgh72ggz00afgig2scywz0snk0-cmake-3.2.2/bin/cmake -E
  cmake_progress_report
  /run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building C object
  CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o

  /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang -o
  CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o -c
  /run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp/testCCompiler.c

  make[1]: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang:
  Command not found

  CMakeFiles/cmTryCompileExec2779557708.dir/build.make:57: recipe for target
  'CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o' failed

  make[1]: *** [CMakeFiles/cmTryCompileExec2779557708.dir/testCCompiler.c.o]
  Error 127

  make[1]: Leaving directory '/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeTmp'

  Makefile:117: recipe for target 'cmTryCompileExec2779557708/fast' failed

  make: *** [cmTryCompileExec2779557708/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:11 (project)


-- Configuring incomplete, errors occurred!
See also "/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeOutput.log".
See also "/run/user/1000/tmpVUUWXy/CMakeFiles/CMakeError.log".

Running make...
$ make -i -j8
make: *** No targets specified and no makefile found.  Stop.

Cleaning up...

Build completed in 0.29 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /run/user/1000/tmpv8jjBA, C++: /run/user/1000/tmpbvAir8).
Your build system may not be compatible.

[nix-shell:~/dev/genesis]$ clang --version
clang version 3.6.1 (tags/RELEASE_361/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
@rdnetto
Copy link
Owner

rdnetto commented Jun 18, 2015

Can you provide a link to the repo you're running it against?

@andrewrk
Copy link
Author

@rdnetto
Copy link
Owner

rdnetto commented Jun 19, 2015

   make[1]: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang:
   Command not found

I think I have an idea what the problem might be. You're running NixOS, right? The fake toolchain assumes the existence of /bin/bash and /bin/true, neither of which exist for you. (It appears you do have /bin/sh symlinked to bash, but I can't make that assumption without breaking things for Debian, etc.)

So there's basically two things that need to be done:

  • modify the scripts to be dash-compatible so they can use /bin/sh
  • replace the link to /bin/true with a shell script. That'll probably result in a slight performance hit, but I guess it can't be helped

rdnetto added a commit that referenced this issue Jun 19, 2015
rdnetto added a commit that referenced this issue Jun 19, 2015
@rdnetto
Copy link
Owner

rdnetto commented Jun 19, 2015

Can you checkout the nixos_support branch and see if it works now?

@andrewrk
Copy link
Author

You're running NixOS, right?

That's right. Sorry I don't mean to cause you trouble since I'm running a non-standard distro. Hopefully there is a way to do things so that it works in a standard way for all distros and other POSIX-compliant systems.

This change got me past the previous error. Now I'm getting something different - cmake is not finding any dependencies. For comparison, I also include what it looks like when I run cmake normally without YCM-Generator.

[nix-shell:~/tmp]$ python ~/Downloads/YCM-Generator/config_gen.py ~/dev/genesis/ -o out.py --verbose
Running cmake in '/run/user/1000/tmpKbfFJO'...
$ cmake /home/andy/dev/genesis
-- The C compiler identification is Clang 3.6.1
-- The CXX compiler identification is Clang 3.6.1
-- Check for working C compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang
-- Check for working C compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang++
-- Check for working CXX compiler: /home/andy/Downloads/YCM-Generator/fake-toolchain/Unix/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Configuring libgenesis version 0.0.0
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- 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 - found
-- Found Threads: TRUE  
-- Could NOT find LIBAV (missing:  AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIRS AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIRS AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIRS) 
-- Could NOT find FREETYPE (missing:  FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR) 
-- Could NOT find PNG (missing:  PNG_LIBRARY PNG_INCLUDE_DIR) 
-- Could NOT find RUCKSACK (missing:  RUCKSACK_LIBRARY RUCKSACK_INCLUDE_DIR) 
-- Could NOT find LAXJSON (missing:  LAXJSON_LIBRARY LAXJSON_INCLUDE_DIR) 
-- Could NOT find PULSEAUDIO (missing:  PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR) 
-- Could NOT find GLFW (missing:  GLFW_LIBRARY GLFW_INCLUDE_DIR) 
-- Could NOT find EPOXY (missing:  EPOXY_LIBRARY EPOXY_INCLUDE_DIR) 
-- Could NOT find RHASH (missing:  RHASH_LIBRARY RHASH_INCLUDE_DIR) 
-- Could NOT find ALSA (missing:  ALSA_LIBRARY ALSA_INCLUDE_DIR) 

Installation Summary
--------------------
* Install Directory            : /var/empty/local

System Dependencies
-------------------
* threads                      : OK
* libavformat                  : not found
* libavcodec                   : not found
* libavutil                    : not found
* freetype                     : not found
* libpng                       : not found
* rucksack                     : not found
* liblaxjson                   : not found
* pulseaudio                   : not found
* GLFW                         : not found
* libepoxy                     : not found
* ALSA                         : not found
* librhash                     : not found

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
EPOXY_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
EPOXY_LIBRARY (ADVANCED)
    linked by target "genesis" in directory /home/andy/dev/genesis
FREETYPE_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
FREETYPE_LIBRARY (ADVANCED)
    linked by target "genesis" in directory /home/andy/dev/genesis
GLFW_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
GLFW_LIBRARY (ADVANCED)
    linked by target "genesis" in directory /home/andy/dev/genesis
LAXJSON_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
LAXJSON_LIBRARY (ADVANCED)
    linked by target "genesis" in directory /home/andy/dev/genesis
    linked by target "unit_tests" in directory /home/andy/dev/genesis
PNG_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
PNG_LIBRARY (ADVANCED)
    linked by target "genesis" in directory /home/andy/dev/genesis
PULSEAUDIO_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
PULSEAUDIO_LIBRARY (ADVANCED)
    linked by target "libgenesis_shared" in directory /home/andy/dev/genesis
    linked by target "unit_tests" in directory /home/andy/dev/genesis
RHASH_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
RHASH_LIBRARY (ADVANCED)
    linked by target "genesis" in directory /home/andy/dev/genesis
    linked by target "unit_tests" in directory /home/andy/dev/genesis
RUCKSACK_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
   used as include directory in directory /home/andy/dev/genesis
RUCKSACK_LIBRARY (ADVANCED)
    linked by target "genesis" in directory /home/andy/dev/genesis

-- Configuring incomplete, errors occurred!
See also "/run/user/1000/tmpKbfFJO/CMakeFiles/CMakeOutput.log".
See also "/run/user/1000/tmpKbfFJO/CMakeFiles/CMakeError.log".

Running make...
$ make -i -j8
make: *** No targets specified and no makefile found.  Stop.

Cleaning up...

Build completed in 5.52 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).
()
ERROR: No commands were logged to the build logs (C: /run/user/1000/tmpwVk004, C++: /run/user/1000/tmpxOcCYY).
Your build system may not be compatible.

And here is a normal cmake run in the same environment:

[nix-shell:~/tmp/gen]$ cmake ~/dev/genesis/
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /nix/store/k1zbcj8fng54qf9pfl16km1f6bsy898n-gcc-wrapper-4.9.2/bin/gcc
-- Check for working C compiler: /nix/store/k1zbcj8fng54qf9pfl16km1f6bsy898n-gcc-wrapper-4.9.2/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /nix/store/k1zbcj8fng54qf9pfl16km1f6bsy898n-gcc-wrapper-4.9.2/bin/g++
-- Check for working CXX compiler: /nix/store/k1zbcj8fng54qf9pfl16km1f6bsy898n-gcc-wrapper-4.9.2/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Configuring libgenesis version 0.0.0
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- 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 - found
-- Found Threads: TRUE  
-- Found LIBAV: /nix/store/i1n7av3z5ald85szhcfakm9yk2iaff3m-libav-11.4/lib/libavformat.so  
-- Found FREETYPE: /nix/store/kj6flli9mxq5jpdyv301nbi73zh2dc6c-freetype-2.5.4/lib/libfreetype.so  
-- Found PNG: /nix/store/dl8q6szn49bjk095375prk45vgzr5ndb-libpng-1.6.16/lib/libpng.so  
-- Found RUCKSACK: /nix/store/dm9622pp4zi11mkr92kl3bq634ad26h0-rucksack-3.1.0/lib/librucksack.so  
-- Found LAXJSON: /nix/store/qmcv5qpsalcwikdrrn329v2rf3b5zrf2-liblaxjson-1.0.5/lib/liblaxjson.so  
-- Found PULSEAUDIO: /nix/store/lkx1ss2jyhnxqmfav0aj08pqbs7b2j7j-libpulseaudio-6.0/lib/libpulse.so  
-- Found GLFW: /nix/store/4vw9xg5ab391pm7fq3s4nxkxq4x8r8ns-glfw-3.1.1/lib/libglfw.so  
-- Found EPOXY: /nix/store/4fgdxmzja03187mg1h86wdzqbdgkzpzz-epoxy-1.2/lib/libepoxy.so  
-- Found RHASH: /nix/store/zsplrg08fwm14bx43zylmf8hbxkqng7b-rhash-1.3.3/lib/librhash.so  
-- Found ALSA: /nix/store/qhzizwyzhyy4wfdmdpfwi6qkxl3db8lc-alsa-lib-1.0.29/lib/libasound.so (found version "1.0.29") 

Installation Summary
--------------------
* Install Directory            : /var/empty/local

System Dependencies
-------------------
* threads                      : OK
* libavformat                  : OK
* libavcodec                   : OK
* libavutil                    : OK
* freetype                     : OK
* libpng                       : OK
* rucksack                     : OK
* liblaxjson                   : OK
* pulseaudio                   : OK
* GLFW                         : OK
* libepoxy                     : OK
* ALSA                         : OK
* librhash                     : OK

-- Configuring done
-- Generating done
-- Build files have been written to: /home/andy/tmp/gen

@rdnetto
Copy link
Owner

rdnetto commented Jun 23, 2015

Sorry about the delay in replying - I'm in the middle of my exams atm so free time is scarce.

Sorry I don't mean to cause you trouble since I'm running a non-standard distro. Hopefully there is a way to do things so that it works in a standard way for all distros and other POSIX-compliant systems.

It's cool, all the changes so far have made the code more portable rather than just adding special cases, so I don't mind.

Can you see if using -e enables it to find the dependencies? And if not, can you post the value of $PATH in your shell?

@andrewrk
Copy link
Author

Nice, that worked. Apologies for not noticing and trying the -e option. Hmm but it seems like that might be a good thing to preserve the environment variables by default, no?

By the way, in case you're curious, here's the config I ended up using:

https://github.com/andrewrk/genesis/blob/5f49cd9a8c2b61b9859a22102bc3f732add9461a/.ycm_extra_conf.py

It's not the output of YCM-Generator, although the YCM-Generator template was a good starting point that I used. I ended up going with a hybrid of using cmake's generated compile_commands.json and for some reason on NixOS I needed to give YCM the path to stdlib.h and friends. So I did that by executing echo | cc -xc -E -v - and echo | cc -xc++ -E -v - where cc is the C compiler in the CC env variable, and parsing the output of those commands to find out where the include paths are.

@rdnetto
Copy link
Owner

rdnetto commented Jun 24, 2015

Nice, that worked. Apologies for not noticing and trying the -e option. Hmm but it seems like that might be a good thing to preserve the environment variables by default, no?

IIRC, the reason -e isn't the default was to improve reproducibility and simplify debugging. If a set environment variable changes the behaviour, it makes debugging this kind of error much harder, compared to telling everyone to just try using -e.

BTW, you might want to figure out which variable is the relevant one, since that'll probably cause problems for you at some stage due to Nix being so different.

@rdnetto rdnetto closed this as completed Jun 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants