Hi,I'm trying to run kythe on https://gitlab.cern.ch/gaudi/Gaudi/.Building it is unfortunately a bit involved, so while originally I tried to build a kythe index for the entire project, I'm focussing in this thread on just one TU that shows that I'm doing something wrong / kythe can't do for me what I expect it to do. I hope the writeup is not too much of a mess and I copied everything correctly together.What I did (the first few steps are just an explanation how I ended up with - what I think are - the interesting commands towards the end, if you want to save yourself from the mess, skip forward to step 5):0. I downloaded kythe 0.0.41 and checked out the corresponding tag from github. It's unpacked to /tmp/tmp.YfWrn8brsT/kythe-v0.0.41.1. I did a "regular" clang build. Our default setup for that is that `make` in the top level directory calls `cmake` with the appropriate arguments to create a build directory in which ninja builds with clang. (yes, unconventional, sorry)In when running the top level `make` with `-n`, I see that `cmake` should get called with```shcd /afs/cern.ch/work/p/pseyfert/ofun/Gaudi/build.x86_64-centos7-clang8-opt && cmake -DGAUDI_DIAGNOSTICS_COLOR=ON -DCMAKE_TOOLCHAIN_FILE=/afs/cern.ch/work/p/pseyfert/ofun/Gaudi/toolchain.cmake -GNinja /afs/cern.ch/work/p/pseyfert/ofun/Gaudi```That means the instructions from [the docs](https://github.com/kythe/kythe/pull/4173/files) won't work for me as a) unfortunately [here](https://github.com/kythe/kythe/blob/v0.0.41/kythe/go/extractors/config/runextractor/cmakecmd/cmakecmd.go#L112) cmake gets called without `-DCMAKE_TOOLCHAIN_FILE`. (to be fair, I could create a build directory manually, have CMAKE_TOOLCHAIN_FILE set and then run `runextractor cmake`) and b) that sets (invisible from the call) `CMAKE_CXX_COMPILER` to `lcg-clang++-8.0.0`, which would get overridden through `-DCMAKE_CXX_COMPILER=clang++`.2. I therefore run my build manually `make; cd /afs/cern.ch/work/p/pseyfert/ofun/Gaudi/build.x86_64-centos7-clang8-opt; cmake --build .``CMAKE_EXPORT_COMPILE_COMMANDS` is ON by default so the `compile_commands.json` gets created and with youcompleteme or clang-tidy of include-what-you-use I can verify that the `json` file is okay.
3. I check out tag 0.0.41 of kythe, comment out line 112-118 in `cmakecmd.go`, rebuild `runextractor`, and run it as described in the docs, and watch with `ps` what processes get called from `ExtractCompilations`.4. I expect the extracted compilations to be slightly incorrect because my clang executable `lcg-clang++-8.0.0` is just an executable shell script:```sh#!/bin/shLD_LIBRARY_PATH=$(printenv LD_LIBRARY_PATH | sed 's-[^:]*/\(gcc\|llvm\|clang\)/[^:]*:\?--g')export LD_LIBRARY_PATH=/cvmfs/lhcb.cern.ch/lib/lcg/releases/clang/8.0.0/x86_64-centos7/lib64:/cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/8.2.0/x86_64-centos7/lib64:/cvmfs/lhcb.cern.ch/lib/lcg/releases/binutils/2.30/x86_64-centos7/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}exec /cvmfs/lhcb.cern.ch/lib/lcg/releases/clang/8.0.0/x86_64-centos7/bin/clang++ --gcc-toolchain=/cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/8.2.0/x86_64-centos7 "$@"```This doesn't do anything spectacular other than setting PATH and LD_LIBRARY_PATH correctly such that the compiler binary works as intended (works around issues that we have with compilers not being linked against the OS's `libstdc++.so`), adds `--gcc-toolchain=/cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/8.2.0/x86_64-centos7`, and passes all arguments on to the compiler binary. I suspect `--gcc-toolchain` should be passed to the cxx_extractor (at least other clang based tools I worked with need it), so after I saw what subprocesses get spawned by `runextractor` I run one of them by hand (step 6).
5. I set the KYTHE environment variables. I also make sure the output directory exists (https://github.com/kythe/kythe/issues/4174):```shexport KYTHE_CORPUS=Gaudiexport KYTHE_ROOT_DIRECTORY=/afs/cern.ch/work/p/pseyfert/ofun/Gaudiexport KYTHE_OUTPUT_DIRECTORY=/tmp/doesexistmkdir -p $KYTHE_OUTPUT_DIRECTORY```6. I set `PATH` and `LD_LIBRARY_PATH to the values I got from the above clang launcher, `cd` into my build directory and launch the cxx_extractor```cpp/tmp/tmp.YfWrn8brsT/kythe-v0.0.41/extractors/cxx_extractor --with_executable /cvmfs/lhcb.cern.ch/lib/bin/x86_64-centos7/lcg-clang++-8.0.0 -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_SPIRIT_USE_PHOENIX_V3 -DGAUDI_V20_COMPAT -DGaudiSvc_EXPORTS -DPACKAGE_NAME=\"GaudiSvc\" -DPACKAGE_VERSION=\"v33r0\" -DTBB_USE_GLIBCXX_VERSION=80000 -D_GNU_SOURCE -Df2cFortran -Dlinux -Dunix -IGaudiSvc -I../GaudiSvc -I../GaudiPluginService -I../GaudiKernel -Iinclude -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_96b/clhep/2.4.1.2/x86_64-centos7-clang8-opt/include -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_96b/cppgsl/2.0.0/x86_64-centos7-clang8-opt/include -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_96b/tbb/2019_U7/x86_64-centos7-clang8-opt/include -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_96b/ROOT/6.18.04/x86_64-centos7-clang8-opt/include -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_96b/Boost/1.70.0/x86_64-centos7-clang8-opt/include -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_96b/rangev3/0.5.0/x86_64-centos7-clang8-opt/include -march=x86-64 -msse4.2 -fmessage-length=0 -pipe -Wall -Wextra -Werror=return-type -pthread -pedantic -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wnon-virtual-dtor -std=c++17 -fdiagnostics-color -O3 -DNDEBUG -fPIC -MD -MT GaudiSvc/CMakeFiles/GaudiSvc.dir/src/RndmGenSvc/HepRndmGenerators.cpp.o -MF GaudiSvc/CMakeFiles/GaudiSvc.dir/src/RndmGenSvc/HepRndmGenerators.cpp.o.d -o GaudiSvc/CMakeFiles/GaudiSvc.dir/src/RndmGenSvc/HepRndmGenerators.cpp.o -c ../GaudiSvc/src/RndmGenSvc/HepRndmGenerators.cpp --gcc-toolchain=/cvmfs/lhcb.cern.ch/lib/lcg/releases/gcc/8.2.0/x86_64-cent```This finishes successfully ($? is 0) without errors or warnings. The resulting kzip file can be downloaded [here](https://cernbox.cern.ch/index.php/s/Wlbs4ooTPVnuuMc).
7. When running the `cxx_indexer` with `/tmp/tmp.YfWrn8brsT/kythe-v0.0.41/indexers/cxx_indexer --ignore_unimplemented /tmp/doesexist/* > /tmp/entries` I get the following error messages repeated several times over```pseyfert@pseyfert-centos:/tmp/doesexist >> /tmp/tmp.YfWrn8brsT/kythe-v0.0.41/indexers/cxx_indexer --ignore_unimplemented /tmp/doesexist/* > /tmp/entriesIn file included from /afs/cern.ch/work/p/pseyfert/ofun/Gaudi/GaudiSvc/src/RndmGenSvc/HepRndmGenerators.cpp:28:In file included from /afs/cern.ch/work/p/pseyfert/ofun/Gaudi/GaudiKernel/GaudiKernel/ObjectFactory.h:14:In file included from /afs/cern.ch/work/p/pseyfert/ofun/Gaudi/GaudiPluginService/Gaudi/PluginService.h:20:/afs/cern.ch/work/p/pseyfert/ofun/Gaudi/GaudiPluginService/Gaudi/PluginServiceV2.h:84:54: error: no type named 'Factory' in 'HepRndm::Generator<Rndm::Bit>'template <typename T, typename F = typename T::Factory>~~~~~~~~~~~~^~~~~~~/afs/cern.ch/work/p/pseyfert/ofun/Gaudi/GaudiPluginService/Gaudi/PluginServiceV2.h:85:14: note: in instantiation of default argument for 'DeclareFactory<HepRndm::Generator<Rndm::Bit> >' required herestruct DeclareFactory {^```The output file `/tmp/entries/` isn't empty. Now it's not clear to me what to expect here. I would've thought if clang can build HepRndmGenerators.cpp then so should the cxx_indexer (at least that's what I'm used to with other clang based tools. btw: my understanding is that the c++ parts of kythe are clang based?). The cxx_indexer doesn't fail on all translation units and when restricting myself to a few translation units that go through the cxx_indexer without errors I reached the end of [the docs](https://raw.githubusercontent.com/kythe/kythe/master/kythe/web/site/examples.md) and could run `http_server -- ....` and look at the code index in my webbrowser (well, that was last time I tried with v0.0.30 anyways). At this point I'm a bit lost how to debug / where to suspect errors on my side or wonder where my tools are just incompatible (NB: I only have the build system and compilers for clang 8 ready, I didn't see if cxx_indexer is clang 9 based and I don't have an ETA for clang 9. Also I know that for include-what-you-use or cpp-insights I often need to make sure clang's system headers are in the right place with [hacks like this](https://gitlab.cern.ch/pseyfert/lb-compiler-explorer/blob/master/Dockerfile#L21) or as [discussed here](https://github.com/include-what-you-use/include-what-you-use/issues/100), no idea if that's relevant for kythe.Any hint, pointers or comments for me? Maybe a few easy questions from my side:* Should kythe just work on a project that builds fine with cmake and clang?
* Should I be suspicious if I haven't tried building with clang9 yet?
* Should cxx_indexer be able to digest any tu that clang++ can handle?
* Are there any other information I could provide or things I should try? (like a docker container with the directories set up would require some work and time from me and would also require running privileged containers for the (world readable) network mounts that are involved, but should be possible)
--Thanks in advance,Paul
You received this message because you are subscribed to the Google Groups "Kythe" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kythe+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/3dc07640-bdab-49ca-8155-baa5c62f117b%40googlegroups.com.
* Are there any other information I could provide or things I should try? (like a docker container with the directories set up would require some work and time from me and would also require running privileged containers for the (world readable) network mounts that are involved, but should be possible)I think the next thing to try would be changing the command in the produced compile_commands.json to point to the actual clang binary that gets exec'd and includes the `--gcc-toolchain` option.
--
You received this message because you are subscribed to the Google Groups "Kythe" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kythe+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/6c772b4e-9934-4f85-8e6a-dfa19b2f3343%40googlegroups.com.
Luke may have a better idea.It's possible that we're instantiating templates for indexing which wouldn't be during compilation and that is the cause of the errors. It's worth checking to see if there are substantial differences in the output (or even just the size) between the run with errors and the run without.

You may be able to use https://github.com/kythe/kythe/tree/master/kythe/go/storage/tools/triples to get a better sense of the changes between the two. It's quite possible the indexing errors are benign, although it would be nice to inhibit logging them if that's the case.--Shahms
To unsubscribe from this group and stop receiving emails from it, send an email to ky...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/6c772b4e-9934-4f85-8e6a-dfa19b2f3343%40googlegroups.com.
--:-P
Am Dienstag, 11. Februar 2020 18:44:37 UTC+1 schrieb Shahms King:Luke may have a better idea.It's possible that we're instantiating templates for indexing which wouldn't be during compilation and that is the cause of the errors. It's worth checking to see if there are substantial differences in the output (or even just the size) between the run with errors and the run without.I would say the outputs differ substantially in size (490MB vs 570MB).I don't yet have a clue of the output, but I guess it makes sense as the macros I commented out instantiate some templates. (w/o default parameters).Either way, with the included http_server (the one you said may or may not work) I don't see any content:
To unsubscribe from this group and stop receiving emails from it, send an email to kythe+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/02f6772f-ecab-4689-9664-7f9acd9727df%40googlegroups.com.
On Wed, Feb 12, 2020 at 10:46 AM Paul Seyfert <pseyfert....@gmail.com> wrote:
Am Dienstag, 11. Februar 2020 18:44:37 UTC+1 schrieb Shahms King:Luke may have a better idea.It's possible that we're instantiating templates for indexing which wouldn't be during compilation and that is the cause of the errors. It's worth checking to see if there are substantial differences in the output (or even just the size) between the run with errors and the run without.I would say the outputs differ substantially in size (490MB vs 570MB).I don't yet have a clue of the output, but I guess it makes sense as the macros I commented out instantiate some templates. (w/o default parameters).Either way, with the included http_server (the one you said may or may not work) I don't see any content:Thanks for the follow up. If the included http_server fails to display anything in either case, it's unlikely that the indexer error is the problem (or at least not the only one). Looking at the screenshot, though, I see some content (specifically, the Gaudi: root directory) listed. Clicking on that should expand to the immediate subdirectories (if any) and so on.
On Wed, Feb 12, 2020 at 10:46 AM Paul Seyfert <pseyfert....@gmail.com> wrote:
Am Dienstag, 11. Februar 2020 18:44:37 UTC+1 schrieb Shahms King:Luke may have a better idea.It's possible that we're instantiating templates for indexing which wouldn't be during compilation and that is the cause of the errors. It's worth checking to see if there are substantial differences in the output (or even just the size) between the run with errors and the run without.I would say the outputs differ substantially in size (490MB vs 570MB).I don't yet have a clue of the output, but I guess it makes sense as the macros I commented out instantiate some templates. (w/o default parameters).Either way, with the included http_server (the one you said may or may not work) I don't see any content:Thanks for the follow up. If the included http_server fails to display anything in either case, it's unlikely that the indexer error is the problem (or at least not the only one). Looking at the screenshot, though, I see some content (specifically, the Gaudi: root directory) listed. Clicking on that should expand to the immediate subdirectories (if any) and so on.sorry i was too brief there. i tried clicking that in chrome and firefox but nothing expands, as if the directory browser wants to tell me there's the directory but no content.I do see on the shell running the http_server that the click gets registered by the server2020/02/12 20:24:05 HTTP server listening on "localhost:8089"2020/02/12 20:24:11 filetree.CorpusRoots: 43.818517ms2020/02/12 20:24:13 filetree.Dir: 1.728409ms
Any other details you can provide in https://github.com/kythe/kythe/issues/4362 would also be helpful.The expanded macro case *looks* like straightforward case of providing an explicit template argument where the default won't compile, which happens pretty frequently in almost any code base so I would not expect the error to be fatal.--ShahmsYou may be able to use https://github.com/kythe/kythe/tree/master/kythe/go/storage/tools/triples to get a better sense of the changes between the two. It's quite possible the indexing errors are benign, although it would be nice to inhibit logging them if that's the case.--ShahmsOn Tue, Feb 11, 2020 at 5:12 AM Paul Seyfert <pseyfert....@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Kythe" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kythe+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/302f50e2-cf89-430e-bd50-b54f1a188aba%40googlegroups.com.

:grinning_face_with_star_eyes: amazing, thanks for investigating!i tried the following setups1) KYTHE_ROOT_DIRECTORY set to the source directory and building with ninja (original setup)2) KYTHE_ROOT_DIRECTORY set to the build directory and building with ninja3) KYTHE_ROOT_DIRECTORY set to the build directory and building with gnu make (iirc cmake creates compile_commands.json with -I relative paths for ninja and absolute paths with gnu make. changing this way doesn't match the needed fix you described but while i have another issue related to that on my desk i figured i just see what happens)In either case I don't see a UI working as in your screenshot.Looking at the start of root/units/<file> in the kzip I see1) with KYTHE_ROOT_DIRECTORY set to the source tree [{"v_name":{"corpus":"Gaudi","path":"GaudiSvc/src/RndmGenSvc/HepRndmGenerators.cpp"}2) with KYTHE_ROOT_DIRECTORY set to the build tree [{"v_name":{"corpus":"Gaudi","path":"/afs/cern.ch/work/p/pseyfert/ofun/Gaudi/GaudiSvc/src/RndmGenSvc/HepRndmGenerators.cpp"}so that seems to go in the opposite of the desired direction.Do I understand correctly you mean the absolute paths of my dependencies' headers (boost, standard library, …) are problematic? Because as far as I see by eye in the kzip (or with `tools/entrystream --write_format=json -unique`) the files from my source repository appear by relative (to the source top level dir) path.
Cheers,Paul
Am Donnerstag, 13. Februar 2020 02:09:18 UTC+1 schrieb Shahms King:It does appear to be the absolute paths causing issues. I'm not sure if it's just http_server, but I suspect so. If I remap the files in the kzip provided, I can get a rudimentary UI working:--ShahmsOn Wed, Feb 12, 2020 at 4:10 PM Shahms King <sha...@google.com> wrote:I don't know that the VName paths are the source of the problem, but I know that the graph generally expects the "path" to be relative to the repository root, but it can be pretty easy to end up with absolute paths and paths relative to the build directory instead which can cause issues (and looks to have happened here).Can you set KYTHE_ROOT_DIRECTORY to the *build* root, rather than the source root and see if that helps?
--
You received this message because you are subscribed to the Google Groups "Kythe" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kythe+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/929923f0-3c8c-4451-a41c-71f4d1d81094%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ky...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/929923f0-3c8c-4451-a41c-71f4d1d81094%40googlegroups.com.
--:-P
To unsubscribe from this group and stop receiving emails from it, send an email to kythe+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kythe/7c33afb1-e383-470e-9383-c8be73a6353e%40googlegroups.com.