rr-debugger / rr

Record and Replay Framework
http://rr-project.org/
Other
9.12k stars 583 forks source link

Compilation issue | error: Not defined: Cxx #2190

Open d4nF opened 6 years ago

d4nF commented 6 years ago

Hi,

I'm trying to compile rr to a custom env/folder and i'm having issues I've compiled capnproto 0.6.1 to that env, but whenever I run make I get the following error

[ 56%] Generating rr_trace.capnp.c++, rr_trace.capnp.h /home/d4nf/Custom_Libs/rr/rr-5.1.0/src/rr_trace.capnp:5:20-38: error: Import failed: /capnp/c++.capnp /home/d4nf/Custom_Libs/rr/rr-5.1.0/src/rr_trace.capnp:6:2-5: error: Not defined: Cxx make[2]: [CMakeFiles/rr.dir/build.make:62: rr_trace.capnp.c++] Error 1 make[1]: [CMakeFiles/Makefile2:17968: CMakeFiles/rr.dir/all] Error 2

my environment:

uname -r 4.9.80-gentoo g++ --version g++ (Gentoo 7.3.0-r1 p1.1) 7.3.0

I am aware i could use portage to install rr on my host, however I see this issue with non-gentoo systems as well My guess is that maybe I've compiled capnproto incorrectly, however googling this issue unfortunately has led me nowhere

here is my procedure for reproducing this issue. assumption is that rr and capnproto do not exist on the machine yet


mkdir builds tgt
cd builds
tar xf capnproto-0.6.1.tar.gz
tar xf rr-5.1.0.tar.gz
cd capnproto
mkdir build
cd build
cmake ../c++/ -DCMAKE_INSTALL_PREFIX:PATH=~/tgt
make -j install
export PATH=$PATH:~/tgt/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/tgt/lib64
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:~/tgt/lib64/pkgconfig
cd ~/builds/rr-5.1.0
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=~/tgt
make -j
# the issue should appear here
rocallahan commented 6 years ago

I'm not really able to help with Capnproto setup issues, sorry :-(. Wild guess, maybe it's building without C++ support for some reason? Check the build logs for Capnproto to make sure it detected a C++ environment?

d4nF commented 6 years ago

So I looked further and found https://capnproto.org/cxx.html In the "Setting a Namespace" section, it mentions that the capnproto include file needs to be in the Prefix in order for using

Cxx = import "/capnp/c++.capnp"

to work

At this point im pretty sure the issue is with rr's CMakeLists.txt file not adding capnproto's include directory if it's being sourced from a different prefix.

I'm currently looking for the right place to add it to the include_directories() command, but so far am not having any luck

rocallahan commented 6 years ago

The include directory should be obtained by the call to pkg_check_modules in CMakeLists.txt and added to CMAKE_C(XX)_FLAGS there. So you need to make sure pkg-config is picking up your Capnproto build, perhaps by setting PKG_CONFIG_PATH.

d4nF commented 6 years ago

The cmake generation will fail if capnproto isnt found in the PKG_CONFIG_PATH...

I think i found the issue

In the main CMakeLists.txt file at line 345 (release 0.5.1) I added the equivilant of "-I$tgt/include" (see original post for $tgt) The issue is that the capnp command doesn't seem to know where it was installed at, and requires its callers to tell it where it was [installed at]

In anycase I was able to compile with this above hack

rocallahan commented 6 years ago

I don't really understand. Is an rr change needed, or is this a Capnproto build issue?

d4nF commented 6 years ago

Hey, sorry for disappearing

rr's main cmakefile needs to deduce the include directory of capnproto (for "COMMAND capnp compile") and include that path as shown above. I say this since it seems that capnproto wont do the deduction by itself by design (as it states in the linked guide above)

rocallahan commented 6 years ago

Can you send me a PR that works for you?

marc1uk commented 1 year ago

+1 on this issue. Unfortunately I'm not really familiar with CMake, so don't know the right way to do this (I would have thought it would be handled by pkg-config), but calling pkg-config capnp --cflags-only-I returned -I/path/to/capnp/include/directory, and I basically just copied that into a new line as part of the COMMAND capnp compile:

 518                    COMMAND capnp compile
 519                            "--src-prefix=${CMAKE_CURRENT_SOURCE_DIR}/src"
 520                            "-I/home/myuser/capnp/build/include"
 521                            "-oc++:${CMAKE_CURRENT_BINARY_DIR}"
 522                            "${CMAKE_CURRENT_SOURCE_DIR}/src/rr_trace.capnp"

(as well as ensuring PATH and LD_LIBRARY_PATH were set to include capnp appropriately) and the build succeeded. Not really appropriate for a pull request i'm afraid, but hopefully someone with better CMake knowledge can figure out how to incorporate that (i tried using "`pkg-config capnp --cflags-only-I`" but that gave "no such command" :confused: ).