Fix GNU LD regex matching CMake status lines as diagnostics (#4910)#4926
Fix GNU LD regex matching CMake status lines as diagnostics (#4910)#4926Omotola wants to merge 4 commits into
Conversation
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>
|
hi! nice fix for the Zephyr case. one concern before merge: the new prefix These previously matched via suggested tweak: allow (?:[^\s:]*[/\\\-])?ld(?:\.exe)?this still rejects the Zephyr also worth adding a positive test next to the new ones in |
Fix GNU LD diagnostic regex matching CMake status lines (#4910)
Problem
The GNU linker diagnostic parser incorrectly matches informational CMake build output as linker diagnostics. For
example, Zephyr build status lines like:
-- Zephyr version: 4.3.0 (/path/to/zephyr), build: v4.3.0
appear in the VS Code Problems panel as errors with source: cmake GNULD, because the regex .*ld in the pattern
matches the ld suffix in build.
Root Cause
Five regex patterns in src/diagnostics/gnu-ld.ts use .*ld to match the linker binary path. This is too broad — it
matches any word ending in ld (e.g., build, child, ould), not just actual linker paths like /usr/bin/ld or
C:\mingw\bin\ld.exe.
Fix
Changed .ld → (?:.[/\])?ld in all five patterns. This requires ld to either:
This ensures only real linker binary paths are matched while rejecting arbitrary words that happen to end in ld.
Testing
Added two new unit tests that reproduce the false positive from #4910:
4.3.0 (/path/to/zephyr), build: v4.3.0
1.0 (/path/to/tool), build: v1.0
Both tests fail before the fix and pass after. All existing GNU LD diagnostic tests continue to pass.
Changes
Fixes #4910