Menu

#1593 clangd_client: support versioned executable auto detection

Next_Nightly
applied
pecan
Patch
2026-03-25
2026-03-15
Christo
No

Installing clangd from https://apt.llvm.org/ results in verisioned libraries, for eg. /usr/bin/clangd-20 in my recent installation. Attached patch helps to autodetect this.

1 Attachments

Discussion

  • pecan

    pecan - 2026-03-19
    • assigned_to: pecan
     
  • pecan

    pecan - 2026-03-25

    Prompt to Gemini AI:

    For CodeBlocks, what does a contributor mean by ticket 1593 when he states:

    Installing clangd from https://apt.llvm.org/ results in verisioned libraries, for eg. /usr/bin/clangd-20 in my recent installation. Attached patch helps to autodetect this.

    With patch code: ticket 1593

    Gemini said

    In Code::Blocks ticket 1593, the contributor is addressing a common issue where the IDE fails to find the clangd executable (the Language Server Protocol provider) because the filename isn't just clangd, but includes a version number.
    The Problem

    When you install LLVM/Clang tools on Linux (especially via the LLVM apt repositories) or Windows, the installer often names the binary with its major version to allow multiple versions to coexist. Instead of a generic /usr/bin/clangd, you get:

    /usr/bin/clangd-19
    /usr/bin/clangd-20
    C:\Program Files\LLVM\bin\clangd-20.exe
    

    Before this patch, Code::Blocks was hardcoded to look only for exactly clangd or clangd.exe. If that specific file didn't exist, the Clangd Client plugin would fail to initialize, even if a valid versioned copy was present on the system.
    How the Patch Fixes It

    The contributor added a "wildcard" search fallback. Here is the logic broken down:

    Variable Definition:
    The patch introduces clangdexe_versioned, which uses a wildcard *:
    
        Linux: clangd-*
        Windows: clangd-*.exe
    
    The Search Logic:
    The code first tries the standard search for the base name. If fnClangdPath remains empty (meaning it was not found), it executes the new block:
    C++
    
    wxString spec = LLVM_Dirmaybe + wxFILE_SEP_PATH + clangdexe_versioned;
    fnClangdPath = wxFindFirstFile(spec);
    
    This tells the system: "Go to the default LLVM directory and find the first file that starts with 'clangd-' and ends with the appropriate extension."
    
    The Result:
    If the user has clangd-20 installed but not a generic clangd symlink, Code::Blocks will now successfully "autodetect" the versioned binary and use it for code completion, refactoring, and symbol navigation.
    

    Summary of Intent

    The contributor is making the Clangd Client plugin more robust and user-friendly. Instead of forcing users to manually create symlinks or browse their file system to point the IDE to the right file, the IDE now "guesses" correctly by looking for versioned patterns.

    References:

    Code::Blocks Ticket #1593: "autodetect versioned clangd"
    LLVM Debian/Ubuntu nightly packages (apt.llvm.org) naming conventions.
    wxWidgets wxFindFirstFile documentation for pattern matching.
    
     
    👍
    1

    Last edit: pecan 2026-03-25
  • pecan

    pecan - 2026-03-25

    Thanks
    Applied SVN rev 13830

     
  • pecan

    pecan - 2026-03-25
    • status: open --> applied
    • Milestone: Undefined --> Next_Nightly
     

Log in to post a comment.

MongoDB Logo MongoDB