Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
909 stars 99 forks source link

Unable to set up compilation database for Chromium #194

Open zeptonaut opened 9 years ago

zeptonaut commented 9 years ago

First off - huge thanks for all the awesome work you've done on this project!

I'm trying to get irony-mode to provide completion for Chromium code, which is built with Ninja.

I generated the compile commands with:

$ ninja -C out/Debug -t compdb cc cxx objc objcxx > out/Debug/compile_commands.json

This successfully generates a file at:

/usr/local/google/home/charliea/chrome/src/out/Debug/compile_commands.json

After this I added the compilation database to irony-mode with:

M-x irony-cdb-json-add-compile-commands-path RET /usr/local/google/home/charliea/chrome/src/out/Debug RET /usr/local/google/home/charliea/chrome/src/out/Debug/compile_commands.json RET

However, now when I go to a file that's covered by the generated build rules and type M-x irony-cdb-menu, I'm greeted with a message saying "No compilation database in use."

Any ideas on how I've messed up the compilation database configuration?

Here are a few pieces of values that might be useful (based on the questions you asked in #190):

I suspect that I'm doing something stupid, but I'm not quite sure what it is. Any ideas on how to fix this?

zeptonaut commented 9 years ago

/poke

Sarcasm commented 9 years ago

Hi sorry for the delay, life is a little busy right now.

I think you entered the wrong directory here:

M-x irony-cdb-json-add-compile-commands-path RET /usr/local/google/home/charliea/chrome/src/out/Debug RET /usr/local/google/home/charliea/chrome/src/out/Debug/compile_commands.json RET

The first directory should be the project root, files under this directory will be looked for in the corresponding compilation database, file outside this directory aren't, so if you enter an out-of-source build directory as project root, it won't work. Try something like /usr/local/google/home/charliea/chrome/src/ instead.

zeptonaut commented 9 years ago

Awesome - thank you so much! I really appreciate you taking the time out of your busy life to help!

It looks like M-: (irony-cdb-json--locate-db) RET is now returning the sensible response (/usr/local/google/home/charliea/chrome/src/out/Debug/compile_commands.json). However, M-x irony-cdb-menu still says "No compilation database in use."

Any ideas?

Sarcasm commented 9 years ago

Can you print the debug info as explained here:https://github.com/Sarcasm/irony-mode/issues/190#issuecomment-93062550

zeptonaut commented 9 years ago

It returns:

I: found compilation database: /usr/local/google/home/charliea/chrome/src/out/Debug/compile_commands.json

Sarcasm commented 9 years ago

Another message should follow this one, do you have one? If not maybe you can toggle M-x toggle-debug-on-error RET and see if you have an error.

zeptonaut commented 9 years ago

Ah - it looks like part of the command was just taking a really, really long time. Here's what the full result was:

"I: found by guessing: (((-MMD -MF obj/third_party/libvpx/source/libvpx/vp8/common/x86/libvpx_intrinsics_ssse3.variance_ssse3.o.d -DV8_DEPRECATION_WARNINGS -D_FILE_OFFSET_BITS=64 -DCHROMIUM_BUILD -DCR_CLANG_REVISION=233105-2 -DTOOLKIT_VIEWS=1 -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_ASH=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_DEFAULT_RENDER_THEME=1 -DUSE_LIBJPEG_TURBO=1 -DUSE_X11=1 -DUSE_CLIPBOARD_AURAX11=1 -DENABLE_ONE_CLICK_SIGNIN -DENABLE_PRE_SYNC_BACKUP -DENABLE_REMOTING=1 -DENABLE_WEBRTC=1 -DENABLE_MEDIA_ROUTER=1 -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_NOTIFICATIONS -DENABLE_HIDPI=1 -DUSE_UDEV -DDONT_EMBED_BUILD_METADATA -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_GOOGLE_NOW=1 -DCLD_VERSION=2 -DENABLE_PRINTING=1 -DENABLE_BASIC_PRINTING=1 -DENABLE_PRINT_PREVIEW=1 -DENABLE_SPELLCHECK=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SETTINGS_APP=1 -DENABLE_SUPERVISED_USERS=1 -DENABLE_MDNS=1 -DENABLE_SERVICE_DISCOVERY=1 -DV8_USE_EXTERNAL_STARTUP_DATA -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DSAFE_BROWSING_SERVICE -DUSE_LIBPCI=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_DEBUG -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GLIBCXX_DEBUG=1 -Igen -I../../third_party/libvpx/source/config/linux/x64 -I../../third_party/libvpx/source/libvpx -fstack-protector --param=ssp-buffer-size=4 -Werror -pthread -fno-strict-aliasing -Wno-unused-parameter -Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC -Wno-reserved-user-defined-literal -Xclang -load -Xclang /usr/local/google/home/charliea/chrome/src/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -fcolor-diagnostics -B/usr/local/google/home/charliea/chrome/src/third_party/binutils/Linux_x64/Release/bin -Wno-conversion -Wno-parentheses-equality -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wno-c++11-narrowing -Wno-deprecated-register -Wno-inconsistent-missing-override -mssse3 -Wno-format -Wno-unused-result -m64 -march=x86-64 -O0 -g -gdwarf-4 -funwind-tables -gsplit-dwarf -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare) . /usr/local/google/home/charliea/chrome/src/out/Debug))"

I'd say the command took at least a minute to execute, though.

If I just run (irony-cdb-json--load-db (irony-cdb-json--locate-db)), it takes about the same amount of time.

Sarcasm commented 9 years ago

Yeah, reading the compilation database is slow, the implementation is far from optimal for big projects, see #176. This is likely to change in the future.

zeptonaut commented 9 years ago

Is there any reason that you can see that this would prevent (irony-cdb-menu) from saying that there was a database, though?

Sarcasm commented 9 years ago

You mean that even after a minute the compilation database menu say that no compilation database was found?

zeptonaut commented 9 years ago

Yep. It immediately says "no compilation database found", but even if I wait a few minutes, it continues to say the same thing.

Sarcasm commented 9 years ago

Okay, I think I can reproduce the issue now but I haven't really changed Irony much lately so I'm wondering if it's not due to my Emacs version.

What version of Emacs are you using?

I have 24.5.1, I should try tomorrow at work to see on an older Emacs version.

Sarcasm commented 9 years ago

Nevermind, no issue with Emacs 24.5.1, my WIP on irony at home was the culprit.

Can you show your irony-mode configuration?