Skip to content

Windows clang-cl build (opt-in) with shared/static presets - #469

Closed
cjcliffe wants to merge 1 commit into
jgaeddert:masterfrom
cjcliffe:windows-clangcl
Closed

cjcliffe wants to merge 1 commit into
jgaeddert:masterfrom
cjcliffe:windows-clangcl

Conversation

@cjcliffe

@cjcliffe cjcliffe commented Nov 3, 2026

Copy link
Copy Markdown

Adds an opt-in Windows build using the Visual Studio Clang toolset, behind a new ENABLE_CLANG_CL option (default OFF) plus windows-clangcl-* CMake presets for x64/Win32 × shared/static. Default configures behave exactly as before — verified MinGW/GCC-isms untouched, and a default VS/cl configure passes with detection uncapped.

Library sources (all _WIN32/_MSC_VER-guarded, matching surrounding idiom):

  • timer.c: QPC wall clock + GetProcessTimes CPU time in place of gettimeofday/getrusage
  • runtime.c: __cpuidex/_xgetbv in place of inline asm
  • msb_index.c: _BitScanReverse in place of inline asm
  • logging.c: local strsep plus unistd.h guard
  • libliquid.c: unistd.h guard

Build system:

  • cmake/clangcl/complex.h shim: UCRT <complex.h> predates C99 _Complex, so clang-cl builds stand this in via -I (scalar decompose for real/imag/conj/abs/arg, forward to UCRT struct routines for transcendentals)
  • Shared target gets WINDOWS_EXPORT_ALL_SYMBOLS (no export macros in-tree) and links the clang builtins archive, located relative to the compiler so VS-bundled and standalone LLVM both work
  • c m link guarded off Windows; autotest log dir creation via cmake -E (portable, identical elsewhere)
  • README: new ENABLE_CLANG_CL row plus a Windows section (VS 2022+, preset commands)

Known limits (deliberate):

  • SIMD capped at SSE4.2 on this path: clang only declares AVX types with -mavx on the command line, but the AVX sources share translation units with the portable/runtime-dispatch code that must stay baseline-safe. Lifting it needs the .avx.c files split into separate TUs first.
  • Presets leave examples/benchmarks/autotest off — all hard-require getopt.h (plus unistd.h for autotest). A getopt port is separate follow-up work.

@cjcliffe

cjcliffe commented Nov 3, 2026

Copy link
Copy Markdown
Author

Whoops, was meant to open that on my own fork; not fully tested yet.

@cjcliffe cjcliffe closed this Nov 3, 2026
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.

1 participant