Bug 576156 - Indexer under Cmake build fails where it succeeds with managed build
Summary: Indexer under Cmake build fails where it succeeds with managed build
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-cmake (show other bugs)
Version: 10.4.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-build-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-21 11:28 EDT by Philip Clapham CLA
Modified: 2021-09-27 13:58 EDT (History)
4 users (show)

See Also:


Attachments
Cmake and Managed build projects of the same code (451.05 KB, application/x-zip-compressed)
2021-09-21 11:28 EDT, Philip Clapham CLA
no flags Details
Indexer Parser Log for CMake Project (30.19 KB, text/plain)
2021-09-22 04:19 EDT, Philip Clapham CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Clapham CLA 2021-09-21 11:28:55 EDT
Created attachment 287181 [details]
Cmake and Managed build projects of the same code

Using the attached two C projects (one CMake, one Managed build) I get different results from the indexer. I'm using the spdlog project for logging at version 1.9.2 and have copied the include directory into each project.

The code is the same in both projects:

#include "spdlog/spdlog.h"

int main()
{
  spdlog::default_logger_raw()->debug("Message {}", 5);
}

And in the Managed project it successfully indexes it as:

template<typename... Args>
void debug(fmt::format_string<Args...> fmt, Args &&...args)
{
    log(level::debug, fmt, std::forward<Args>(args)...);
}


but on the CMake project I get the error:

Invalid arguments '
Candidates are:
void debug(fmt::v8::basic_format_string<char,fmt::v8::type_identity<#0(...)>::type ...>, #0(...) && ...)
void debug(const #0 &)
'
Comment 1 Jonah Graham CLA 2021-09-21 16:16:17 EDT
@Martin does this example sound like it is in your area of knowledge? Thanks!

@Philip thank you for the report.
Comment 2 Martin Weber CLA 2021-09-21 16:51:16 EDT
´Invalid arguments '
Candidates are:
void ...´

Looks like a GCC error message to me.
o.e.cdt.jsoncdb just passes macros and include paths to the indexer. Maybe these differ between MBS build and CMake build. You can see the macros and includes if you open a source-file in the editor, then select menu Project | C/C++ Index | Create parser Log file. (No idea why this is not in the editor context menu.)
Comment 3 Philip Clapham CLA 2021-09-22 04:16:14 EDT
@Jonah @Nartin Thanks both for your help.

I built the parser log files for the two projects as you suggested, and noticed a key difference up front. In the CMake Project:

Include Search Path (option -I):
   /opt/rh/devtoolset-8/root/usr/include/c++/8
   /opt/rh/devtoolset-8/root/usr/include/c++/8/x86_64-redhat-linux
   /opt/rh/devtoolset-8/root/usr/include/c++/8/backward
   /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/include
   /usr/local/include
   /opt/rh/devtoolset-8/root/usr/include
   /usr/include

And in the Managed Build Project:
   /usr/include/c++/4.8.2
   /usr/include/c++/4.8.2/x86_64-redhat-linux
   /usr/include/c++/4.8.2/backward
   /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include
   /usr/local/include
   /usr/include

So I span up a new Managed Build project which uses the devtoolset-8 g++ compiler (using the 'Linux GCC' toolchain rather than the 'Cross GCC' default) and that new project also cannot index that function call. So perhaps its because of the g++ 8.3.1 compiler? I've attached the Parser log for the CMake Project to see if you can make anything of it.

Thanks,
Phil
Comment 4 Philip Clapham CLA 2021-09-22 04:19:10 EDT
Created attachment 287185 [details]
Indexer Parser Log for CMake Project
Comment 5 Martin Weber CLA 2021-09-22 13:56:31 EDT
@Philip These are two different compilers: One is GCC 8 and the other one is GCC 4.8.2.
This bug is definitely NOT related to the indexer.
Comment 6 Philip Clapham CLA 2021-09-27 06:02:05 EDT
Hi Martin,

Is this not just an indexer issue when using GCC 8?

I've discovered that if I modify the code to:

  spdlog::default_logger_raw()->debug(fmt::v8::basic_format_string<char>("Message {}"), 5);

i.e. tell the compiler/indexer up-front to convert the literal string to a basic_format_string, then the indexer is able to find the correct function.

Thanks,
Phil
Comment 7 Martin Weber CLA 2021-09-27 13:58:46 EDT
@Philip Sorry, when I said the bug is NOT related to the indexer, I assumed the error message was in the build-output console.
Actually, I cannot tell whether it is a bug in the indexer due to my lack of knowlege of the indexer code.