dotnet/runtime · error · RuntimeError
Unknown target OS.
Error message
Unknown target OS.
What it means
Thrown by determine_jit_name() in jitutil.py when computing the cross-compilation JIT file name and the target_os is not 'windows', 'osx', or 'linux', and the target_arch does not start with 'arm' or 'wasm'. The function needs to map the target OS to a short name prefix (win, unix, universal) for the cross-compile JIT filename, and an unrecognized OS has no valid prefix.
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 290d5ab72c)
Solutions
- Check the -target_os argument and ensure it is 'windows', 'osx', or 'linux'.
- If cross-compiling for arm or wasm architectures, ensure target_arch starts with 'arm' or 'wasm' so the 'universal' prefix is used.
- If adding support for a new target OS, add an elif branch in determine_jit_name() to map it to an appropriate jit_os_name prefix.
Example fix
# before: unsupported target OS python superpmi.py asmdiffs -target_os freebsd -target_arch x64 # after: use a supported OS or add support python superpmi.py asmdiffs -target_os linux -target_arch x64
Defensive patterns
Strategy: validation
Validate before calling
# Validate target_os before calling determine_jit_name for cross-compile
valid_target_oses = {'windows', 'osx', 'linux', None}
valid_universal_archs = ('arm', 'wasm')
if use_cross_compile_jit:
if target_os not in valid_target_oses and not any(target_arch.startswith(a) for a in valid_universal_archs):
raise ValueError(f'Unknown target OS: {target_os}. Must be windows, osx, or linux (or use arm/wasm arch).') Type guard
def is_supported_target_os_for_cross_compile(target_os: str, target_arch: str) -> bool:
if target_arch.startswith('arm') or target_arch.startswith('wasm'):
return True
return target_os in {'windows', 'osx', 'linux'} Try / catch
try:
jit_name = determine_jit_name(host_os, target_os, host_arch, target_arch, use_cross_compile_jit)
except RuntimeError as e:
if 'Unknown target OS' in str(e):
logging.error('target_os must be windows, osx, or linux for non-arm/wasm cross-compile')
sys.exit(1)
raise Prevention
- Use -target_os values of 'windows', 'osx', or 'linux' for cross-compilation.
- For arm/arm64/wasm targets, the 'universal' prefix is used automatically regardless of target_os.
- Verify that target_arch and target_os are valid combinations before calling determine_jit_name.
When it happens
Trigger: Called when use_cross_compile_jit is True, or host_arch != target_arch, or target_os differs from host_os (line 494). The if/elif chain at lines 495-504 checks target_arch.startswith('arm'), target_arch.startswith('wasm'), target_os == 'windows', target_os in ('osx','linux'); if none match, line 504 raises.
Common situations: A new target OS was added to the build system (e.g., freebsd, solaris) but determine_jit_name was not updated. The -target_os argument is misspelled or empty. Cross-compiling for an architecture/OS combination that the JIT naming convention doesn't support.
Related errors
- Unknown host OS.
- Unknown OS.
- Unsupported OS.
- event.eventName is a required parameter, in event: ${JSON.st
- "arguments" should be an array, but was ${request.arguments}
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/69d5bd962d9836a5.
Report an issue: GitHub.