Skip to content

Support cross-compilation configurations for IntelliSense #1083

Closed

Description

I am sometimes working on my project using a cross-compilation toolchain (for example, working on a Mac laptop; the project targets Linux). I tried to configure IntelliSense to only search the project and the cross-compilation sysroot. But I got this error:

file: 'file:///<redacted>.cc'
severity: 'Info'
message: 'cannot open source file "Availability.h" (dependency of "<redacted>.h")'
at: '1,1'
source: ''

This is of course a macOS header. I am guessing the indexer might be scanning hard-coded host paths. It seems likely that to properly support cross-compilation, there would need to be a sysroot parameter to act as a final catch-all.

Activity

  1. sean-mcmanus commented on Sep 30, 2017

    @sean-mcmanus
    Contributor

    What is the configuration you're using in c_cpp_properties.json? It sounds like it may be using the macFrameworkPath. We don't scan any hard-coded host paths that aren't in the c_cpp_properties.json.

  2. jfroy commented on Oct 6, 2017

    @jfroy
    Author

    This is my c_cpp_properties.json, with minor edits for confidentiality.

    {
        "configurations": [
            {
                "name": "Foo",
                "includePath": [
                    "${workspaceRoot}",
                    "${workspaceRoot}/build/vscode/gen",
                    "${workspaceRoot}/build/vscode/GLog-prefix/install/include",
                    "${workspaceRoot}/third_party/gflags/include/linux",
                    "${workspaceRoot}/third_party/googletest/googletest/include",
                    "${workspaceRoot}/third_party/protobuf/src",
                    "${workspaceRoot}/tools/sdk/toolchain/include/c++/v1",
                    "${workspaceRoot}/tools/sdk/toolchain/lib/clang/4.0.1/include",
                    "${workspaceRoot}/tools/sdk/sysroot/usr/include",
                    "${workspaceRoot}/tools/sdk/sysroot/usr/include/x86_64-linux-gnu"
                ],
                "defines": [
                ],
                "intelliSenseMode": "clang-x64",
                "browse": {
                    "path": [
                        "${workspaceRoot}",
                        "${workspaceRoot}/build/vscode/gen",
                        "${workspaceRoot}/build/vscode/GLog-prefix/install/include",
                        "${workspaceRoot}/third_party/gflags/include/linux",
                        "${workspaceRoot}/third_party/googletest/googletest/include",
                        "${workspaceRoot}/third_party/protobuf/src",
                        "${workspaceRoot}/tools/sdk/toolchain/include/c++/v1",
                        "${workspaceRoot}/tools/sdk/toolchain/lib/clang/4.0.1/include",
                        "${workspaceRoot}/tools/sdk/sysroot/usr/include",
                        "${workspaceRoot}/tools/sdk/sysroot/usr/include/x86_64-linux-gnu"
                    ],
                    "limitSymbolsToIncludedHeaders": true,
                    "databaseFilename": ""
                }
            }
        ],
        "version": 3
    }

    Using VSCode 1.17.0 (1.17.0), ms-vscode.cpptools 0.13.1

  3. llatta commented on Oct 22, 2017

    @llatta

    I'm running into the same issue, cross compiling emscripten code from a Mac. It seems to be caused by some headers doing some

    #ifdef __APPLE__
    #include <SomeMacSpecificHeader.h> // error: file can't be found in Intellisense session, because no Mac specific include paths in my config
    

    If I manually add #undef __APPLE__ at the top of my source file, the intellisense errors go away. Of course modifying the source in this way is ugly. Is there a way to add this to the config options for the plugin? Either something to allow undefining options, or maybe an option for preventing whatever default defines the intellisense engine adds?

  4. jfroy commented on Oct 22, 2017

    @jfroy
    Author

    Ah, this good insight. The setting we may be missing the clang's -target. If we could specify that for the indexer, then we could convey the target platform and all the relevant compiler built-in defines would be set correctly.

  5. sean-mcmanus commented on Oct 23, 2017

    @sean-mcmanus
    Contributor

    You can use clang -v -E -x c++ - < /dev/null to see what includePath/defines you should use, but we don't currently have a way to remove defines that are hard-coded (they're currently built into the mac binary), but I think we eventually plan to make this configurable.

  6. bobbrow commented on Oct 23, 2017

    @bobbrow
    Contributor

    I think Lutz Latta (@llatta) nailed it. IntelliSense built for Mac always has __APPLE__ defined. The engine API doesn't currently give us an option for changing the target. I'll need to ask for it.

  7. rizickus commented on Jan 19, 2018

    @rizickus

    Is there any progress regarding this issue?

  8. sean-mcmanus commented on Jan 19, 2018

    @sean-mcmanus
    Contributor

    Rimantas (@rizickus) No progress has been made on this, but we just need to change the compile-time Linux/Mac defines to be based on some new setting. In regards to _WIN32, that should stop being defined when you change the intelliSenseMode to "clang-x64" -- do you use a cl.exe or gcc/clang when _WIN32 shouldn't be defined? Or make intelliSenseMode have more possible values for all the compiler/OS combinations.

  9. rizickus commented on Jan 23, 2018

    @rizickus

    Yes, changing to "clang-x64" removed _WIN32 define, thanks! I am using armclang.

  10. cody-greene commented on Apr 17, 2018

    @cody-greene

    Is there an issue# on the main vscode repo for for this option that I can track? And possibly help with? I'd love to use vscode + mingw to cross compile for windows from mac/linux.

  11. sean-mcmanus commented on Apr 17, 2018

    @sean-mcmanus
    Contributor

    Cody Greene (@cody-greene) The main vscode repo wouldn't be tracking this issue, because it's a C++ extension issue. The TODO work is on our closed-source side so there's nothing you could help with. We support cross-compilation in general via setting the compilerPath/intelliSenseMode, but there are just a bunch of hardcoded defines, mostly regarding Mac that can't be changed yet (using forcedInclude to do #undef might be a workaround).

  12. 33 remaining items

  13. sean-mcmanus commented on Dec 28, 2020

    @sean-mcmanus
    Contributor

    Sergey (@icegood) Yeah, it's being worked on for the next release. We'll post an update here when it's available to try in an insiders release.

  14. zakkie commented on Jan 17, 2021

    @zakkie

    I'm working on a project that targets embedded systems.

    • working on Macbook Pro
    • target system: Arduino (tiny ARM board)

    #6745 added definitions for Linux, macOS, WIndows, but no other definitions.

    I think it would be nice to have a option that allows users to define their own settings for a particular system without automatically adding them. (like "intelliSenseMode": "bare")

  15. icegood commented on Jan 20, 2021

    @icegood

    Just checked and it seems to work as expected. Good job!
    One more question: my project is cmake-based and contains custom third party libraries that provide custom header paths. Is it possible to propagate these paths from "CMake Tools" plugin to vscode-cpptools to make search/highlight correct? Or all we can do is to manually add all these extra headers in custom paths inside cpptools?

  16. sean-mcmanus commented on Jan 21, 2021

    @sean-mcmanus
    Contributor

    Sergey (@icegood) The PR at https://github.com/microsoft/vscode-cpptools/pull/6823/files enables cpptools to consume the new IntelliSense modes, but CMake-Tools hasn't been changed yet to send them. Is that what you're referring to? The existing releases should already support configuring IntelliSense includes/defines from CMake-Tools, but it's just the cross-compilation that is new.

  17. sean-mcmanus commented on Jan 21, 2021

    @sean-mcmanus
    Contributor
  18. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    and removed
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Jan 26, 2021
  19. bobbrow commented on Feb 8, 2021

    @bobbrow
    Contributor

    Yes, the old ("generic") enum values always implicitly add the platform based on your host OS. So if you use the extension on linux with 'gcc-arm', we will promote that to 'linux-gcc-arm'. The new enum values allow you to target other platforms.

  20. sean-mcmanus commented on Feb 8, 2021

    @sean-mcmanus
    Contributor
  21. locked and limited conversation to collaborators on Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature RequestFeature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicefixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions