liblouis build: clang-cl target selection relies on PATH order, breaks on arm64 when multiple arch-specific clang-cl binaries are reachable
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- build-system
Research direction
Start with nvdaHelper/liblouis/sconscript and trace how TARGET_ARCH sets compiler flags and how SCons selects clang-cl. Check the build behavior for x86, x86_64, arm64, and arm64ec against the target triples described in the issue. Done means each architecture builds objects for its intended target regardless of PATH order; the issue author reports having a tested fix.
Written by the indexing model from the issue text.
Description
Title
liblouis build: clang-cl target selection relies on PATH order, breaks on arm64 when multiple arch-specific clang-cl binaries are reachable
Related issues, PRs or discussions
Related to #20316 (Fix Clang detection for Visual Studio 2026), which replaced a hardcoded Tools\Llvm\bin glob with env.WhereIs("clang-cl"). That fix is correct for the single-arch-toolchain case it targeted, but doesn't address target selection when more than one arch-specific clang-cl.exe is reachable via PATH, which is the root cause here.
What is the current state of the codebase?
nvdaHelper/liblouis/sconscript sets:
if env["TARGET_ARCH"] in ("x86_64", "arm64"):
# We need to build as 64-bit
env.Append(CCFLAGS="-m64")
-m64/-m32 are real clang-cl flags that select between the x86 and x86_64 targets specifically — they have no arm64 meaning. On a machine with Visual Studio's "C++ Clang Tools for Windows" component installed, there are multiple clang-cl.exe binaries under VC\Tools\Llvm\ (a generic one plus arch-specific ones, e.g. Llvm\bin\clang-cl.exe, Llvm\x64\bin\clang-cl.exe, Llvm\ARM64\bin\clang-cl.exe depending on VS version/layout), each defaulting to a different target triple when given no explicit target (confirmed: the generic Llvm\bin\clang-cl.exe on this machine defaults to i686-pc-windows-msvc, i.e. x86, regardless of which TARGET_ARCH SCons is building).
env.WhereIs("clang-cl") (introduced in #20316) resolves whichever clang-cl.exe happens to be first on the constructed PATH for that environment — this is not guaranteed to match TARGET_ARCH. With the -m64 flag applied only for x86_64/arm64, and removed/absent for arm64 as a one-line fix attempt, clang-cl silently falls back to its binary's own default target (x86 in the case above) instead of arm64, producing object files of the wrong architecture with no build-time error — the failure only surfaces much later as a confusing wall of unresolved CRT symbols at link time (malloc, memcpy, __security_cookie, etc. all unresolved, because the objects are the wrong machine type for libcmt.lib).
Why are changes required?
Building liblouis for arm64/arm64ec from source currently produces silently-wrong-architecture object files (or fails to link with misleading CRT-symbol errors) when the build environment's PATH exposes more than one arch-specific clang-cl.exe, which is the case on at least one real Visual Studio + "C++ Clang Tools for Windows" installation. This blocks building nvdaHelper's liblouis component for ARM64 from source.
What technical changes are required?
Pass an explicit --target= triple to clang-cl per TARGET_ARCH, instead of relying on -m64/-m32 (which don't cover arm64) or on whichever clang-cl.exe happens to resolve first:
clangTarget = {
"x86": "i686-pc-windows-msvc",
"x86_64": "x86_64-pc-windows-msvc",
"arm64": "aarch64-pc-windows-msvc",
}[env["TARGET_ARCH"]]
env.Append(CCFLAGS=f"--target={clangTarget}")
This removes the dependency on -m64/-m32 entirely and makes target selection explicit and correct regardless of which clang-cl.exe binary ends up on PATH.
Are the proposed technical changes API breaking?
No.
Are there potential risks or issues with the proposed implementation?
Low risk. --target= is a standard, well-supported clang-cl flag; this is strictly more robust than the current -m64-only approach, including for the existing x86/x64 builds (it removes an implicit dependency on PATH ordering there too, even though it happens not to manifest as a bug today on typical single-arch-clang-cl setups).
I have a working fix and can open a PR once this issue is triaged, as part of getting a native ARM64 Python build of NVDA building from source end to end.
Investigated and drafted with AI assistance (Claude); I reviewed the technical content and built/tested the fix myself before filing this.
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 842
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 56
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nvaccess/nvda
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
needs-technical-investigation p5 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
nvaccess/nvda#21085 · 7 comments ·
Maintainers usually reply within 1 day
-
Braille Viewer draws two braille patterns wrongly (U+28CC, U+2873) because of glyph errors in FreeMono-FixedBraille.ttfMay be free again A pull request for this issue was closed without being merged. Openaudience/a11y-tester good first issue p4 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nvaccess/nvda#21022 · 3 comments ·
Maintainers usually reply within 1 day
-
api-breaking-change audience/nvda-dev p5 release/blocking release/blocking-beta triaged
Difficulty 2/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
p5 triaged
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pimutils/vdirsyncer#1242 ·
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
QuantConnect/lean-cli#792 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-webui/open-webui#35360 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100