dotnet/runtime · error · RuntimeError
Unknown target OS.
Error message
Unknown target OS.
What it means
Raised by determine_jit_name() in jitutil.py in the cross-compilation JIT branch. When use_cross_compile_jit is set or host/target arch differ or target OS differs from host, the function builds a cross-JIT name; if target_os is not 'windows', 'osx', or 'linux' (and target_arch is not arm*/wasm*) it raises 'Unknown target OS.'
Solutions
- Pass target_os as one of: windows, osx, linux (lowercase).
- Omit -target_os if you do not need cross-OS compilation.
- Verify target_arch/host_arch are consistent and that you actually need the cross-compile path.
Example fix
// before jit_name = determine_jit_name(host_os='linux', target_os='unix', host_arch='x64', target_arch='arm64') # 'Unknown target OS.' // after jit_name = determine_jit_name(host_os='linux', target_os='linux', host_arch='x64', target_arch='arm64')
Defensive patterns
Strategy: validation
Validate before calling
VALID_TARGET_OS = {"windows", "osx", "linux"}
if use_cross_compile_jit or (host_arch != target_arch) or (target_os is not None and host_os != target_os):
if not (target_arch.startswith("arm") or target_arch.startswith("wasm")) and target_os not in VALID_TARGET_OS:
raise SystemExit(f"target_os must be one of {sorted(VALID_TARGET_OS)} for cross-compile, got {target_os!r}") Type guard
def is_supported_target_os(s: str) -> bool:
return s in {"windows", "osx", "linux"} Prevention
- Only pass target_os when you actually need cross-OS compilation.
- Keep target_os lowercase and within the supported set.
When it happens
Trigger: Calling determine_jit_name with a target_os outside {windows, osx, linux} while requesting a cross-compile JIT (e.g. target_arch differs from host_arch, or target_os passed and differs from host_os).
Common situations: Passing a target_os typo or an unsupported platform string; calling superpmi collect/replay with -target_os set incorrectly; mixing capitalized forms.
Related errors
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/69d5bd962d9836a5.
Report an issue: GitHub.
Appendix: source
Thrown at src/coreclr/scripts/jitutil.py:504
If you pass one of target_os, host_arch, or target_arch, you must pass them all.
Return:
(str) : name of the jit for this OS
"""
jit_base_name = 'clrjit'
if use_cross_compile_jit or (host_arch != target_arch) or ((target_os is not None) and (host_os != target_os)):
if target_arch.startswith("arm"):
jit_os_name = "universal"
elif target_arch.startswith("wasm"):
jit_os_name = "universal"
elif target_os == "windows":
jit_os_name = "win"
elif target_os == "osx" or target_os == "linux":
jit_os_name = "unix"
else:
raise RuntimeError("Unknown target OS.")
jit_base_name = 'clrjit_{}_{}_{}'.format(jit_os_name, target_arch, host_arch)
if host_os == "osx":
return "lib" + jit_base_name + ".dylib"
elif host_os == "linux":
return "lib" + jit_base_name + ".so"
elif host_os == "windows":
return jit_base_name + ".dll"
else:
raise RuntimeError("Unknown host OS.")
def get_deepest_existing_directory(path):
""" Given a path, find the deepest existing directory containing it. This
might be the path itself, or a parent directory. If no such directory
is found, None is returned.
View on GitHub (pinned to 60108ba66e)