Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not find c++ include header in cross compiling situation. #157

Closed
sheeaza opened this issue Sep 19, 2019 · 12 comments
Closed

Can not find c++ include header in cross compiling situation. #157

sheeaza opened this issue Sep 19, 2019 · 12 comments

Comments

@sheeaza
Copy link

sheeaza commented Sep 19, 2019

clangd will use the compiler in the compile_commands.json to find the include path,
On my platform, the compiler is exported as:

$ export CXX=/path/to/4.14.98-wayland/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++

$CXX -E -x c++ - -v < /dev/null 2>&1 | \
      awk '/End of search list./ { show=0 } \
      { if (show) printf "-I%s\n",$1 }; \
      /#include <...> search starts here:/ { show=1; }'

-I/path/to/yocto/4.14.98-wayland/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/include
-I/path/to/yocto/4.14.98-wayland/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/include-fixed

This miss the c++ headers, and to locate the c++ headers, the compiler need the sysroot args.

export CXX=/path/toyocto/4.14.98-wayland/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++\ --sysroot\=/path/to/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux

$CXX -E -x c++ - -v < /dev/null 2>&1 | \
      awk '/End of search list./ { show=0 } \
      { if (show) printf "-I%s\n",$1 }; \
      /#include <...> search starts here:/ { show=1; }'

/path/to/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/aarch64-poky-linux
-I/path/to/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux/usr/include/c++/7.3.0/backward
-I/path/to/yocto/4.14.98-wayland/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/include
-I/path/to/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux/usr/lib/gcc/aarch64-poky-linux/7.3.0/include
-I/path/to/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux/usr/local/include
-I/path/to/yocto/4.14.98-wayland/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/include-fixed
-I/path/to/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux/usr/include/

There are already sysroots in the compile_commands.json files, but the clangd dont seem to use it to locate include paths.
So is it possible add the sysroot args to clangd to find all the c++ headers?

@kadircet
Copy link
Member

Could you also send clangd logs so that we can check what are the exact arguments clangd is using to invoke the compiler?

Also please take a look at query-driver command line argument: https://clang.llvm.org/extra/clangd/Configuration.html#query-driver

@sheeaza
Copy link
Author

sheeaza commented Sep 19, 2019


## versions

vim version: NVIM v0.4.2
node version: v11.10.1
coc.nvim version: 0.0.74-e8e583c8e0
term: tmux-256color
platform: linux

## Messages

## Output channel: highlight
[Info  - 5:04:17 PM] Highlight server running in node v11.10.1


## Output channel: languageserver.clangd
I[17:04:18.621] clangd version 10.0.0-svn371642-1~exp1+0~20190911181237.2478~1.gbp13c8b7 (trunk)
I[17:04:18.621] Working directory: /opt/samba/nxf47746/project/learn-test/cv-fisheye
I[17:04:18.621] argv[0]: clangd-10
I[17:04:18.622] argv[1]: --log=verbose
I[17:04:18.622] Starting LSP over stdin/stdout
V[17:04:18.622] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"preselectSupport":true,"snippetSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"contextSupport":true,"dynamicRegistration":true},"declaration":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"foldingRange":{"dynamicRegistration":true,"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"relatedInformation":true},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true}},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"documentChanges":true,"failureHandling":"textOnlyTransactional","resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"initializationOptions":{},"processId":20232,"rootPath":"/opt/samba/nxf47746/project/learn-test/cv-fisheye","rootUri":"file:///opt/samba/nxf47746/project/learn-test/cv-fisheye","trace":"off","workspaceFolders":[{"name":"cv-fisheye","uri":"file:///opt/samba/nxf47746/project/learn-test/cv-fisheye"}]}}

I[17:04:18.622] <-- initialize(0)
I[17:04:18.623] --> reply:initialize(0) 0 ms
V[17:04:18.623] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",">",":"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":2,"typeHierarchyProvider":true,"workspaceSymbolProvider":true}}}

V[17:04:18.625] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[17:04:18.625] <-- initialized
I[17:04:18.625] unhandled notification initialized
V[17:04:18.631] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"#include <cstdio>\n#include <iostream>\n#include <string>\n#include <vector>\n#include <chrono>\n#include <thread>\n#include <map>\n\n#include <signal.h>\n#include <sys/epoll.h>\n#include <sys/poll.h>\n#include <unistd.h>\n#include <pthread.h>\n#include <fcntl.h>\n\n#include <opencv2/opencv.hpp>\n\n#include \"render.hpp\"\n#include \"v4l2capture.hpp\"\n#include \"replxx.hxx\"\n#include \"message.hpp\"\n\nclass RenderWorker\n{\npublic:\nstruct Commit {};\n\n    RenderWorker(Render& render_) :\n        render(render_)\n    {}\n\n    messaging::Sender getSender()\n    {\n        return incoming;\n    }\n\n    void run()\n    {\n        try {\n            for(;;) {\n                incoming.wait()\n                    .handle<std::shared_ptr<PixelBufferBase>>(\n                        [&](std::shared_ptr<PixelBufferBase>& pbuf)\n                        {\n                            render.updateTexture(pbuf);\n                        }\n                    )\n                    .handle<Commit>(\n                        [&](Commit&)\n                        {\n                            render.render(0);\n                        }\n                    );\n            }\n        } catch(messaging::CloseQueue&) {\n        }\n    }\n\n    void done()\n    {\n        getSender().send(messaging::CloseQueue());\n    }\n\nprivate:\n    Render& render;\n    messaging::Receiver incoming;\n    void (RenderWorker::*state)();\n};\n\nclass CaptureWorker\n{\npublic:\n    struct PreviewAll {};\n\n    struct PreviewOne\n    {\n        PreviewOne(int num_ = 0) :\n            num(num_)\n        {}\n\n        int num;\n    };\n\n    CaptureWorker(std::vector<v4l2::Capture>& caps, enum v4l2::PixFormat pixFormat,\n                  const std::vector<std::vector<PixelBufferBase>>& bufBank,\n                  messaging::Sender render_) :\n        captures(caps),\n        render(render_)\n    {\n        for (size_t i = 0; i < captures.size(); i++) {\n            captures[i].open(\"/dev/video\" + std::to_string(i), pixFormat, bufBank[i]);\n            captures[i].start();\n        }\n    }\n\n    void run()\n    {\n        try {\n            for (;;) {\n                incoming.wait()\n                    .handle<PreviewAll>(\n                        [&](const PreviewAll&)\n                        {\n                            epoll_fd = epoll_create1(0);\n\n                            for (size_t i = 0; i < captures.size(); i++) {\n                                struct epoll_event event = {};\n                                event.data.u32 = i;\n                                event.events = EPOLLIN; // do not use edge trigger\n                                int ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, captures[i].getFd(),\n                                        &event);\n                                if (ret == -1)\n                                    throw std::runtime_error(\"EPOLL_CTL_ADD error\");\n                            }\n\n                            while (incoming.empty()) {\n                                std::vector<struct epoll_event> events(captures.size());\n                                int nevent = epoll_wait(epoll_fd, events.data(), events.size(), -1);\n                                if (nevent == -1) {\n                                    if (errno != EINTR)\n                                        throw std::runtime_error(\"epoll_wait error, erron: \" + std::to_string(errno));\n                                }\n\n                                for (int i = 0; i < nevent; i++) {\n                                    int data = events[i].data.u32;\n                                    std::shared_ptr<PixelBufferBase> pb(captures[data].dequeBuffer());\n                                    render.send(pb);\n                                }\n                                render.send(RenderWorker::Commit());\n                            }\n\n                            // do not stop, bug in kernel driver\n                            // for (auto& m : captures) {\n                                // m.stop();\n                            // }\n                            close(epoll_fd);\n                        }\n                    )\n                    .handle<PreviewOne>(\n                        [&](const PreviewOne& msg)\n                        {\n                            currentCapture = msg.num;\n                            epoll_fd = epoll_create1(0);\n                            {\n                                // captures[currentCapture].start();\n                                struct epoll_event event = {};\n                                event.data.u32 = currentCapture;\n                                event.events = EPOLLIN;\n                                int ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, captures[currentCapture].getFd(), &event);\n                                if (ret == -1)\n                                    throw std::runtime_error(\"EPOLL_CTL_ADD error\");\n                            }\n\n                            while (incoming.empty()) {\n                                struct epoll_event event;\n                                int nevent = epoll_wait(epoll_fd, &event, 1, -1);\n                                if (nevent == -1) {\n                                    if (errno != EINTR)\n                                        throw std::runtime_error(\"epoll_wait error, erron: \" + std::to_string(errno));\n                                }\n\n                                int data = event.data.u32;\n                                std::shared_ptr<PixelBufferBase> pb(captures[data].dequeBuffer());\n                                render.send(pb);\n                                render.send(RenderWorker::Commit());\n                            }\n\n                            // do not stop, bug in kernel driver\n                            // captures[currentCapture].stop();\n                            close(epoll_fd);\n                        }\n                    );\n            }\n        } catch (messaging::CloseQueue&) {\n        }\n    }\n\n    void done()\n    {\n        getSender().send(messaging::CloseQueue());\n    }\n\n    messaging::Sender getSender()\n    {\n        return incoming;\n    }\n\nprivate:\n    std::vector<v4l2::Capture>& captures;\n    int epoll_fd;\n    int currentCapture = 0;\n\n    messaging::Receiver incoming;\n    messaging::Sender render;\n    messaging::Sender calibrator;\n    void (CaptureWorker::*state)();\n};\n\n#if 0\nclass CliWorker\n{\nstruct Input\n{\n    std::string str;\n    Input(const std::string str_) :\n        str(str_)\n    {}\n};\n\npublic:\n    CliWorker(replxx::Replxx& rx_, messaging::Sender capture_) :\n        rx(rx_),\n        capture(capture_)\n    {\n    }\n\n    void run()\n    {\n        state = &CliWorker::intrinsicStep;\n        try {\n            for (;;) {\n                (this->*state)();\n            }\n        } catch (messaging::CloseQueue&) {\n        }\n    }\n\n    void done()\n    {\n        getSender().send(messaging::CloseQueue());\n    }\n\n    messaging::Sender getSender()\n    {\n        return incoming;\n    }\n\nprivate:\n    void intrinsicStep()\n    {\n        capture.send(v4l2::PreviewAll());\n        incoming.wait()\n            .handle<Input>(\n                [&](const Input& in)\n                {\n                    capture.send();\n                    state = &CliWorker::calibOneStep;\n                }\n            );\n    }\n\n    void calibOneStep()\n    {\n        // capture.send(messaging::);\n        // incoming.wait()\n            // .handle<>(\n            // );\n    }\n\n    replxx::Replxx& rx;\n    messaging::Receiver incoming;\n    messaging::Sender capture;\n\n    void (CliWorker::*state)();\n};\n#endif\n\n// namespace menu\n// {\n\n// struct Pack\n// {\n    // std::string help;\n\n// };\n\n// struct MsgPack\n// {\n    // std::map<std::string>\n// };\n\n// }\n\nint main()\n{\n    int cameraNum = 4;\n    int qBufNum = 4;\n    int imgWidth = 1280;\n    int imgHeight = 800;\n    enum v4l2::PixFormat pixelFmt = v4l2::PixFormat::XBGR32;\n    int pixelSize = pixelFmt == v4l2::PixFormat::XBGR32 ? 4 : 4;\n    int imgSize = imgHeight * imgWidth * pixelSize;\n\n    // signal(SIGINT, [](int){ keepRunning = false; });\n    std::vector<v4l2::Capture> captures(cameraNum);\n\n    try {\n\n        Render render(imgWidth, imgHeight, pixelSize, cameraNum, qBufNum);\n        render.init();\n        std::vector<std::vector<PixelBufferBase>> bufBank = render.getBufferBank();\n\n        RenderWorker renderWorker(render);\n        CaptureWorker capWorker(captures, pixelFmt, bufBank, renderWorker.getSender());\n\n        // cmdline interface\n        using namespace std::placeholders;\n        using Replxx = replxx::Replxx;\n        std::string input;\n\n        replxx::Replxx rx;\n        rx.install_window_change_handler();\n\n        rx.set_max_history_size(128);\n        rx.set_max_hint_rows(3);\n        rx.bind_key( Replxx::KEY::BACKSPACE, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::DELETE_CHARACTER_LEFT_OF_CURSOR, _1 ) );\n        rx.bind_key( Replxx::KEY::DELETE, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::DELETE_CHARACTER_UNDER_CURSOR, _1 ) );\n        rx.bind_key( Replxx::KEY::LEFT, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::MOVE_CURSOR_LEFT, _1 ) );\n        rx.bind_key( Replxx::KEY::RIGHT, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::MOVE_CURSOR_RIGHT, _1 ) );\n        rx.bind_key( Replxx::KEY::UP, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::HISTORY_PREVIOUS, _1 ) );\n        rx.bind_key( Replxx::KEY::DOWN, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::HISTORY_NEXT, _1 ) );\n        rx.bind_key( Replxx::KEY::PAGE_UP, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::HISTORY_FIRST, _1 ) );\n        rx.bind_key( Replxx::KEY::PAGE_DOWN, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::HISTORY_LAST, _1 ) );\n        rx.bind_key( Replxx::KEY::HOME, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::MOVE_CURSOR_TO_BEGINING_OF_LINE, _1 ) );\n        rx.bind_key( Replxx::KEY::END, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::MOVE_CURSOR_TO_END_OF_LINE, _1 ) );\n        rx.bind_key( Replxx::KEY::TAB, std::bind( &Replxx::invoke, &rx, Replxx::ACTION::COMPLETE_LINE, _1 ) );\n        std::cout\n            << \"Welcome to Replxx\\n\"\n            << \"Press 'tab' to view autocompletions\\n\"\n            << \"Type '.help' for help\\n\"\n            << \"Type '.quit' or '.exit' to exit\\n\\n\";\n\n        std::string prompt {\"\\x1b[1;32mreplxx\\x1b[0m> \"};\n\n        // run thread\n        std::thread renderThread(&RenderWorker::run, &renderWorker);\n        std::thread captureThread(&CaptureWorker::run, &capWorker);\n        messaging::Sender capQueue(capWorker.getSender());\n        capQueue.send(CaptureWorker::PreviewAll());\n\n        std::string help1(std::string(\"input number: 0 to \") + std::to_string(captures.size() - 1) + \" to select device\");\n\n        std::string help2(std::string(\"Input:\\n\") +\n                          \"\\t\\'b\\': back\");\n\n        const std::string* phelp = &help1;\n\n        std::function<void(void)>* stage;\n        std::function<void(void)> f2;\n\n        std::function<void(void)> f1 =\n            [&]()\n            {\n                int num;\n                try {\n                    num = std::stoi(input);\n\n                    if (num >= captures.size()) {\n                        throw(num);\n                    }\n\n                    capQueue.send(CaptureWorker::PreviewOne(num));\n                    stage = &f2;\n                    phelp = &help2;\n                } catch (...) {\n                    std::cout << \"invalid input\" << std::endl;\n                }\n            };\n\n        f2 =\n            [&]()\n            {\n                if (input.compare(\"b\") == 0) {\n                    capQueue.send(CaptureWorker::PreviewAll());\n                    stage = &f1;\n                    phelp = &help2;\n                } else {\n                    std::cout << \"invalid input\" << std::endl;\n                }\n            };\n        stage = &f1;\n\n        for (;;) {\n            char const* cinput{ nullptr };\n\n            std::cout << *phelp << std::endl;\n\n            do {\n                cinput = rx.input(prompt);\n            } while ( ( cinput == nullptr ) && ( errno == EAGAIN ) );\n\n            if (cinput == nullptr) {\n                break;\n            }\n\n            // change cinput into a std::string\n            // easier to manipulate\n            // std::string input {cinput};\n            input = std::string(cinput);\n\n            if (input.empty()) {\n                // user hit enter on an empty line\n\n                continue;\n\n            } else if (input.compare(0, 5, \".quit\") == 0 || input.compare(0, 5, \".exit\") == 0) {\n                // exit the repl\n\n                rx.history_add(input);\n                break;\n\n            } else if (input.compare(0, 5, \".help\") == 0) {\n                // display the help output\n                std::cout\n                    << \".help\\n\\tdisplays the help output\\n\"\n                    << \".quit\\n\\texit the repl\\n\"\n                    << \".exit\\n\\texit the repl\\n\"\n                    << \".clear\\n\\tclears the screen\\n\"\n                    << \".history\\n\\tdisplays the history output\\n\"\n                    << \".prompt <str>\\n\\tset the repl prompt to <str>\\n\";\n\n                rx.history_add(input);\n                continue;\n\n            } else if (input.compare(0, 7, \".prompt\") == 0) {\n                // set the repl prompt text\n                auto pos = input.find(\" \");\n                if (pos == std::string::npos) {\n                    std::cout << \"Error: '.prompt' missing argument\\n\";\n                } else {\n                    prompt = input.substr(pos + 1) + \" \";\n                }\n\n                rx.history_add(input);\n                continue;\n\n            } else if (input.compare(0, 8, \".history\") == 0) {\n                // display the current history\n                for (size_t i = 0, sz = rx.history_size(); i < sz; ++i) {\n                    std::cout << std::setw(4) << i << \": \" << rx.history_line(i) << \"\\n\";\n                }\n\n                rx.history_add(input);\n                continue;\n\n            } else if (input.compare(0, 6, \".clear\") == 0) {\n                // clear the screen\n                rx.clear_screen();\n\n                rx.history_add(input);\n                continue;\n\n            } else {\n                // default action\n\n                (*stage)();\n\n                rx.history_add( input );\n                continue;\n            }\n        }\n\n        capWorker.done();\n        renderWorker.done();\n        captureThread.join();\n        renderThread.join();\n    } catch (const std::exception& e) {\n        std::cerr << e.what() << std::endl;\n        return -1;\n    }\n\n    return 0;\n}\n","uri":"file:///opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp","version":1}}}

I[17:04:18.631] <-- textDocument/didOpen
I[17:04:18.631] Enqueueing 17 commands for indexing
I[17:04:18.631] Updating file /opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp with command 
[/opt/samba/nxf47746/project/learn-test/cv-fisheye/build/src]
/opt/samba/nxf47746/project/sdk/yocto/4.14.98-wayland/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-g++ -target aarch64-poky-linux --driver-mode=g++ --sysroot=/opt/samba/nxf47746/project/sdk/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux -isystem /opt/samba/nxf47746/project/sdk/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux/usr/local/include -isystem /opt/samba/nxf47746/project/sdk/yocto/4.14.98-wayland/sysroots/aarch64-poky-linux/usr/include/opencv4 -I/opt/samba/nxf47746/project/learn-test/cv-fisheye/thirdparty/replxx/include -O2 -pipe -g -feliminate-unused-debug-types -g -o CMakeFiles/fisheye.dir/main.cpp.o -c /opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp -fsyntax-only -resource-dir=/usr/lib/llvm-10/lib/clang/10.0.0
V[17:04:18.633] Preamble for file /opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp cannot be reused. Attempting to rebuild it.
V[17:04:18.752] BackgroundIndex: building version 1 after loading index from disk
V[17:04:19.351] BackgroundIndex: serving version 1 (33674506 bytes)
V[17:04:19.771] index AST for /opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp (main=false): 
  symbol slab: 39702 symbols, 10218608 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 243 relations, 5144 bytes
V[17:04:20.359] Built preamble of size 10704680 for file /opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp
V[17:04:20.366] Trying to fix unresolved name "shared_ptr" in scopes: [std::]
V[17:04:20.366] Dex query tree: (LIMIT 10000 (& S=std:: T=dpt T=ptr T=edp T=har T=red T=are T=sha ?=Restricted For Code Completion))
V[17:04:20.366] Dex query tree: (LIMIT 10000 (& S=std:: T=dpt T=edp T=ptr T=har T=red T=are T=sha ?=Restricted For Code Completion))
V[17:04:20.370] Trying to fix unresolved name "vector" in scopes: [std::]
V[17:04:20.370] Dex query tree: (LIMIT 10000 (& S=std:: T=cto T=vec T=ect T=tor ?=Restricted For Code Completion))
V[17:04:20.370] Dex query tree: (LIMIT 10000 (& S=std:: T=cto T=vec T=ect T=tor ?=Restricted For Code Completion))
V[17:04:20.373] Trying to fix unresolved name "render_" in scopes: []
V[17:04:20.373] Dex query tree: (LIMIT 10000 (& T=ren T=end T=nde T=der S= ?=Restricted For Code Completion))
V[17:04:20.374] Dex query tree: (LIMIT 10000 (& T=ren T=end T=der T=nde S= ?=Restricted For Code Completion))
V[17:04:20.380] Trying to fix unresolved name "bufBank" in scopes: []
V[17:04:20.380] Dex query tree: (LIMIT 10000 (& T=ank T=fba T=ban T=ufb T=buf S= ?=Restricted For Code Completion))
V[17:04:20.380] Dex query tree: (LIMIT 10000 (& T=ank T=fba T=ban T=ufb T=buf S= ?=Restricted For Code Completion))
V[17:04:20.385] Trying to fix unresolved name "runtime_error" in scopes: [std::]
V[17:04:20.385] Dex query tree: (LIMIT 10000 (& S=std:: T=mee T=eer T=run T=nti T=rro T=ror T=err T=unt T=ime T=tim ?=Restricted For Code Completion))
V[17:04:20.385] Dex query tree: (LIMIT 10000 (& S=std:: T=mee T=run T=eer T=nti T=ror T=rro T=err T=unt T=ime T=tim ?=Restricted For Code Completion))
V[17:04:20.386] Trying to fix unresolved name "vector" in scopes: [std::]
V[17:04:20.388] Trying to fix unresolved name "events" in scopes: []
V[17:04:20.388] Trying to fix unresolved name "errno" in scopes: []
V[17:04:20.389] Trying to fix unresolved name "EINTR" in scopes: []
V[17:04:20.399] index AST for /opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp (main=true): 
  symbol slab: 26 symbols, 10256 bytes
  ref slab: 17 symbols, 31 refs, 4640 bytes
  relations slab: 0 relations, 24 bytes
I[17:04:20.400] --> textDocument/publishDiagnostics
V[17:04:20.400] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"'cstdio' file not found","range":{"end":{"character":17,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member","message":"No member named 'shared_ptr' in namespace 'std'","range":{"end":{"character":43,"line":41},"start":{"character":33,"line":41}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"ref_non_value","message":"'PixelBufferBase' does not refer to a value","range":{"end":{"character":59,"line":41},"start":{"character":44,"line":41}},"relatedInformation":[{"location":{"range":{"end":{"character":21,"line":235},"start":{"character":6,"line":235}},"uri":"file:///opt/samba/nxf47746/project/learn-test/cv-fisheye/src/message.hpp"},"message":"Declared here"}],"severity":1,"source":"clang"},{"code":"no_member_template","message":"No template named 'vector' in namespace 'std'","range":{"end":{"character":29,"line":83},"start":{"character":23,"line":83}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member_template","message":"No template named 'vector' in namespace 'std'","range":{"end":{"character":35,"line":84},"start":{"character":29,"line":84}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member","message":"No member named 'vector' in namespace 'std'","range":{"end":{"character":47,"line":84},"start":{"character":41,"line":84}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"ref_non_value","message":"'PixelBufferBase' does not refer to a value","range":{"end":{"character":63,"line":84},"start":{"character":48,"line":84}},"relatedInformation":[{"location":{"range":{"end":{"character":21,"line":235},"start":{"character":6,"line":235}},"uri":"file:///opt/samba/nxf47746/project/learn-test/cv-fisheye/src/message.hpp"},"message":"Declared here"}],"severity":1,"source":"clang"},{"code":"no_member_template","message":"No template named 'vector' in namespace 'std'","range":{"end":{"character":15,"line":188},"start":{"character":9,"line":188}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"undeclared_var_use_suggest","message":"Use of undeclared identifier 'render_'; did you mean 'render'? (fix available)","range":{"end":{"character":22,"line":87},"start":{"character":15,"line":87}},"relatedInformation":[{"location":{"range":{"end":{"character":28,"line":193},"start":{"character":22,"line":193}},"uri":"file:///opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp"},"message":"'render' declared here"}],"severity":1,"source":"clang"},{"code":"undeclared_var_use","message":"Use of undeclared identifier 'bufBank'","range":{"end":{"character":81,"line":90},"start":{"character":74,"line":90}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member","message":"No member named 'to_string' in namespace 'std'","range":{"end":{"character":58,"line":90},"start":{"character":49,"line":90}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member","message":"No member named 'runtime_error' in namespace 'std'","range":{"end":{"character":60,"line":112},"start":{"character":47,"line":112}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member","message":"No member named 'vector' in namespace 'std'","range":{"end":{"character":43,"line":116},"start":{"character":37,"line":116}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"expected_expression","message":"Expected expression","range":{"end":{"character":50,"line":116},"start":{"character":44,"line":116}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"undeclared_var_use","message":"Use of undeclared identifier 'events'","range":{"end":{"character":72,"line":117},"start":{"character":66,"line":117}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"undeclared_var_use","message":"Use of undeclared identifier 'events'","range":{"end":{"character":87,"line":117},"start":{"character":81,"line":117}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"undeclared_var_use","message":"Use of undeclared identifier 'errno'","range":{"end":{"character":45,"line":119},"start":{"character":40,"line":119}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"undeclared_var_use","message":"Use of undeclared identifier 'EINTR'","range":{"end":{"character":54,"line":119},"start":{"character":49,"line":119}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member","message":"No member named 'runtime_error' in namespace 'std'","range":{"end":{"character":64,"line":120},"start":{"character":51,"line":120}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"no_member","message":"No member named 'to_string' in namespace 'std'","range":{"end":{"character":109,"line":120},"start":{"character":100,"line":120}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"fatal_too_many_errors","message":"Too many errors emitted, stopping now","range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///opt/samba/nxf47746/project/learn-test/cv-fisheye/src/main.cpp"}}

Here is the log, and this issue shouldn't been caused by the query-driver, because the c header file is located right.

@sheeaza
Copy link
Author

sheeaza commented Sep 23, 2019

// Should we also preserve flags like "-sysroot", "-nostdinc" ?               
const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};         
                                                                              
if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,      
                                       Redirects)) {                          
  elog("System include extraction: driver execution failed with return code: "
       "{0}",                                                                 
       llvm::to_string(RC));                                                  
  return {};                                                                  
}            

in clang-tools-extra/clangd/QueryDriverDatabase.cpp [line 123] , it seem that clangd didn't preserve flags "-sysroot".

@topisani
Copy link

This patch fixed the issue for me: https://reviews.llvm.org/D73453

@topisani
Copy link

Before applying the mentioned patch, clangd doesnt find c++ includes, and others. It does locate GCCs own libraries, but not libstdc++

Below is the relevant part of the log, when clangd is called with /usr/bin/clangd --log=verbose "--query-driver=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/*/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-*"

As maybe obvious, this is in a yocto system cross compiling for arm.

V[10:30:38.404] System include extraction: adding  /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include
V[10:30:38.404] System include extraction: adding  /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed
I[10:30:38.404] System include extractor: succesfully executed /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++, got includes: "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include, /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed"
I[10:30:38.404] Updating file /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/src/services/engine_manager.cpp with command 
[/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/otto-core-1.0.0+git999]
/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -target arm-poky-linux-gnueabi --driver-mode=g++ -DLOGURU_STACKTRACES=0 -DOTTO_BOARD_PARTS_AUDIO_RTAUDIO -DOTTO_BOARD_PARTS_CONTROLLER_TOOT_MCU_FIFO -DOTTO_BOARD_PARTS_UI_EGL -DOTTO_BOARD_RPI_PROTO_1 -DOTTO_BUILD_DOCS=0 -DOTTO_BUILD_TESTS=1 -DOTTO_DEBUG_UI=0 -DOTTO_ENABLE_ASAN=0 -DOTTO_ENABLE_LTO=0 -DOTTO_ENABLE_TIMERS=0 -DOTTO_ENABLE_UBSAN=0 -DOTTO_USE_FBCP=0 -DOTTO_USE_LIBCXX=0 -D__LINUX_ALSA__ -I/home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/src/. -I/home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/boards/rpi-proto-1/include -I/home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/boards/parts/ui/egl/include -I/opt/vc/include -I/home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/boards/parts/audio/rtaudio/include -I/home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/boards/parts/controller/toot-mcu-fifo/include -I/home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/fmt -I/home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/lyra/include -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/include -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/nanovg/src -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/GSL -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/GSL/include -isystem external/include -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/foonathan_array/include -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/foonathan_type_safe/include -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/foonathan_type_safe/external/debug_assert -isystem /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/external/choreograph/src -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0=/usr/src/debug/otto-core/1.0.0+git999-r0 -fdebug-prefix-map=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0=/usr/src/debug/otto-core/1.0.0+git999-r0 -fdebug-prefix-map=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot= -fdebug-prefix-map=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native= -Wno-psabi -fvisibility-inlines-hidden -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot -Wall -Wno-long-long -Wno-pedantic -Wno-c++14-compat -Wno-psabi -Wno-unknown-pragmas -Wno-vla -Wno-sign-compare -DNDEBUG -ffast-math -funsafe-math-optimizations -mfpu=neon-vfpv4 -std=c++17 -include /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/otto-core-1.0.0+git999/src/otto_DOCTEST_STATIC_LIB_FORCE_LINK_DUMMIES//dummy_47.h -o src/CMakeFiles/otto.dir/services/engine_manager.cpp.o -c /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/src/services/engine_manager.cpp -isystem /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include -isystem /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed -fsyntax-only -resource-dir=/usr/lib/clang/9.0.1
V[10:30:38.425] Ignored diagnostic. unknown argument: '-fmacro-prefix-map=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0=/usr/src/debug/otto-core/1.0.0+git999-r0'
V[10:30:38.432] Preamble for file /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/src/services/engine_manager.cpp cannot be reused. Attempting to rebuild it.
V[10:30:38.432] Ignored diagnostic. unknown warning option '-Wno-psabi'
V[10:30:38.433] Ignored diagnostic. unknown warning option '-Wno-psabi'
V[10:30:38.435] Ignored diagnostic. unknown warning option '-Wno-psabi'
V[10:30:38.435] Ignored diagnostic. unknown warning option '-Wno-psabi'
V[10:30:38.603] BackgroundIndex: building version 1 after loading index from disk
V[10:30:39.085] BackgroundIndex: serving version 1 (33924116 bytes)
V[10:30:39.101] Indexing /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/test/graphics.t.cpp (digest:=5D6F16F92072AA4E)
V[10:30:39.109] Ignored diagnostic. unknown argument: '-fmacro-prefix-map=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0=/usr/src/debug/otto-core/1.0.0+git999-r0'
V[10:30:39.110] Ignored diagnostic. unknown warning option '-Wno-psabi'
V[10:30:39.112] Ignored diagnostic. /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/test/graphics.t.hpp:3:10:'functional' file not found
V[10:30:40.072] index AST for /home/topisani/dev/otto-bsp/build/workspace/sources/otto-core/src/services/engine_manager.cpp (main=false): 

@kadircet
Copy link
Member

thanks for the logs @topisani I can see --sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot in the command line arguments being passed to clang driver, I wonder why clang can't figure out where system directories are by looking at it.

what are the outputs of

/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -E -v -xc++ /dev/null

and

/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -E -v -xc++ /dev/null --sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot

please include both stderr and stdout

@topisani
Copy link

$ /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -E -v -xc++ /dev/null
Using built-in specs.
COLLECT_GCC=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++
Target: arm-poky-linux-gnueabi
Configured with: ../../../../../../work-shared/gcc-9.2.0-r0/gcc-9.2.0/configure --build=x86_64-linux --host=x86_64-linux --target=arm-poky-linux-gnueabi --prefix=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr --exec_prefix=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr --bindir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi --sbindir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi --libexecdir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/libexec/arm-poky-linux-gnueabi --datadir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/share --sysconfdir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/etc --sharedstatedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/com --localstatedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/var --libdir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/lib/arm-poky-linux-gnueabi --includedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/include --oldincludedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/include --infodir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/share/info --mandir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native --enable-clocale=generic --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --disable-multilib --enable-default-pie --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-lto --disable-libssp --enable-libitm --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=sysv --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --without-isl --with-gxx-include-dir=/not/exist/usr/include/c++/9.2.0 --with-sysroot=/not/exist --with-build-sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot --enable-poison-system-directories --with-system-zlib --disable-static --disable-nls --with-glibc-version=2.28 --enable-initfini-array
Thread model: posix
gcc version 9.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/cc1plus -E -quiet -v -iprefix /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/ -D_GNU_SOURCE /dev/null -mcpu=arm10tdmi -mtls-dialect=gnu -marm -march=armv5t
ignoring nonexistent directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/../../../../../arm-poky-linux-gnueabi/include"
ignoring nonexistent directory "/not/exist/usr/include/c++/9.2.0"
ignoring nonexistent directory "/not/exist/usr/include/c++/9.2.0/arm-poky-linux-gnueabi"
ignoring nonexistent directory "/not/exist/usr/include/c++/9.2.0/backward"
ignoring duplicate directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/../../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include"
ignoring nonexistent directory "/not/exist/usr/lib/arm-poky-linux-gnueabi/9.2.0/include"
ignoring nonexistent directory "/not/exist/usr/local/include"
ignoring duplicate directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/../../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed"
ignoring nonexistent directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/../../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/../../../../../arm-poky-linux-gnueabi/include"
ignoring nonexistent directory "/not/exist/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed
End of search list.
# 1 "/dev/null"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/dev/null"
COMPILER_PATH=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/:/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/
LIBRARY_PATH=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/:/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/
COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'

And with the sysroot

$ /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -E -v -xc++ /dev/null --sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot
Using built-in specs.
COLLECT_GCC=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++
Target: arm-poky-linux-gnueabi
Configured with: ../../../../../../work-shared/gcc-9.2.0-r0/gcc-9.2.0/configure --build=x86_64-linux --host=x86_64-linux --target=arm-poky-linux-gnueabi --prefix=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr --exec_prefix=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr --bindir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi --sbindir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi --libexecdir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/libexec/arm-poky-linux-gnueabi --datadir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/share --sysconfdir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/etc --sharedstatedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/com --localstatedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/var --libdir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/lib/arm-poky-linux-gnueabi --includedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/include --oldincludedir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/include --infodir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/share/info --mandir=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot-native --enable-clocale=generic --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --disable-multilib --enable-default-pie --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-lto --disable-libssp --enable-libitm --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=sysv --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --without-isl --with-gxx-include-dir=/not/exist/usr/include/c++/9.2.0 --with-sysroot=/not/exist --with-build-sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/x86_64-linux/gcc-cross-arm/9.2.0-r0/recipe-sysroot --enable-poison-system-directories --with-system-zlib --disable-static --disable-nls --with-glibc-version=2.28 --enable-initfini-array
Thread model: posix
gcc version 9.2.0 (GCC) 
COLLECT_GCC_OPTIONS='--sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot' '-E' '-v' '-shared-libgcc' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/cc1plus -E -quiet -v -iprefix /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/ -isysroot /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot -D_GNU_SOURCE /dev/null -mcpu=arm10tdmi -mtls-dialect=gnu -marm -march=armv5t
ignoring nonexistent directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/../../../../../arm-poky-linux-gnueabi/include"
ignoring duplicate directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/../../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include"
ignoring nonexistent directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/local/include"
ignoring duplicate directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/../../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed"
ignoring nonexistent directory "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/../../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/../../../../../arm-poky-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/include-fixed
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/include/c++/9.2.0
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/include/c++/9.2.0/arm-poky-linux-gnueabi
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/include/c++/9.2.0/backward
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/lib/arm-poky-linux-gnueabi/9.2.0/include
 /home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/include
End of search list.
# 1 "/dev/null"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "/dev/null"
COMPILER_PATH=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/:/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/
LIBRARY_PATH=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/:/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/:/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/lib/:/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/lib/arm-poky-linux-gnueabi/9.2.0/:/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot/usr/lib/
COLLECT_GCC_OPTIONS='--sysroot=/home/topisani/dev/otto-bsp/build/tmp/work/otto_proto_v1-poky-linux-gnueabi/otto-core/1.0.0+git999-r0/recipe-sysroot' '-E' '-v' '-shared-libgcc' '-mcpu=arm10tdmi' '-mtls-dialect=gnu' '-marm' '-march=armv5t'

So, as can be seen, the driver only outputs the paths for the gcc libs, if not supplied with the sysroot as an argument.

kadircet added a commit to llvm/llvm-project that referenced this issue Feb 5, 2020
Solves this issue: clangd/clangd#157

This is my first contribution to an llvm project, so I hope I'm doing it right!

Patch by @topisani (Tobias Pisani)!

Reviewers: kadircet, klimek

Differential Revision: https://reviews.llvm.org/D73811
@sheeaza
Copy link
Author

sheeaza commented Mar 18, 2020

This patch also fix my issue, thanks.

@sheeaza sheeaza closed this as completed Mar 18, 2020
arichardson pushed a commit to arichardson/llvm-project that referenced this issue Apr 1, 2020
Solves this issue: clangd/clangd#157

This is my first contribution to an llvm project, so I hope I'm doing it right!

Patch by @topisani (Tobias Pisani)!

Reviewers: kadircet, klimek

Differential Revision: https://reviews.llvm.org/D73811
sam-mccall pushed a commit to llvm/llvm-project that referenced this issue Jun 10, 2020
Solves this issue: clangd/clangd#157

This is my first contribution to an llvm project, so I hope I'm doing it right!

Patch by @topisani (Tobias Pisani)!

Reviewers: kadircet, klimek

Differential Revision: https://reviews.llvm.org/D73811

(cherry picked from commit 6e8d6bc)
@wrightleft
Copy link

wrightleft commented Dec 2, 2020

@topisani, did you get your problem resolved? I'm using Yocto and cannot get clangd to find the system headers too.

Sorry. I didn't notice that the patch was from you. I guess you solved your problem. I still wonder why my problem persists. Hmm.

ajohnson-uoregon pushed a commit to ajohnson-uoregon/clang-rewrite-only that referenced this issue Jul 17, 2022
Solves this issue: clangd/clangd#157

This is my first contribution to an llvm project, so I hope I'm doing it right!

Patch by @topisani (Tobias Pisani)!

Reviewers: kadircet, klimek

Differential Revision: https://reviews.llvm.org/D73811

(cherry picked from commit bc48e5f)
@kalj
Copy link

kalj commented Sep 21, 2022

I seem to be experiencing this exact issue with clangd built from git. Should I file a new issue or do we track it here?

I have this source file:

#include <iostream>

int main(int argc, char **argv) {
  std::cout << "hello\n";
  return 0;
}

and this compile_commands.json:

[
{
  "directory": "/home/kalle/dev/lsp-clangd-debugging/build-poky",
  "command": "/home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++ --sysroot=/home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux -o CMakeFiles/hello.dir/hello.cpp.o -c /home/kalle/dev/lsp-clangd-debugging/hello.cpp",
  "file": "/home/kalle/dev/lsp-clangd-debugging/hello.cpp"
}
]

Then, running clangd --check hello.cpp, I get this output:

I[22:02:34.060] clangd version 16.0.0 (git@github.com:llvm/llvm-project.git c0bc461999fdac918dd26867947c24eb6235c8d0)
I[22:02:34.060] Features: linux+debug
I[22:02:34.060] PID: 361828
I[22:02:34.060] Working directory: /home/kalle/dev/lsp-clangd-debugging
I[22:02:34.060] argv[0]: /usr/local/llvm/bin/clangd
I[22:02:34.060] argv[1]: --check=hello.cpp
I[22:02:34.061] Entering check mode (no LSP server)
I[22:02:34.061] Testing on source file /home/kalle/dev/lsp-clangd-debugging/hello.cpp
I[22:02:34.061] Loading compilation database...
I[22:02:34.062] Loaded compilation database from /home/kalle/dev/lsp-clangd-debugging/compile_commands.json
I[22:02:34.063] Compile command from CDB is: /home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++ --target=x86_64-poky-linux --driver-mode=g++ --sysroot=/home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux -o CMakeFiles/hello.dir/hello.cpp.o -c -resource-dir=/usr/local/llvm/lib/clang/16.0.0 -- /home/kalle/dev/lsp-clangd-debugging/hello.cpp
I[22:02:34.064] Parsing command...
I[22:02:34.066] internal (cc1) args are: -cc1 -triple x86_64-poky-linux -fsyntax-only -disable-free -clear-ast-before-backend -main-file-name hello.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/kalle/dev/lsp-clangd-debugging/build-poky -resource-dir /usr/local/llvm/lib/clang/16.0.0 -isysroot /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux -internal-isystem /usr/local/llvm/lib/clang/16.0.0/include -internal-isystem /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/local/include -internal-externc-isystem /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/include -internal-externc-isystem /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/include -fdeprecated-macro -fdebug-compilation-dir=/home/kalle/dev/lsp-clangd-debugging/build-poky -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -no-round-trip-args -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /home/kalle/dev/lsp-clangd-debugging/hello.cpp
I[22:02:34.066] Building preamble...
I[22:02:34.095] Indexing headers...
I[22:02:34.096] Built preamble of size 214292 for file /home/kalle/dev/lsp-clangd-debugging/hello.cpp version null in 0.03 seconds
E[22:02:34.097] [pp_file_not_found] Line 2: 'iostream' file not found
I[22:02:34.097] Building AST...
E[22:02:34.111] [undeclared_var_use] Line 7: use of undeclared identifier 'std'
I[22:02:34.111] Indexing AST...
I[22:02:34.111] Building inlay hints
I[22:02:34.112] Testing features at each token (may be slow in large files)
I[22:02:34.129] All checks completed, 2 errors

E.g. it does not find <iostream>.
Looking at the cc1 args, it is clear that the c++ include directories are missing, as if it had missed taking the sysroot into account.

Running /home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++ -E -x c++ - -v < /dev/null gives:

...
ignoring nonexistent directory "/not/exist/usr/include/c++/11.2.0"
ignoring nonexistent directory "/not/exist/usr/include/c++/11.2.0/x86_64-poky-linux"
ignoring nonexistent directory "/not/exist/usr/include/c++/11.2.0/backward"
ignoring nonexistent directory "/not/exist/usr/lib/x86_64-poky-linux/11.2.0/include"
ignoring nonexistent directory "/not/exist/usr/local/include"
ignoring nonexistent directory "/home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.2.0/../../../../../x86_64-poky-linux/include"
ignoring nonexistent directory "/not/exist/usr/include/"
#include "..." search starts here:
#include <...> search starts here:
 /home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.2.0/include
 /home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.2.0/include-fixed
End of search list.
...

By contrast, including the --sysroot arg -- /home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++ --sysroot=/home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux -E -x c++ - -v < /dev/null -- I instead get:

...
ignoring nonexistent directory "/home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/lib/x86_64-poky-linux/11.2.0/include"
ignoring nonexistent directory "/home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/local/include"
ignoring nonexistent directory "/home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.2.0/../../../../../x86_64-poky-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/include/c++/11.2.0
 /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/include/c++/11.2.0/x86_64-poky-linux
 /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/include/c++/11.2.0/backward
 /home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.2.0/include
 /home/kalle/misc/poky-install-x86_64/sysroots/x86_64-pokysdk-linux/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/11.2.0/include-fixed
 /home/kalle/misc/poky-install-x86_64/sysroots/core2-64-poky-linux/usr/include/
End of search list.

...

@HighCommander4
Copy link

@kalj could you file a new issue please to make sure it doesn't get lost, since this one is closed? (You can always link to this one if they seem related.)

@kalj
Copy link

kalj commented Sep 22, 2022

@HighCommander4 Thanks, done now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants