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

Query of clang-cl compiler fails with pre-release v17 #11207

Closed
jineens opened this issue Jul 17, 2023 · 6 comments
Closed

Query of clang-cl compiler fails with pre-release v17 #11207

jineens opened this issue Jul 17, 2023 · 6 comments
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@jineens
Copy link
Member

jineens commented Jul 17, 2023

Environment

  • OS and Version: Windows 10 19044
  • VS Code Version: insiders 1.81.0
  • C/C++ Extension Version: v1.16.3

Bug Summary and Steps to Reproduce

Bug Summary:
Error squiggles do not work, I think this is because the build configuration does not work with clang-cl, but I don't know what's going on there either. Regular intellisense (definition lookup, auto complete, etc) works fine.

image
languate_server_logging.txt
diagnostics_logging.txt

Configuration and Logs

c_cpp_properties.json:
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}",
                "${workspaceFolder}/**",
                "${workspaceFolder}/out/debug_x64/gen",
                "${workspaceFolder}/out/debug_x64/gen/third_party/perfetto",
                "${workspaceFolder}/third_party/abseil-cpp",
                "${workspaceFolder}/third_party/abseil-cpp/**",
                "${workspaceFolder}/third_party/skia",
                "${workspaceFolder}/third_party/skia/**",
                "${workspaceFolder}/third_party/boringssl/**",
                "${workspaceFolder}/third_party/boringssl/src/include",
                "${workspaceFolder}/third_party/webrtc/**",
                "${workspaceFolder}/third_party/webrtc"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "cStandard": "c17",
            "cppStandard": "c++20",
            "intelliSenseMode": "windows-clang-x64",
            "compileCommands": "${workspaceFolder}/out/debug_x64/compile_commands.json",
            "compilerPath": "${workspaceFolder}/third_party/llvm-build/Release+Asserts/bin/clang-cl.exe"
        }
    ],
    "version": 4
}
excerpt from compile_commands.json (gomacc is an middle process, clang-cl is the actual builder):
  {
    "directory": "D:\\purple\\src\\out\\debug_x64",
    "command": "D:\\blue\\depot_tools\\.cipd_bin\\gomacc.exe ..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\clang-cl.exe /c ../../chrome/browser/ui/webui/edge_dlp/dlp_internals_ui_message_handler.cc /Foobj/chrome/browser/ui/ui/dlp_internals_ui_message_handler.obj /nologo /showIncludes:user /winsysroot../../third_party/depot_tools/win_toolchain/vs_files/57841fa63e -DPDF_DIG_SIG_READ -DPDFCONTROL_ENABLE_MIP -DPDFCONTROL_ENABLE_DLL_CONSUMPTION -DPDFCONTROL_ENABLE_JS -DPDFCONTROL_ENABLE_FORMS -DDCHECK_ALWAYS_ON=1 -DUSE_AURA=1 \"-DEXCLUDE_FROM_EDGE=@\\\"EXCLUDE_FROM_EDGE is not a valid macro. Did you mean EXCLUDED_FROM_EDGE?\\\"\" -DMICROSOFT_EDGE_BUILD -DEDGE_HISTORY_JOURNAL_TELEMETRY -DEDGE_THIRD_PARTY_SERP_TELEMETRY -D_HAS_NODISCARD -D_CRT_NONSTDC_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_LIBCPP_ENABLE_ASSERTIONS=1 \"-DCR_CLANG_REVISION=\\\"llvmorg-16-edge-init-60439-g61786364-1\\\"\" -DCOMPONENT_BUILD -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ASSERTIONS_DISABLE_ASSUME -DCR_LIBCXX_REVISION=055b2e17ae4f0e2c025ad0c7508b01787df17758 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -D__WRL_DISABLE_STATIC_INITIALIZE__ -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_NI -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWEBP_EXTERN=extern -DLIBYUV_DISABLE_NEON -DUSE_EGL -DVK_USE_PLATFORM_WIN32_KHR -D_WTL_NO_AUTOMATIC_NAMESPACE -DTOOLKIT_VIEWS=1 -DON_FOCUS_PING_ENABLED -DABSL_CONSUME_DLL -DBORINGSSL_SHARED_LIBRARY -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -DGOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE=0 -DPROTOBUF_USE_DLLS -DWEBRTC_ENABLE_SYMBOL_EXPORT -DWEBRTC_ENABLE_AVX2 -DRTC_ENABLE_WIN_WGC -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_WIN -DABSL_ALLOCATOR_NOTHROW=1 -DLOGGING_INSIDE_WEBRTC -DSK_ENABLE_SKSL -DSK_UNTIL_CRBUG_1187654_IS_FIXED \"-DSK_USER_CONFIG_HEADER=\\\"../../skia/config/SkUserConfig.h\\\"\" -DSK_WIN_FONTMGR_NO_SIMULATIONS -DSK_DISABLE_LEGACY_SKSURFACE_METHODS -DSK_DISABLE_LEGACY_GRAPHITE_IMAGE_FACTORIES -DSK_DISABLE_LEGACY_GRAPHITE_IMAGE_METHODS -DSK_DISABLE_LEGACY_SKSURFACE_FACTORIES -DSK_DISABLE_LEGACY_SKSURFACE_FLUSH -DSK_DISABLE_LEGACY_SKSURFACE_AS_IMAGE -DSK_DISABLE_LEGACY_SKSURFACE_DISPLAYLIST -DSK_CODEC_DECODES_JPEG -DSK_CODEC_DECODES_PNG -DSK_CODEC_DECODES_WEBP -DSK_ENCODE_JPEG -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSK_HAS_WUFFS_LIBRARY -DSKIA_DLL -DSKCMS_API=__declspec(dllexport) -DGR_GL_FUNCTION_TYPE=__stdcall -DSK_GANESH \"-DSK_GPU_WORKAROUNDS_HEADER=\\\"gpu/config/gpu_driver_bug_workaround_autogen.h\\\"\" -DSK_GL -DSK_VULKAN=1 -DSK_GRAPHITE -DSK_DAWN -DWGPU_SHARED_LIBRARY -DCRASHPAD_ZLIB_SOURCE_EXTERNAL -DLEVELDB_PLATFORM_CHROMIUM=1 -DLEVELDB_SHARED_LIBRARY -DV8_USE_EXTERNAL_STARTUP_DATA -DUSING_V8_SHARED -DV8_ENABLE_CHECKS -DV8_COMPRESS_POINTERS -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_SANDBOX -DV8_DEPRECATION_WARNINGS -DCPPGC_CAGED_HEAP -DCPPGC_YOUNG_GENERATION -DCPPGC_POINTER_COMPRESSION -DCPPGC_SLIM_WRITE_BARRIER \"-DI18N_ADDRESS_VALIDATION_DATA_URL=\\\"https://chromium-i18n.appspot.com/ssl-aggregate-address/\\\"\" \"-DOPENSCREEN_TEST_DATA_DIR=\\\"third_party/openscreen/src/test/data/\\\"\" -DENABLE_TRACE_LOGGING -DFLATBUFFERS_LOCALE_INDEPENDENT=0 -DVR_USE_COMMAND_BUFFER -DGL_GLEXT_PROTOTYPES -DI18N_PHONENUMBERS_USE_ICU_REGEXP=1 -DI18N_PHONENUMBERS_USE_ALTERNATE_FORMATS=1 -DI18N_PHONENUMBERS_NO_THREAD_SAFETY=1 -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -Igen/third_party/dawn/include -I../../third_party/dawn/include -I../../third_party/libwebp/src/src -I../../third_party/libyuv/include -I../../third_party/jsoncpp/source/include -I../../third_party/khronos -I../../gpu -I../../third_party/vulkan-deps/vulkan-headers/src/include -Igen/third_party/private_membership/src -Igen/third_party/shell-encryption/src -Igen/components/policy/proto -I../../third_party/wtl/include -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -I../../third_party/ced/src -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/ipcz/include -I../../net/third_party/quiche/overrides -I../../net/third_party/quiche/src/quiche/common/platform/default -I../../net/third_party/quiche/src -Igen/net/third_party/quiche/src -I../../third_party/webrtc_overrides -I../../third_party/webrtc -Igen/third_party/webrtc -I../../third_party/skia -Igen/third_party/skia -I../../third_party/wuffs/src/release/c -I../../third_party/vulkan/include -Igen/third_party/metrics_proto -I../../third_party/crashpad/crashpad -I../../third_party/crashpad/crashpad/compat/win -I../../third_party/zlib -I../../third_party/leveldatabase -I../../third_party/leveldatabase/src -I../../third_party/leveldatabase/src/include -I../../third_party/libwebm/source -I../../third_party/mesa_headers -I../../v8/include -Igen/v8/include -I../../third_party/re2/src -I../../third_party/libaddressinput/src/cpp/include -I../../third_party/lzma_sdk -I../../third_party/lzma_sdk/C -I../../third_party/lzma_sdk/Asm/x86 -I../../third_party/openscreen/src -Igen/third_party/openscreen/src -I../../third_party/flatbuffers/src/include -I../../third_party/flatbuffers/src/src -I../../third_party/brotli/include -I../../third_party/onnxruntime_directml/include -I../../third_party/libphonenumber/dist/cpp/src -Igen/third_party/libphonenumber /W4 -Wimplicit-fallthrough -Wunreachable-code-aggressive -Wthread-safety /WX -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-nonportable-include-path -Wenum-compare-conditional -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-deprecated-this-capture -Wshadow -fno-delete-null-pointer-checks -fno-ident -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 /clang:-ffp-contract=off -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase -ffile-reproducible /Zc:sizedDealloc- /D__WRL_ENABLE_FUNCTION_STATICS__ -fmsc-version=1934 /Zc:dllexportInlines- -m64 /Brepro -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern /Od /Ob0 /GF /Z7 -gcodeview-ghash -Xclang -fuse-ctor-homing /guard:cf,nochecks /MDd -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang raw-ref-template-as-trivial-member -Xclang -plugin-arg-find-bad-constructs -Xclang check-stack-allocated -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-shadow -Wexit-time-destructors -Wno-redundant-parens -Wno-null-pointer-subtraction -DPROTOBUF_ALLOW_DEPRECATED=1 -Wno-redundant-parens -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare /std:c++20 -Wno-trigraphs /TP /GR- -I../../buildtools/third_party/libc++/trunk/include /Fd\"obj/chrome/browser/ui/ui_cc.pdb\"",
    "file": "../../chrome/browser/ui/webui/edge_dlp/dlp_internals_ui_message_handler.cc",
    "output": "obj/chrome/browser/ui/ui/dlp_internals_ui_message_handler.obj"
  },

C/C++ Configuration warnings is this line repeated over and over:
[7/17/2023, 1:31:23 PM] Unable to resolve configuration with compilerPath "D:\purple\src/third_party/llvm-build/Release+Asserts/bin/clang-cl.exe".  Using "cl.exe" instead.

Other Extensions

No response

Additional context

No response

@Colengms Colengms self-assigned this Jul 17, 2023
@Colengms
Copy link
Contributor

Hi @jineens .

The error you are seeing appears to be due to failing to 'query' your compiler (for system include paths and system defines). It's falling back to defaults, separately for each file in your compile_commands.json, which is why you're seeing duplicate messages.

Note that use of compileCommands overrides all other fields in your c_cpp_properties.json, except for the compilerPath, which overrides the compiler(s) used in compile_commands.json.

In your case, your compile_commands.json uses gomacc.exe. which appears to accept arguments similar to ccache, in that it's passed a command line with the actual compiler as the first argument. As a result, the compilerPath specified is replacing gomacc.exe and being passed the path to clang-cl.exe as an argument. Passing that to clang-cl.exe is likely causing it to return an error instead of the expected output.

We don't currently support gomacc, but we do support ccache, and could likely extend that support to gomacc. Would you like to use this issue as a feature request to track adding support for gomacc?

You may be able to work around the issue by specifying a compilerPath that refers to a bat/cmd file that simply strips the first argument passed to it (clang-cl.exe) and passes the remaining arguments to that.

For more clarify, you might want to set "C_Cpp.loggingLevel": "Debug" and check the C/C++ output channel for the command lines it's using to query your compiler.

@Colengms Colengms added Language Service more info needed The issue report is not actionable in its current state labels Jul 17, 2023
@jineens
Copy link
Member Author

jineens commented Jul 17, 2023 via email

@Colengms
Copy link
Contributor

This appears to be related to use of a clang-cl.exe built directly out of the LLVM main branch (pre-release) in which support for the /clang: prefix either being broken or removed. The C/C++ Extension requires that (or some alternatively) support in order to gather system include paths and system defined from clang-cl.exe. So, I've opened an issue against LLVM for this: llvm/llvm-project#63930

@Colengms Colengms added bug Feature: Configuration An issue related to configuring the extension or IntelliSense and removed more info needed The issue report is not actionable in its current state labels Jul 18, 2023
@Colengms Colengms changed the title Intellisense: cannot get error-squiggles to work; intellisense is convinced we're in c++99 so it can't find std::string; Query of clang-cl compiler fails with pre-release v17 Jul 18, 2023
@Colengms Colengms added this to the 1.17 milestone Jul 18, 2023
@Colengms
Copy link
Contributor

Update: This appears to be related to our use of /clang:-xc and /clang:-xc++, specifically. Previously these arguments did not actually work as we expected, with recent versions of clang-cl generating a warning, and version 17 apparently now considering this an error. We can fix this issue by using /TC and /TP instead, in combination with the /clang:-prefixed gcc arguments to solicit the system include paths and system defines. This should be fixed in our next release.

@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Jul 18, 2023
@sean-mcmanus sean-mcmanus modified the milestones: 1.17, 1.17.0 Jul 19, 2023
@michelleangela
Copy link
Contributor

Fix available in pre-release https://github.com/microsoft/vscode-cpptools/releases/tag/v1.17.0.

@michelleangela
Copy link
Contributor

@github-actions github-actions bot locked and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

5 participants