Skip to content

[CPU][Windows] Fix JIT shared library compilation and exports - #3281

Open
sepcnt wants to merge 1 commit into
tile-ai:mainfrom
sepcnt:fix-windows-cpu-jit-libgen
Open

sepcnt wants to merge 1 commit into
tile-ai:mainfrom
sepcnt:fix-windows-cpu-jit-libgen

Conversation

@sepcnt

@sepcnt sepcnt commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Use MSVC-compatible shared-library, C++17, and exception-handling flags for CPU JIT with cl.exe and clang-cl; keep GNU-style driver support.
  • Emit .dll files on Windows, use the host compiler environment, and export the CPU wrapper's call entrypoint.
  • Report a missing CPU compiler explicitly and keep object files beside their temporary source.

Validation

  • Rebuilt native libraries from a clean build on Windows.
  • With kernel caching disabled: python -m pytest testing/python/cpu testing/python/target/test_tilelang_codegen_clamp.py -q — 97 passed, 4 skipped.
  • With TILELANG_DISABLE_CLANG_CL=1 and kernel caching disabled: python -m pytest testing/python/target/test_tilelang_codegen_clamp.py -k cpu -q — 5 passed, 8 deselected.
  • Targeted format.sh checks and git diff --check passed.

Summary

  • Use MSVC-compatible flags for Windows CPU JIT builds with cl.exe or clang-cl, and retain GNU-style flags for other CPU compilers.
  • Emit .dll files on Windows. Place compiler object files beside the temporary source file.
  • Use the MSVC subprocess environment for Windows CPU builds and report an explicit error when no CPU C++ compiler is available.
  • Export the CPU wrapper’s call function with TL_EXPORT.

C++ style / lint notes

The change updates generated C++ wrapper code but does not edit docs/developer_guide/cpp_style.md or CI lint tooling. No review findings or test results were supplied. The relevance or outcome of the “C++ API Style Audit (warning only)” step is not established.

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run pre-commit run --all-files in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: tile-ai/tilelang/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 582b6ff5-404a-4984-b968-86c41cc6bbb3

📥 Commits

Reviewing files that changed from the base of the PR and between 356f309 and 99917aa.

📒 Files selected for processing (2)
  • tilelang/jit/adapter/libgen.py
  • tilelang/jit/adapter/wrapper.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

CPU JIT generation marks the generated call function for export. CPU library compilation checks for a C++ compiler and uses platform-specific output names, compiler flags, and subprocess environments.

Changes

CPU JIT compilation

Layer / File(s) Summary
CPU wrapper and library build
tilelang/jit/adapter/wrapper.py, tilelang/jit/adapter/libgen.py
The generated CPU call function now uses TL_EXPORT. CPU compilation raises a RuntimeError when no C++ compiler is available. Windows cl and clang-cl use MSVC-style flags, a .dll output, and an object file beside the temporary source. Windows CPU builds use the MSVC subprocess environment; other CPU compilers retain the Unix-style shared-library command.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: leiwang1999

Merge Risk: ⚪ Minimal · up to 99917

No issue requiring a fix before merge was established; the Windows compiler lookup supports the developer-environment setup.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 99917

The changes enable Windows CPU JIT libraries to build and expose their existing call function. No new unauthorized caller or privilege gain was established. The ROCm compiler selection change merits attention where SDK paths can be influenced by less-trusted users.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The reachable native-code and compiler-execution scope is the process performing JIT compilation and loading. The evidence establishes neither a network entrypoint nor tenant-separated execution for these paths.

Trust Boundaries and Controls

  • inferred — Exporting CPU call makes the symbol visible to the existing dynamic-library caller, but does not itself establish a new authorization boundary. The examined wrapper derives its argument types from the lowered function; it does not show independent native-call authorization or bounds checks.

Resilience and Maintainability Implications

  • inferred — The Windows CPU environment change does not establish a new environment trust boundary: the previous Windows compilation helper also reached the MSVC environment provider. Compiler executables and generated libraries still run with the JIT process’s authority.

Hardening Proposals

  • proposed — If a privileged or shared JIT process accepts ROCM_PATH from less-trusted users, constrain compiler selection to trusted toolchain locations. A HIP-header existence check establishes installation completeness, not executable provenance.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main changes: fixing CPU JIT shared-library compilation and exports on Windows.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant