{"record":{"id":"69d5bd962d9836a5","repo":"dotnet/runtime","slug":"unknown-target-os","errorCode":null,"errorMessage":"Unknown target OS.","messagePattern":"Unknown target OS\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/jitutil.py","lineNumber":504,"sourceCode":"        If you pass one of target_os, host_arch, or target_arch, you must pass them all.\n\n    Return:\n        (str) : name of the jit for this OS\n    \"\"\"\n\n    jit_base_name = 'clrjit'\n\n    if use_cross_compile_jit or (host_arch != target_arch) or ((target_os is not None) and (host_os != target_os)):\n        if target_arch.startswith(\"arm\"):\n            jit_os_name = \"universal\"\n        elif target_arch.startswith(\"wasm\"):\n            jit_os_name = \"universal\"\n        elif target_os == \"windows\":\n            jit_os_name = \"win\"\n        elif target_os == \"osx\" or target_os == \"linux\":\n            jit_os_name = \"unix\"\n        else:\n            raise RuntimeError(\"Unknown target OS.\")\n\n        jit_base_name = 'clrjit_{}_{}_{}'.format(jit_os_name, target_arch, host_arch)\n\n    if host_os == \"osx\":\n        return \"lib\" + jit_base_name + \".dylib\"\n    elif host_os == \"linux\":\n        return \"lib\" + jit_base_name + \".so\"\n    elif host_os == \"windows\":\n        return jit_base_name + \".dll\"\n    else:\n        raise RuntimeError(\"Unknown host OS.\")\n\n\ndef get_deepest_existing_directory(path):\n    \"\"\" Given a path, find the deepest existing directory containing it. This\n        might be the path itself, or a parent directory. If no such directory\n        is found, None is returned.\n","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/scripts/jitutil.py#L486-L522","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: unsupported target OS\npython superpmi.py asmdiffs -target_os freebsd -target_arch x64\n\n# after: use a supported OS or add support\npython superpmi.py asmdiffs -target_os linux -target_arch x64","handlingStrategy":"validation","validationCode":"# Validate target_os before calling determine_jit_name for cross-compile\nvalid_target_oses = {'windows', 'osx', 'linux', None}\nvalid_universal_archs = ('arm', 'wasm')\nif use_cross_compile_jit:\n    if target_os not in valid_target_oses and not any(target_arch.startswith(a) for a in valid_universal_archs):\n        raise ValueError(f'Unknown target OS: {target_os}. Must be windows, osx, or linux (or use arm/wasm arch).')","typeGuard":"def is_supported_target_os_for_cross_compile(target_os: str, target_arch: str) -> bool:\n    if target_arch.startswith('arm') or target_arch.startswith('wasm'):\n        return True\n    return target_os in {'windows', 'osx', 'linux'}","tryCatchPattern":"try:\n    jit_name = determine_jit_name(host_os, target_os, host_arch, target_arch, use_cross_compile_jit)\nexcept RuntimeError as e:\n    if 'Unknown target OS' in str(e):\n        logging.error('target_os must be windows, osx, or linux for non-arm/wasm cross-compile')\n        sys.exit(1)\n    raise","preventionTips":["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."],"tags":["jitutil","cross-compile","validation","os-detection"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}