Skip to content

build(liquid-dsp): MSVC enablement via clang-cl sub-build (closes #3049)#3073

Closed
ten9876 wants to merge 2 commits into
mainfrom
auto/liquid-dsp-clang-cl-msvc
Closed

build(liquid-dsp): MSVC enablement via clang-cl sub-build (closes #3049)#3073
ten9876 wants to merge 2 commits into
mainfrom
auto/liquid-dsp-clang-cl-msvc

Conversation

@ten9876

@ten9876 ten9876 commented May 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Enables liquid-dsp on Windows MSVC by routing the liquid-dsp sub-build through clang-cl (LLVM's MSVC-ABI-compatible frontend, bundled with VS 2022's "C++ Clang Compiler for Windows" component). clang-cl supports C99 `_Complex` natively while producing MSVC-compatible `.lib` output, so the resulting `liquid.lib` links cleanly into the main AetherSDR/MSVC binary.

Closes #3049.

Why

#3046 vendored liquid-dsp Linux+macOS-only because cl.exe rejects C99 `_Complex` arithmetic used throughout liquid-dsp's source. Patching every internal `+` / `*` operator on complex values to MSVC's `_FCmulcc` / `_FCadd` intrinsics would be hundreds of edits diverged from upstream — high cost, high maintenance. Routing the sub-build through clang-cl is zero-edit-to-liquid-dsp and ABI-compatible with our MSVC AetherSDR build.

How

  • `if(MSVC)` branch: `find_program(CLANG_CL_EXE)` then `ExternalProject_Add` with `CMAKE_C_COMPILER=clang-cl.exe`, building static `liquid.lib` into `build/liquid-dsp-install/`. Wired to an `IMPORTED` target with the install include dir for downstream consumers.
  • Non-MSVC branch: unchanged `add_subdirectory` flow.
  • Link line: `if(TARGET liquid-static) target_link_libraries(...) endif()` replaces the `$<$NOT:...>` generator expression. A Windows build without clang-cl on PATH cleanly omits liquid-static rather than failing the link.

Verified locally

  • Linux x86_64 in-tree build: clean, links liquid-static, summary shows liquid-dsp configured.
  • Windows clang-cl path: needs CI to validate (no Windows host locally).

If clang-cl is missing

The configure logs `liquid-dsp: clang-cl not found on PATH; skipping` and continues. Only consumer-visible effect: `liquid-static` target is absent (matches today's MSVC behavior).

Test plan

  • CI green: build + check-paths + check-windows
  • Windows job actually runs the ExternalProject_Add sub-build (visible in build log)
  • No regression on Linux build time / artifact size

73, Jeremy KK7GWY & Claude (AI dev partner)

🤖 Generated with Claude Code

…uild (closes #3049)

#3046 skipped liquid-dsp on Windows MSVC because cl.exe rejects C99
`_Complex` arithmetic that liquid-dsp's source code uses throughout
(`liquid.h:473` error C2061 was just the first surface; the .c sources
also use complex `+` / `*` operators that MSVC's C compiler doesn't
support).  This unblocks the Windows build path so future digital-mode
consumers can use liquid-dsp on all three platforms.

Approach: a separate ExternalProject_Add sub-build invokes CMake with
`-DCMAKE_C_COMPILER=clang-cl.exe`.  clang-cl is LLVM's MSVC-ABI-
compatible frontend (ships with VS 2022's "C++ Clang Compiler for
Windows" component) and supports `_Complex` natively while producing
MSVC-compatible `.lib` output.  The resulting `liquid.lib` links into
the main AetherSDR/MSVC binary without ABI drama.

Linux + macOS path unchanged — still `add_subdirectory` in-tree.
Link line now uses `if(TARGET liquid-static)` instead of
`$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:liquid-static>` so a Windows build
without clang-cl (rare; only an unusually slim VS install) cleanly
omits liquid-static rather than failing the link.

Verified:
- Linux x86_64 in-tree build still clean (this commit)
- Windows clang-cl path needs CI to confirm (cannot test locally)

If `clang-cl.exe` isn't on PATH the configure logs an informational
"liquid-dsp: clang-cl not found" message and continues; the only
consumer-visible effect is that `liquid-static` is absent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ten9876 ten9876 requested a review from a team as a code owner May 24, 2026 21:40
Windows CI on the previous commit failed at the ExternalProject configure
step:

  CMake Error at C:/Program Files/CMake/share/cmake-3.31/Modules/Platform/
  Windows-Clang.cmake:168 (message):
    supported.  Use either clang/clang++ or clang-cl as all C, C++, CUDA,
    ...

liquid-dsp's project() declares `LANGUAGES C CXX`, and CMake's
Windows-Clang platform module refuses to mix clang-cl for C with MSVC
cl.exe for C++ — both must use a clang variant.  Setting only
CMAKE_C_COMPILER leaves the inner project's C++ language detection on
default cl.exe, which trips the consistency check.

Fix: also pass `-DCMAKE_CXX_COMPILER=${CLANG_CL_EXE}`.  The C++ compiler
isn't actually invoked (BUILD_EXAMPLES / AUTOTESTS / BENCHMARKS / SANDBOX
all disabled, and liquid-dsp's library sources are pure C) but the
declared language is enough to trigger CMake's platform-module check.

Linux build still clean (this commit).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ten9876

ten9876 commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

Closing — clang-cl was the wrong approach. The fundamental issue runs deeper than I originally claimed in the RFC discussion: clang-cl supports the C99 _Complex keyword natively, but it inherits MSVC's <complex.h> from UCRT, which does not define the C99 complex macro and uses opaque _Fcomplex/_Dcomplex types with different function signatures. liquid-dsp's 153 internal .c files call crealf/cimagf/cabsf/cargf against the C99 declarations — even hacking the type system with -Dcomplex=_Complex would still fail at link time because the function symbols don't exist in UCRT in their C99 form.

The right answer is mingw-w64-gcc in an ExternalProject — full C99 <complex.h>, defaults to UCRT on Win10+ (matches our MSVC build), static-link the resulting .a into the MSVC AetherSDR binary (link.exe accepts .a directly).

Filed updated plan in #3049 with the full lessons learned. Picking it back up there when we prioritize the Windows liquid-dsp enablement.

73, Jeremy KK7GWY & Claude (AI dev partner)

@ten9876 ten9876 closed this May 24, 2026
@ten9876 ten9876 deleted the auto/liquid-dsp-clang-cl-msvc branch May 24, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

liquid-dsp Windows/MSVC support — mingw-w64 ExternalProject (Path B locked in)

1 participant