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

Error during index #521

Closed
ambihelical opened this issue Mar 15, 2018 · 19 comments
Closed

Error during index #521

ambihelical opened this issue Mar 15, 2018 · 19 comments

Comments

@ambihelical
Copy link
Contributor

I'm getting this error while indexing a cross-compiled project, many if not all files have the same issue.
The following was in Emacs buffer lsp-cquery stderr". Any help in debugging this would be appreciated. In the following, I replaced some job-sensitive information with [censored].

I'm on commit 1301569

2018-03-15 10:11:35.036 ( 0.072s) [indexer0 ]clang_translation_unit.cc:99 libclang generic failure for /home/[censored]/dev/[censored]/[censored]/External/tinyxml/tinyxml.cpp. Please try running the following, identify which flag causes the issue, and report a bug. cquery will then filter the flag for you automatically:
$ /home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-g++ -working-directory=/home/[censored]/dev/[censored]/build/External/tinyxml -DANDROID -DBOARD="Android" -DLOCALE="usa" -DMANUFACTURER="[censored]" -DPLATFORM_SETTINGS_FILE="/home/[censored]/dev/[censored]/[censored]/[censored]util/platform/AndroidPlatformSettings.h" -DUNQUOTED_BOARD=Android -Dtinyxml_EXPORTS -Wno-psabi --sysroot=/home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/sysroot -funwind-tables -fsigned-char -no-canonical-prefixes -march=armv7-a -fdata-sections -ffunction-sections -Wa,--noexecstack -std=c++11 -L/home/[censored]/dev/[censored]/[censored]/app/android/build/libs/armeabi-v7a/ -lgnustl_shared -llog -DANDROID -pipe -Wall -Wtype-limits -Wuninitialized -fmessage-length=0 -ftabstop=4 -Wno-unknown-pragmas -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DVERBOSE_LOGGING -DBUILD_DEBUG -DBUILD_TYPE=DEBUG -DREVISION_STRING="" -DVERSION_STRING="DEBUG" -g -ffunction-sections -fdata-sections -Os -ffast-math -fasynchronous-unwind-tables -fPIC -isystem /home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/sysroot/usr/include -isystem /home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/include/c++/4.9 -isystem /home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/include/c++/4.9/arm-linux-androideabi/armv7-a -fPIC /home/[censored]/dev/[censored]/[censored]/External/tinyxml/tinyxml.cpp -resource-dir=/home/[censored]/extern/cquery/build/release/lib/clang+llvm-6.0.0-x86_64-linux-gnu-ubuntu-14.04/lib/clang/6.0.0 -Wno-unknown-warning-option -fparse-all-comments -fsyntax-only

The result of doing what it requests is as follows:

arm-linux-androideabi-g++: error: unrecognized command line option '-working-directory=/home/[censored]/dev/[censored]/build/External/tinyxml'
arm-linux-androideabi-g++: error: unrecognized command line option '-resource-dir=/home/[censored]/extern/cquery/build/clang+llvm-6.0.0-x86_64-linux-gnu-ubuntu-14.04/lib/clang/6.0.0'
arm-linux-androideabi-g++: error: unrecognized command line option '-fparse-all-comments'

@edjubuh
Copy link
Contributor

edjubuh commented Mar 15, 2018

You need to use clang as your compiler. You can use clang --target=armv7-none-linux-androideabi (target found here), along with the additional sysroot info, which it looks like you might have.

Edit: clang needs to be the compiler cquery is instructed to use - you can still compile your actual binary with arm-linux-androideabi-g++

@ambihelical
Copy link
Contributor Author

ambihelical commented Mar 15, 2018

Sorry, I'm not very familiar with the tool. Where do I specify that?

@edjubuh
Copy link
Contributor

edjubuh commented Mar 15, 2018

Did you write your own .cquery or compile_commands.json file?

@ambihelical
Copy link
Contributor Author

The compile_commands.json file was auto-generated by cmake.

@MaskRay
Copy link
Contributor

MaskRay commented Mar 16, 2018

@ambihelical I think what @edjubuh meant is if you enclose some example entries of compile_commands.json, it will be more helpful

The clang compiler driver will behave like a cross compiler if its executable name is like arm-linux-androideabi-g++, the name essentially defines a -target

@ambihelical
Copy link
Contributor Author

@MaskRay here is the first entry, censored:
[
{
"directory": "/home/[censored]/dev/[censored]/build/External/tinyxml",
"command": "/home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-g++ -DANDROID -DBOARD=\"Android\" -DLOCALE=\"usa\" -DMANUFACTURER=\"[censored]\" -DPLATFORM_SETTINGS_FILE=\"/home/[censored]/dev/[censored]/[censored]/[censored]util/platform/AndroidPlatformSettings.h\" -DUNQUOTED_BOARD=Android -Dtinyxml_EXPORTS -Wno-psabi --sysroot=/home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/sysroot -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fdata-sections -ffunction-sections -Wa,--noexecstack -std=c++11 -L/home/[censored]/dev/[censored]/[censored]/app/android/build/libs/armeabi-v7a/ -lgnustl_shared -llog -DANDROID -pipe -Wall -Wtype-limits -Wuninitialized -fmessage-length=0 -ftabstop=4 -Wno-unknown-pragmas -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DVERBOSE_LOGGING -DBUILD_DEBUG -DBUILD_TYPE=DEBUG -DREVISION_STRING=\"\" -DVERSION_STRING=\"DEBUG\" -g -ffunction-sections -fdata-sections -Os -ffast-math -fasynchronous-unwind-tables -fPIC -isystem /home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/sysroot/usr/include -isystem /home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/include/c++/4.9 -isystem /home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/include/c++/4.9/arm-linux-androideabi/armv7-a -fPIC -o CMakeFiles/tinyxml.dir/tinyxml.cpp.o -c /home/[censored]/dev/[censored]/[censored]/External/tinyxml/tinyxml.cpp",
"file": "/home/[censored]/dev/[censored]/[censored]/External/tinyxml/tinyxml.cpp"
},

@Riatre
Copy link
Contributor

Riatre commented Mar 17, 2018

I suspect it is "-no-canonical-prefixes" that makes libclang bark.
Could you please change "/home/[censored]/dev/[censored]/android-sdk/toolchain/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-g++" to "clang -target arm-linux-androideabi" in your command line, try to execute this and confirm it?

@MaskRay MaskRay closed this as completed Mar 18, 2018
@ambihelical
Copy link
Contributor Author

@MaskRay Are there commits that addresses this? If not, I'll be able to provide more feedback when I go back to work.

@MaskRay
Copy link
Contributor

MaskRay commented Mar 18, 2018

Riatre pointed out the cause: -no-canonical-prefixes

@ambihelical
Copy link
Contributor Author

I don't understand how pointing out the cause, if it is the only problem, fixes the issue in any way. Is there something I need to do with that information that is escaping me?

@ambihelical
Copy link
Contributor Author

ambihelical commented Mar 20, 2018

@Riatre I used the cquery-downloaded clang as follows:

~/extern/cquery/build/clang+llvm-6.0.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++ -target arm-linux-androideabi [...rest of command...]

The following is the output:

clang++: warning: -lgnustl_shared: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: -llog: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: optimization flag '-finline-limit=64' is not supported [-Wignored-optimization-argument]
clang++: warning: argument unused during compilation: '-L/home/[censored]/app/android/build/libs/armeabi-v7a/' [-Wunused-command-line-argument]
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]

@ambihelical
Copy link
Contributor Author

@MaskRay, @jacobdufault, as far as I can tell this has not been resolved in any way that in my experience bugs are usually resolved, if you agree, please reopen, if not please let me know how I should follow up.

@jacobdufault
Copy link
Owner

I'll reopen, does removing -no-canonical-prefixes fix the issue?

@jacobdufault jacobdufault reopened this Mar 22, 2018
@ambihelical
Copy link
Contributor Author

Removing -fno-canonical-prefixes didn't help. I tried removing each option one by one from compile_commands.json using my best guess and then running emacs to test. Finally, after removing -march=armv7-a I no longer got the generic error.

@jacobdufault
Copy link
Owner

Sounds like we need to ban -march= flags, would you be willing to submit a PR changing project.cc?

@ambihelical
Copy link
Contributor Author

I'll give it a shot.

@ambihelical
Copy link
Contributor Author

@jacobdufault Stupid question: I see there are a number of tests, how do you run them? I tried e2e_test_runner.py, but it just crashes. After running waf -h, I tried ./waf list, but it just crashes. This is on Ubuntu 16.04

@jacobdufault
Copy link
Owner

e2e tests are still a WIP. ./build/release/bin/cquery --test-unit --test-index will run the unit and index tests.

@jacobdufault
Copy link
Owner

Closing in favor of #569, please let me know if this should be reopened.

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

5 participants