From 80d7620df27e44b743ce672bd191cb30ed9cf896 Mon Sep 17 00:00:00 2001 From: Omotola Akeredolu Date: Mon, 4 May 2026 18:31:15 -0700 Subject: [PATCH] Fix GNU LD regex matching CMake status lines as diagnostics (#4910) Tighten GNU LD diagnostic regex patterns to require a path separator before 'ld' so words like 'build' no longer falsely match as linker binary paths. This prevents Zephyr and other CMake status lines from appearing as spurious problems in the Problems panel. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 1 + src/diagnostics/gnu-ld.ts | 10 +++++----- test/unit-tests/diagnostics.test.ts | 12 ++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4caec86e3..e1bec2a4fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Bug Fixes: - Fix Windows backslash handling in token splitting to preserve trailing backslashes before whitespace. This caused "Compile Active File" with MSVC + Ninja Multi-Config to merge adjacent flags (e.g., `/Fd\ /FS`) into a single malformed argument. [#4902](https://github.com/microsoft/vscode-cmake-tools/issues/4902) - Fix kit detection returning "unknown vendor" when using clang-cl compiler. [#4638](https://github.com/microsoft/vscode-cmake-tools/issues/4638) - Update testing framework to fix bugs when running tests of CMake Tools without a reliable internet connection. [#4891](https://github.com/microsoft/vscode-cmake-tools/pull/4891) [@cwalther](https://github.com/cwalther) +- Fix GNU LD diagnostic regex incorrectly matching CMake status lines (e.g., Zephyr build output) as linker errors in the Problems panel. [#4910](https://github.com/microsoft/vscode-cmake-tools/issues/4910) ## 1.23.52 diff --git a/src/diagnostics/gnu-ld.ts b/src/diagnostics/gnu-ld.ts index 3cc896aa13..8f6068a993 100644 --- a/src/diagnostics/gnu-ld.ts +++ b/src/diagnostics/gnu-ld.ts @@ -9,23 +9,23 @@ import { oneLess, RawDiagnostic, RawDiagnosticParser, RawRelated, FeedLineResult // Patterns to identify and capture GNU linker diagnostic messages const regexPatterns: RegexPattern[] = [ { // path/to/ld[.exe]:[ ]path/to/file:line: severity: message - regexPattern: /^(?:.*ld(?:\.exe)?:)(?:\s*)?(.+):(\d+):\s+(?:fatal )?(\w+):\s+(.+)/, + regexPattern: /^(?:(?:.*[/\\])?ld(?:\.exe)?:)(?:\s*)?(.+):(\d+):\s+(?:fatal )?(\w+):\s+(.+)/, matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Severity, MatchType.Message] }, { // path/to/ld[.exe]:[ ]path/to/file.obj:path/to/file:line: message - regexPattern: /^(?:.*ld(?:\.exe)?\:)(?:\s*)(?:.+?\.obj:)(.+?):(\d+):\s+(.+)/, + regexPattern: /^(?:(?:.*[/\\])?ld(?:\.exe)?\:)(?:\s*)(?:.+?\.obj:)(.+?):(\d+):\s+(.+)/, matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message] }, { // path/to/ld[.exe]:[ ]path/to/file:line: message - regexPattern: /^(?:.*ld(?:\.exe)?\:)(?:\s*)?(.+):(\d+):\s+(.+)/, + regexPattern: /^(?:(?:.*[/\\])?ld(?:\.exe)?\:)(?:\s*)?(.+):(\d+):\s+(.+)/, matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message] }, { // path/to/ld[.exe]: severity: message - regexPattern: /^(.*ld(?:\.exe)?):\s+(?:fatal )?(\w+):\s+(.+)/, + regexPattern: /^((?:.*[/\\])?ld(?:\.exe)?):\s+(?:fatal )?(\w+):\s+(.+)/, matchTypes: [MatchType.Full, MatchType.File, MatchType.Severity, MatchType.Message] }, { // path/to/ld[.exe]: message (without trailing colon) - regexPattern: /^(.*ld(?:\.exe)?):\s+(.+)(? { expect(build_consumer.compilers.gnuld.diagnostics).to.have.length(0); expect(build_consumer.compilers.gnuld.diagnostics).to.have.length(0); }); + test('No linker error on Zephyr build status line "-- Zephyr version: ..." (issue #4910)', () => { + const lines = ['-- Zephyr version: 4.3.0 (/path/to/zephyr), build: v4.3.0']; + feedLines(build_consumer, [], lines); + expect(build_consumer.compilers.gnuld.diagnostics).to.have.length(0); + expect(build_consumer.compilers.gcc.diagnostics).to.have.length(0); + }); + test('No linker error on generic CMake status lines containing "build:" (issue #4910)', () => { + const lines = ['-- Some tool version: 1.0 (/path/to/tool), build: v1.0']; + feedLines(build_consumer, [], lines); + expect(build_consumer.compilers.gnuld.diagnostics).to.have.length(0); + expect(build_consumer.compilers.gcc.diagnostics).to.have.length(0); + }); test('Parsing GHS Diagnostics', () => { const lines = [ '"C:\\path\\source\\debug\\debug.c", line 631 (col. 3): warning #68-D: integer conversion resulted in a change of sign'