clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
630 stars 109 forks source link

__float128 is not supported on Apple Silicon #473

Closed Season0518 closed 1 year ago

Season0518 commented 1 year ago

Hello, I recently wrote some algorithm problems using Macbook on the M2Max chip. When I use the bits/stdc++ header file, the header file displays: In included file: __float128 is not supported on this target . But the program can be compiled normally. Is this a BUG or am I using it inappropriately?

For a clearer description of the problem, here are my simplified directory structure and screenshots:

Error Info

image

Compile successfully

image

settings.json

{
    "clangd.arguments": [
        "--compile-commands-dir=${workspaceFolder}/build",
        "--query-driver=/opt/homebrew/bin/aarch64-apple-darwin22-g++-12",
        "--log=verbose",
        "--pretty"
    ],
    "cmake.configureOnOpen": true,
}

compile_commands.json

[
{
  "directory": "/Users/vm/test_cpp/build",
  "command": "/opt/homebrew/bin/aarch64-apple-darwin22-g++-12 -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -o CMakeFiles/ACM_Env.dir/main.cpp.o -c /Users/vm/test_cpp/main.cpp",
  "file": "/Users/vm/test_cpp/main.cpp",
  "output": "CMakeFiles/ACM_Env.dir/main.cpp.o"
}
]

CMakeFiles.txt

cmake_minimum_required(VERSION 3.24)
project(ACM_Env)

set(CMAKE_CXX_STANDARD 17)

add_executable(ACM_Env main.cpp)

Logs

I[14:12:06.814] Homebrew clangd version 16.0.0
I[14:12:06.815] Features: mac+xpc
I[14:12:06.815] PID: 2980
I[14:12:06.815] Working directory: /Users/vm/test_cpp
I[14:12:06.815] argv[0]: /opt/homebrew/opt/llvm/bin/clangd
I[14:12:06.815] argv[1]: --compile-commands-dir=/Users/vm/test_cpp/build
I[14:12:06.815] argv[2]: --query-driver=/opt/homebrew/bin/aarch64-apple-darwin22-g++-12
I[14:12:06.815] argv[3]: --log=verbose
I[14:12:06.815] argv[4]: --pretty
V[14:12:06.815] User config file is /Users/vm/Library/Preferences/clangd/config.yaml
I[14:12:06.815] Starting LSP over stdin/stdout
V[14:12:06.815] <<< {
  "id": 0,
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {
    "capabilities": {
      "general": {
        "markdown": {
          "parser": "marked",
          "version": "1.1.0"
        },
        "positionEncodings": [
          "utf-16"
        ],
        "regularExpressions": {
          "engine": "ECMAScript",
          "version": "ES2020"
        },
        "staleRequestSupport": {
          "cancel": true,
          "retryOnContentModified": [
            "textDocument/semanticTokens/full",
            "textDocument/semanticTokens/range",
            "textDocument/semanticTokens/full/delta"
          ]
        }
      },
      "notebookDocument": {
        "synchronization": {
          "dynamicRegistration": true,
          "executionSummarySupport": true
        }
      },
      "textDocument": {
        "callHierarchy": {
          "dynamicRegistration": true
        },
        "codeAction": {
          "codeActionLiteralSupport": {
            "codeActionKind": {
              "valueSet": [
                "",
                "quickfix",
                "refactor",
                "refactor.extract",
                "refactor.inline",
                "refactor.rewrite",
                "source",
                "source.organizeImports"
              ]
            }
          },
          "dataSupport": true,
          "disabledSupport": true,
          "dynamicRegistration": true,
          "honorsChangeAnnotations": false,
          "isPreferredSupport": true,
          "resolveSupport": {
            "properties": [
              "edit"
            ]
          }
        },
        "codeLens": {
          "dynamicRegistration": true
        },
        "colorProvider": {
          "dynamicRegistration": true
        },
        "completion": {
          "completionItem": {
            "commitCharactersSupport": true,
            "deprecatedSupport": true,
            "documentationFormat": [
              "markdown",
              "plaintext"
            ],
            "insertReplaceSupport": true,
            "insertTextModeSupport": {
              "valueSet": [
                1,
                2
              ]
            },
            "labelDetailsSupport": true,
            "preselectSupport": true,
            "resolveSupport": {
              "properties": [
                "documentation",
                "detail",
                "additionalTextEdits"
              ]
            },
            "snippetSupport": true,
            "tagSupport": {
              "valueSet": [
                1
              ]
            }
          },
          "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
            ]
          },
          "completionList": {
            "itemDefaults": [
              "commitCharacters",
              "editRange",
              "insertTextFormat",
              "insertTextMode"
            ]
          },
          "contextSupport": true,
          "dynamicRegistration": true,
          "editsNearCursor": true,
          "insertTextMode": 2
        },
        "declaration": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "definition": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "diagnostic": {
          "dynamicRegistration": true,
          "relatedDocumentSupport": false
        },
        "documentHighlight": {
          "dynamicRegistration": true
        },
        "documentLink": {
          "dynamicRegistration": true,
          "tooltipSupport": true
        },
        "documentSymbol": {
          "dynamicRegistration": true,
          "hierarchicalDocumentSymbolSupport": true,
          "labelSupport": 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
            ]
          },
          "tagSupport": {
            "valueSet": [
              1
            ]
          }
        },
        "foldingRange": {
          "dynamicRegistration": true,
          "foldingRange": {
            "collapsedText": false
          },
          "foldingRangeKind": {
            "valueSet": [
              "comment",
              "imports",
              "region"
            ]
          },
          "lineFoldingOnly": true,
          "rangeLimit": 5000
        },
        "formatting": {
          "dynamicRegistration": true
        },
        "hover": {
          "contentFormat": [
            "markdown",
            "plaintext"
          ],
          "dynamicRegistration": true
        },
        "implementation": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "inlayHint": {
          "dynamicRegistration": true,
          "resolveSupport": {
            "properties": [
              "tooltip",
              "textEdits",
              "label.tooltip",
              "label.location",
              "label.command"
            ]
          }
        },
        "inlineValue": {
          "dynamicRegistration": true
        },
        "linkedEditingRange": {
          "dynamicRegistration": true
        },
        "onTypeFormatting": {
          "dynamicRegistration": true
        },
        "publishDiagnostics": {
          "codeDescriptionSupport": true,
          "dataSupport": true,
          "relatedInformation": true,
          "tagSupport": {
            "valueSet": [
              1,
              2
            ]
          },
          "versionSupport": false
        },
        "rangeFormatting": {
          "dynamicRegistration": true
        },
        "references": {
          "dynamicRegistration": true
        },
        "rename": {
          "dynamicRegistration": true,
          "honorsChangeAnnotations": true,
          "prepareSupport": true,
          "prepareSupportDefaultBehavior": 1
        },
        "selectionRange": {
          "dynamicRegistration": true
        },
        "semanticTokens": {
          "augmentsSyntaxTokens": true,
          "dynamicRegistration": true,
          "formats": [
            "relative"
          ],
          "multilineTokenSupport": false,
          "overlappingTokenSupport": false,
          "requests": {
            "full": {
              "delta": true
            },
            "range": true
          },
          "serverCancelSupport": true,
          "tokenModifiers": [
            "declaration",
            "definition",
            "readonly",
            "static",
            "deprecated",
            "abstract",
            "async",
            "modification",
            "documentation",
            "defaultLibrary"
          ],
          "tokenTypes": [
            "namespace",
            "type",
            "class",
            "enum",
            "interface",
            "struct",
            "typeParameter",
            "parameter",
            "variable",
            "property",
            "enumMember",
            "event",
            "function",
            "method",
            "macro",
            "keyword",
            "modifier",
            "comment",
            "string",
            "number",
            "regexp",
            "operator",
            "decorator"
          ]
        },
        "signatureHelp": {
          "contextSupport": true,
          "dynamicRegistration": true,
          "signatureInformation": {
            "activeParameterSupport": true,
            "documentationFormat": [
              "markdown",
              "plaintext"
            ],
            "parameterInformation": {
              "labelOffsetSupport": true
            }
          }
        },
        "synchronization": {
          "didSave": true,
          "dynamicRegistration": true,
          "willSave": true,
          "willSaveWaitUntil": true
        },
        "typeDefinition": {
          "dynamicRegistration": true,
          "linkSupport": true
        },
        "typeHierarchy": {
          "dynamicRegistration": true
        }
      },
      "window": {
        "showDocument": {
          "support": true
        },
        "showMessage": {
          "messageActionItem": {
            "additionalPropertiesSupport": true
          }
        },
        "workDoneProgress": true
      },
      "workspace": {
        "applyEdit": true,
        "codeLens": {
          "refreshSupport": true
        },
        "configuration": true,
        "diagnostics": {
          "refreshSupport": true
        },
        "didChangeConfiguration": {
          "dynamicRegistration": true
        },
        "didChangeWatchedFiles": {
          "dynamicRegistration": true,
          "relativePatternSupport": true
        },
        "executeCommand": {
          "dynamicRegistration": true
        },
        "fileOperations": {
          "didCreate": true,
          "didDelete": true,
          "didRename": true,
          "dynamicRegistration": true,
          "willCreate": true,
          "willDelete": true,
          "willRename": true
        },
        "inlayHint": {
          "refreshSupport": true
        },
        "inlineValue": {
          "refreshSupport": true
        },
        "semanticTokens": {
          "refreshSupport": true
        },
        "symbol": {
          "dynamicRegistration": true,
          "resolveSupport": {
            "properties": [
              "location.range"
            ]
          },
          "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
            ]
          },
          "tagSupport": {
            "valueSet": [
              1
            ]
          }
        },
        "workspaceEdit": {
          "changeAnnotationSupport": {
            "groupsOnLabel": true
          },
          "documentChanges": true,
          "failureHandling": "textOnlyTransactional",
          "normalizesLineEndings": true,
          "resourceOperations": [
            "create",
            "rename",
            "delete"
          ]
        },
        "workspaceFolders": true
      }
    },
    "clientInfo": {
      "name": "Visual Studio Code",
      "version": "1.77.0"
    },
    "initializationOptions": {
      "clangdFileStatus": true,
      "fallbackFlags": []
    },
    "locale": "en",
    "processId": 2930,
    "rootPath": "/Users/vm/test_cpp",
    "rootUri": "file:///Users/vm/test_cpp",
    "trace": "off",
    "workspaceFolders": [
      {
        "name": "test_cpp",
        "uri": "file:///Users/vm/test_cpp"
      }
    ]
  }
}

I[14:12:06.815] <-- initialize(0)
V[14:12:06.815] Invoking /usr/bin/xcrun to find clang installation
V[14:12:06.820] Invoking /usr/bin/xcrun to find clang installation
I[14:12:06.825] --> reply:initialize(0) 9 ms
V[14:12:06.825] >>> {
  "id": 0,
  "jsonrpc": "2.0",
  "result": {
    "capabilities": {
      "astProvider": true,
      "callHierarchyProvider": true,
      "clangdInlayHintsProvider": true,
      "codeActionProvider": {
        "codeActionKinds": [
          "quickfix",
          "refactor",
          "info"
        ]
      },
      "compilationDatabase": {
        "automaticReload": true
      },
      "completionProvider": {
        "resolveProvider": false,
        "triggerCharacters": [
          ".",
          "<",
          ">",
          ":",
          "\"",
          "/",
          "*"
        ]
      },
      "declarationProvider": true,
      "definitionProvider": true,
      "documentFormattingProvider": true,
      "documentHighlightProvider": true,
      "documentLinkProvider": {
        "resolveProvider": false
      },
      "documentOnTypeFormattingProvider": {
        "firstTriggerCharacter": "\n",
        "moreTriggerCharacter": []
      },
      "documentRangeFormattingProvider": true,
      "documentSymbolProvider": true,
      "executeCommandProvider": {
        "commands": [
          "clangd.applyFix",
          "clangd.applyTweak"
        ]
      },
      "foldingRangeProvider": true,
      "hoverProvider": true,
      "implementationProvider": true,
      "inlayHintProvider": true,
      "memoryUsageProvider": true,
      "referencesProvider": true,
      "renameProvider": {
        "prepareProvider": true
      },
      "selectionRangeProvider": true,
      "semanticTokensProvider": {
        "full": {
          "delta": true
        },
        "legend": {
          "tokenModifiers": [
            "declaration",
            "definition",
            "deprecated",
            "deduced",
            "readonly",
            "static",
            "abstract",
            "virtual",
            "dependentName",
            "defaultLibrary",
            "usedAsMutableReference",
            "usedAsMutablePointer",
            "constructorOrDestructor",
            "userDefined",
            "functionScope",
            "classScope",
            "fileScope",
            "globalScope"
          ],
          "tokenTypes": [
            "variable",
            "variable",
            "parameter",
            "function",
            "method",
            "function",
            "property",
            "variable",
            "class",
            "interface",
            "enum",
            "enumMember",
            "type",
            "type",
            "unknown",
            "namespace",
            "typeParameter",
            "concept",
            "type",
            "macro",
            "modifier",
            "operator",
            "comment"
          ]
        },
        "range": false
      },
      "signatureHelpProvider": {
        "triggerCharacters": [
          "(",
          ")",
          "{",
          "}",
          "<",
          ">",
          ","
        ]
      },
      "standardTypeHierarchyProvider": true,
      "textDocumentSync": {
        "change": 2,
        "openClose": true,
        "save": true
      },
      "typeDefinitionProvider": true,
      "typeHierarchyProvider": true,
      "workspaceSymbolProvider": true
    },
    "serverInfo": {
      "name": "clangd",
      "version": "Homebrew clangd version 16.0.0 mac+xpc arm64-apple-darwin22.4.0"
    }
  }
}

V[14:12:06.826] <<< {
  "jsonrpc": "2.0",
  "method": "initialized",
  "params": {}
}

I[14:12:06.826] <-- initialized
V[14:12:06.829] <<< {
  "jsonrpc": "2.0",
  "method": "textDocument/didOpen",
  "params": {
    "textDocument": {
      "languageId": "cpp",
      "text": "// #include <iostream>\n#include <bits/stdc++.h>\n\nusing namespace std;\n\nint main(void) {\n  printf(\"Hello CMake\\n\");\n  return 0;\n}",
      "uri": "file:///Users/vm/test_cpp/main.cpp",
      "version": 1
    }
  }
}

I[14:12:06.829] <-- textDocument/didOpen
V[14:12:06.829] System include extraction: driver clang expanded to /opt/homebrew/opt/llvm/bin/clang
V[14:12:06.829] System include extraction: not allowed driver /opt/homebrew/opt/llvm/bin/clang
I[14:12:06.829] Loaded compilation database from /Users/vm/test_cpp/build/compile_commands.json
V[14:12:06.829] Broadcasting compilation database from /Users/vm/test_cpp/build
I[14:12:06.829] --> window/workDoneProgress/create(0)
V[14:12:06.829] >>> {
  "id": 0,
  "jsonrpc": "2.0",
  "method": "window/workDoneProgress/create",
  "params": {
    "token": "backgroundIndexProgress"
  }
}

I[14:12:06.829] Enqueueing 1 commands for indexing
V[14:12:06.831] <<< {
  "id": 0,
  "jsonrpc": "2.0",
  "result": null
}

I[14:12:06.831] <-- reply(0)
I[14:12:06.831] --> $/progress
V[14:12:06.831] >>> {
  "jsonrpc": "2.0",
  "method": "$/progress",
  "params": {
    "token": "backgroundIndexProgress",
    "value": {
      "kind": "begin",
      "percentage": 0,
      "title": "indexing"
    }
  }
}

I[14:12:06.831] --> $/progress
V[14:12:06.831] >>> {
  "jsonrpc": "2.0",
  "method": "$/progress",
  "params": {
    "token": "backgroundIndexProgress",
    "value": {
      "kind": "report",
      "message": "0/1",
      "percentage": 0
    }
  }
}

V[14:12:06.847] System include extraction: target extracted: "aarch64-apple-darwin22"
V[14:12:06.847] System include extraction: adding  /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12
V[14:12:06.847] System include extraction: adding  /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22
V[14:12:06.847] System include extraction: adding  /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward
V[14:12:06.847] System include extraction: adding  /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include
V[14:12:06.847] System include extraction: adding  /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed
V[14:12:06.847] System include extraction: adding  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include
V[14:12:06.847] System include extraction: adding  /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks
I[14:12:06.847] System includes extractor: successfully executed /opt/homebrew/bin/aarch64-apple-darwin22-g++-12
    got includes: "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12, /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22, /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward, /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include, /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed, /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include, /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks"
    got target: "aarch64-apple-darwin22"
I[14:12:06.847] ASTWorker building file /Users/vm/test_cpp/main.cpp version 1 with command 
[/Users/vm/test_cpp/build]
/opt/homebrew/Cellar/gcc/12.2.0/bin/aarch64-apple-darwin22-g++-12 --target=aarch64-apple-darwin22 --driver-mode=g++ -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -o CMakeFiles/ACM_Env.dir/main.cpp.o -c -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks -resource-dir=/opt/homebrew/Cellar/llvm/16.0.0/lib/clang/16 -- /Users/vm/test_cpp/main.cpp
V[14:12:06.848] Driver produced command: cc1 -cc1 -triple arm64-apple-macosx13.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -funwind-tables=1 -target-sdk-version=13.3 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +lse -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +neon -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -target-linker-version 820.1 -fcoverage-compilation-dir=/Users/vm/test_cpp/build -resource-dir /opt/homebrew/Cellar/llvm/16.0.0/lib/clang/16 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/local/include -internal-isystem /opt/homebrew/Cellar/llvm/16.0.0/lib/clang/16/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include -fdeprecated-macro -fdebug-compilation-dir=/Users/vm/test_cpp/build -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -no-round-trip-args -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /Users/vm/test_cpp/main.cpp
I[14:12:06.848] --> textDocument/clangd.fileStatus
V[14:12:06.848] >>> {
  "jsonrpc": "2.0",
  "method": "textDocument/clangd.fileStatus",
  "params": {
    "state": "parsing includes, running Update",
    "uri": "file:///Users/vm/test_cpp/main.cpp"
  }
}

V[14:12:06.848] Building first preamble for /Users/vm/test_cpp/main.cpp version 1
V[14:12:06.880] BackgroundIndex: building version 1 after loading index from disk
V[14:12:06.922] BackgroundIndex: serving version 1 (23279276 bytes)
I[14:12:06.928] --> $/progress
V[14:12:06.928] >>> {
  "jsonrpc": "2.0",
  "method": "$/progress",
  "params": {
    "token": "backgroundIndexProgress",
    "value": {
      "kind": "report",
      "message": "0/1",
      "percentage": 0
    }
  }
}

I[14:12:06.928] --> $/progress
V[14:12:06.928] >>> {
  "jsonrpc": "2.0",
  "method": "$/progress",
  "params": {
    "token": "backgroundIndexProgress",
    "value": {
      "kind": "end"
    }
  }
}

V[14:12:06.937] <<< {
  "id": 1,
  "jsonrpc": "2.0",
  "method": "textDocument/documentSymbol",
  "params": {
    "textDocument": {
      "uri": "file:///Users/vm/test_cpp/main.cpp"
    }
  }
}

I[14:12:06.937] <-- textDocument/documentSymbol(1)
V[14:12:06.937] <<< {
  "id": 2,
  "jsonrpc": "2.0",
  "method": "textDocument/codeAction",
  "params": {
    "context": {
      "diagnostics": [],
      "triggerKind": 2
    },
    "range": {
      "end": {
        "character": 10,
        "line": 1
      },
      "start": {
        "character": 9,
        "line": 1
      }
    },
    "textDocument": {
      "uri": "file:///Users/vm/test_cpp/main.cpp"
    }
  }
}

I[14:12:06.937] <-- textDocument/codeAction(2)
V[14:12:06.952] <<< {
  "id": 3,
  "jsonrpc": "2.0",
  "method": "textDocument/documentLink",
  "params": {
    "textDocument": {
      "uri": "file:///Users/vm/test_cpp/main.cpp"
    }
  }
}

I[14:12:06.952] <-- textDocument/documentLink(3)
V[14:12:06.952] <<< {
  "id": 4,
  "jsonrpc": "2.0",
  "method": "textDocument/inlayHint",
  "params": {
    "range": {
      "end": {
        "character": 1,
        "line": 8
      },
      "start": {
        "character": 0,
        "line": 0
      }
    },
    "textDocument": {
      "uri": "file:///Users/vm/test_cpp/main.cpp"
    }
  }
}

I[14:12:06.952] <-- textDocument/inlayHint(4)
V[14:12:07.140] <<< {
  "id": 5,
  "jsonrpc": "2.0",
  "method": "textDocument/foldingRange",
  "params": {
    "textDocument": {
      "uri": "file:///Users/vm/test_cpp/main.cpp"
    }
  }
}

I[14:12:07.140] <-- textDocument/foldingRange(5)
I[14:12:07.141] --> reply:textDocument/foldingRange(5) 0 ms
V[14:12:07.141] >>> {
  "id": 5,
  "jsonrpc": "2.0",
  "result": [
    {
      "endLine": 7,
      "kind": "region",
      "startCharacter": 16,
      "startLine": 5
    }
  ]
}

I[14:12:07.214] Indexing c++17 standard library in the context of /Users/vm/test_cpp/main.cpp
V[14:12:07.295] indexed preamble AST for /Users/vm/test_cpp/main.cpp version 1:
  symbol slab: 13962 symbols, 4361608 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 536 relations, 17432 bytes
V[14:12:07.331] Build dynamic index for header symbols with estimated memory usage of 9007312 bytes
V[14:12:07.332] Dropped diagnostic: /Users/vm/test_cpp/main.cpp: in included file: __float128 is not supported on this target
I[14:12:07.338] Built preamble of size 12439280 for file /Users/vm/test_cpp/main.cpp version 1 in 0.49 seconds
I[14:12:07.338] --> workspace/semanticTokens/refresh(1)
V[14:12:07.338] >>> {
  "id": 1,
  "jsonrpc": "2.0",
  "method": "workspace/semanticTokens/refresh",
  "params": null
}

V[14:12:07.339] <<< {
  "id": 1,
  "jsonrpc": "2.0",
  "result": null
}

I[14:12:07.339] <-- reply(1)
V[14:12:07.345] <<< {
  "id": 6,
  "jsonrpc": "2.0",
  "method": "textDocument/semanticTokens/full",
  "params": {
    "textDocument": {
      "uri": "file:///Users/vm/test_cpp/main.cpp"
    }
  }
}

I[14:12:07.345] <-- textDocument/semanticTokens/full(6)
V[14:12:07.359] indexed file AST for /Users/vm/test_cpp/main.cpp version 1:
  symbol slab: 1 symbols, 4448 bytes
  ref slab: 2 symbols, 2 refs, 4272 bytes
  relations slab: 0 relations, 24 bytes
V[14:12:07.359] Build dynamic index for main-file symbols with estimated memory usage of 11576 bytes
I[14:12:07.359] --> textDocument/publishDiagnostics
V[14:12:07.359] >>> {
  "jsonrpc": "2.0",
  "method": "textDocument/publishDiagnostics",
  "params": {
    "diagnostics": [
      {
        "code": "type_unsupported",
        "message": "In included file: __float128 is not supported on this target",
        "range": {
          "end": {
            "character": 10,
            "line": 1
          },
          "start": {
            "character": 9,
            "line": 1
          }
        },
        "relatedInformation": [
          {
            "location": {
              "range": {
                "end": {
                  "character": 51,
                  "line": 431
                },
                "start": {
                  "character": 41,
                  "line": 431
                }
              },
              "uri": "file:///opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/current/gcc/aarch64-apple-darwin22/12/include/stddef.h"
            },
            "message": "Error occurred here"
          }
        ],
        "severity": 1,
        "source": "clang"
      }
    ],
    "uri": "file:///Users/vm/test_cpp/main.cpp",
    "version": 1
  }
}

V[14:12:07.360] ASTWorker running DocumentSymbols on version 1 of /Users/vm/test_cpp/main.cpp
I[14:12:07.360] --> reply:textDocument/documentSymbol(1) 422 ms
V[14:12:07.360] >>> {
  "id": 1,
  "jsonrpc": "2.0",
  "result": [
    {
      "kind": 13,
      "name": "using namespace std",
      "range": {
        "end": {
          "character": 19,
          "line": 3
        },
        "start": {
          "character": 0,
          "line": 3
        }
      },
      "selectionRange": {
        "end": {
          "character": 19,
          "line": 3
        },
        "start": {
          "character": 16,
          "line": 3
        }
      }
    },
    {
      "detail": "int ()",
      "kind": 12,
      "name": "main",
      "range": {
        "end": {
          "character": 1,
          "line": 8
        },
        "start": {
          "character": 0,
          "line": 5
        }
      },
      "selectionRange": {
        "end": {
          "character": 8,
          "line": 5
        },
        "start": {
          "character": 4,
          "line": 5
        }
      }
    }
  ]
}

V[14:12:07.360] ASTWorker running EnumerateTweaks on version 1 of /Users/vm/test_cpp/main.cpp
I[14:12:07.360] --> reply:textDocument/codeAction(2) 422 ms
V[14:12:07.360] >>> {
  "id": 2,
  "jsonrpc": "2.0",
  "result": []
}

V[14:12:07.360] ASTWorker running DocumentLinks on version 1 of /Users/vm/test_cpp/main.cpp
I[14:12:07.360] --> reply:textDocument/documentLink(3) 408 ms
V[14:12:07.360] >>> {
  "id": 3,
  "jsonrpc": "2.0",
  "result": [
    {
      "range": {
        "end": {
          "character": 24,
          "line": 1
        },
        "start": {
          "character": 9,
          "line": 1
        }
      },
      "target": "file:///opt/homebrew/Cellar/gcc/12.2.0/include/c%2B%2B/12/aarch64-apple-darwin22/bits/stdc%2B%2B.h"
    }
  ]
}

V[14:12:07.360] ASTWorker running InlayHints on version 1 of /Users/vm/test_cpp/main.cpp
I[14:12:07.360] --> reply:textDocument/inlayHint(4) 407 ms
V[14:12:07.360] >>> {
  "id": 4,
  "jsonrpc": "2.0",
  "result": []
}

V[14:12:07.360] ASTWorker running SemanticHighlights on version 1 of /Users/vm/test_cpp/main.cpp
I[14:12:07.360] --> reply:textDocument/semanticTokens/full(6) 15 ms
V[14:12:07.360] >>> {
  "id": 6,
  "jsonrpc": "2.0",
  "result": {
    "data": [
      3,
      16,
      3,
      15,
      131584,
      2,
      4,
      4,
      3,
      131075,
      1,
      2,
      6,
      3,
      131584
    ],
    "resultId": "1"
  }
}

I[14:12:07.360] --> textDocument/clangd.fileStatus
V[14:12:07.360] >>> {
  "jsonrpc": "2.0",
  "method": "textDocument/clangd.fileStatus",
  "params": {
    "state": "idle",
    "uri": "file:///Users/vm/test_cpp/main.cpp"
  }
}

V[14:12:07.381] Ignored diagnostic. /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include/stddef.h:432:42:__float128 is not supported on this target
V[14:12:07.381] Ignored diagnostic. /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include/stddef.h:431:5:__float128 is not supported on this target
V[14:12:07.620] <<< {
  "id": 7,
  "jsonrpc": "2.0",
  "method": "textDocument/codeAction",
  "params": {
    "context": {
      "diagnostics": [
        {
          "code": "type_unsupported",
          "message": "In included file: __float128 is not supported on this target",
          "range": {
            "end": {
              "character": 10,
              "line": 1
            },
            "start": {
              "character": 9,
              "line": 1
            }
          },
          "relatedInformation": [
            {
              "location": {
                "range": {
                  "end": {
                    "character": 51,
                    "line": 431
                  },
                  "start": {
                    "character": 41,
                    "line": 431
                  }
                },
                "uri": "file:///opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/current/gcc/aarch64-apple-darwin22/12/include/stddef.h"
              },
              "message": "Error occurred here"
            }
          ],
          "severity": 1,
          "source": "clang"
        }
      ],
      "triggerKind": 2
    },
    "range": {
      "end": {
        "character": 10,
        "line": 1
      },
      "start": {
        "character": 9,
        "line": 1
      }
    },
    "textDocument": {
      "uri": "file:///Users/vm/test_cpp/main.cpp"
    }
  }
}

I[14:12:07.620] <-- textDocument/codeAction(7)
V[14:12:07.620] ASTWorker running EnumerateTweaks on version 1 of /Users/vm/test_cpp/main.cpp
I[14:12:07.620] --> reply:textDocument/codeAction(7) 0 ms
V[14:12:07.620] >>> {
  "id": 7,
  "jsonrpc": "2.0",
  "result": []
}

I[14:12:07.620] --> textDocument/clangd.fileStatus
V[14:12:07.620] >>> {
  "jsonrpc": "2.0",
  "method": "textDocument/clangd.fileStatus",
  "params": {
    "state": "idle",
    "uri": "file:///Users/vm/test_cpp/main.cpp"
  }
}

I[14:12:07.779] Indexed c++17 standard library (incomplete due to errors): 11092 symbols, 2715 filtered
V[14:12:07.812] Build dynamic index for header symbols with estimated memory usage of 8467140 bytes

System information Clangd version (from the log, or clangd --version):

Homebrew clangd version 16.0.0 Features: mac+xpc Platform: arm64-apple-darwin22.4.0

clangd extension version: v0.1.23

Operating system: MacOSX 13.3

HighCommander4 commented 1 year ago

Can you build the program successfully with clang as the compiler, or only with gcc?

Season0518 commented 1 year ago

Could you please tell me what exactly it means? Is it compiled with g++/clang under the command line? Or run with CMake? On the command line, it can also be compiled normally. ScreenShot:

image

The screenshot shows compiling and running with the corresponding toolchain

HighCommander4 commented 1 year ago

Does clang++ main.cpp work?

Season0518 commented 1 year ago

Yes,Because there is no bits/stdc++ header file under clang++, I replaced it with the header file that reported the error. The error persists, but compiles fine

image image

Update: Both clangd and clang++ come from llvm

image
HighCommander4 commented 1 year ago

Can you try keeping <bits/stdc++.h> but running clang with with clang++ -std=libstdc++ main.cpp?

This is a closer approximation to how clangd is trying to parse the code.

Season0518 commented 1 year ago

I tried but it doesn't work

image
HighCommander4 commented 1 year ago

My bad, I made a mistake with the flag: I meant -stdlib=libstdc++ rather than -std=libstdc++.

Season0518 commented 1 year ago

It doesn't matter, it's prompting like this now

image
HighCommander4 commented 1 year ago

Ok, I see, clang doesn't know about your libstdc++ installation. Clangd is able to find it due to the --query-driver.

Let's try a different approach. Let's take the command that clangd prints in the log:

/opt/homebrew/Cellar/gcc/12.2.0/bin/aarch64-apple-darwin22-g++-12 --target=aarch64-apple-darwin22 --driver-mode=g++ -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -o CMakeFiles/ACM_Env.dir/main.cpp.o -c -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks -resource-dir=/opt/homebrew/Cellar/llvm/16.0.0/lib/clang/16 -- /Users/vm/test_cpp/main.cpp

and replace the compiler with clang++ as well as removing some of the stuff clangd adds that's not suitable for running on the command line to get:

clang++ --target=aarch64-apple-darwin22 -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk -o CMakeFiles/ACM_Env.dir/main.cpp.o -c -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22 -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include -isystem /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks -- /Users/vm/test_cpp/main.cpp

What happens if you run that?

Season0518 commented 1 year ago

Ok, I first executed it in the main.cpp directory, and he prompted an error,

image

and then I navigated to the build directory to find the .o file, and he prompted like this

image
HighCommander4 commented 1 year ago

Ok, so this indicates the issue is not specific to clangd, but rather clang itself doesn't support this type (__float128).

Since clangd uses clang's parser, it's constrained to parsing code that clang can understand. In cases of projects normally compiled with gcc, this generally means making the code portable enough that clang can also compile it.

I'm not sure how to do that in this particular case, but as the question is now no longer clangd-specific (it's "how to get clang to accept this code"), hopefully you can find an answer to that elsewhere.

Season0518 commented 1 year ago

Ok, then I will disable this error in the configuration file of clangd using the “type_unsupported” option, sincerely thank you for your quick reply

Attaching my clangd config so others can solve this problem

Diagnostics:
  Suppress: ["type_unsupported"]