Skip to content

Register only the LLVM targets this build can emit for, and build the bench on Windows - #17

Merged
dreamsailing59-ops merged 1 commit into
ExpansionPak:mainfrom
dougchansan:pr/llvm-target-registration
Aug 22, 2026
Merged

Register only the LLVM targets this build can emit for, and build the bench on Windows#17
dreamsailing59-ops merged 1 commit into
ExpansionPak:mainfrom
dougchansan:pr/llvm-target-registration

Conversation

@dougchansan

Copy link
Copy Markdown
Contributor

What

main does not link against the official LLVM 20 Windows package.

target.cpp calls InitializeAll*, which expands to every target the host LLVM was configured with. That package ships seven (AArch64 ARM X86 BPF WebAssembly RISCV NVPTX) while CMakeLists.txt linked four, so the link fails with 14 unresolved LLVMInitialize* symbols for BPF, WebAssembly and NVPTX.

Why this shape

Naming X86 and AArch64 unconditionally fixes Windows but breaks against an LLVM built without one of them — the call would not even compile. So both the registration and the linked component list are derived from LLVM_TARGETS_TO_BUILD, which LLVMConfig.cmake reports:

if("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
    list(APPEND DOLRECOMP_LLVM_COMPONENTS X86CodeGen X86AsmParser)
    target_compile_definitions(dr_llvm PRIVATE DOLLLVM_HAVE_X86_TARGET=1)
endif()

with matching #if defined(...) guards in target.cpp, and a FATAL_ERROR if neither target is present.

Also

benchmarks/llvm_backend_bench.c used clock_gettime/CLOCK_MONOTONIC, which MSVC does not provide, so the benchmark target never built on Windows. Adds a QueryPerformanceCounter path; the POSIX path is unchanged.

Verification

  • 28/28 ctest on Windows (MSVC 19.50, LLVM 20.1.8 — 7 targets)
  • 28/28 ctest on a Raspberry Pi 4 (GCC 14.2, LLVM 19 — 21 targets)

Those two LLVM builds have very different target sets, which is what exercises the gating in both directions.

… bench on Windows

main does not link against the official LLVM 20 Windows package. target.cpp
calls InitializeAll*, which expands to every target the host LLVM was
configured with; that package ships seven (AArch64 ARM X86 BPF WebAssembly
RISCV NVPTX) while CMakeLists linked four, so the link fails with 14 unresolved
LLVMInitialize* symbols for BPF, WebAssembly and NVPTX.

Register x86-64 and AArch64 explicitly -- they are the only targets the emitter
can produce -- and derive both the registration and the linked components from
LLVM_TARGETS_TO_BUILD, so this also compiles against an LLVM built without one
of them rather than trading a Windows break for a Linux one. Fails the configure
with a clear message if neither target is present.

benchmarks/llvm_backend_bench.c used clock_gettime/CLOCK_MONOTONIC, which MSVC
does not provide, so the benchmark target never built on Windows. Adds a
QueryPerformanceCounter path.

Verified: 28/28 ctest on Windows (MSVC 19.50, LLVM 20.1.8) and on a Raspberry
Pi 4 (GCC 14.2, LLVM 19, 21 targets built), which exercises both sides of the
gating.
@siahisaforker

Copy link
Copy Markdown
Contributor

if i have to review another PR i will explode and die

@dougchansan

Copy link
Copy Markdown
Contributor Author

do a flip!

@dreamsailing59-ops
dreamsailing59-ops merged commit ba5d622 into ExpansionPak:main Aug 22, 2026
6 checks passed
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.

3 participants