Skip to content

Fix jemalloc builds for Windows MSVC targets - #173

Open
han1548772930 wants to merge 2 commits into
tikv:mainfrom
han1548772930:fix/windows-msvc-target-triple
Open

Fix jemalloc builds for Windows MSVC targets#173
han1548772930 wants to merge 2 commits into
tikv:mainfrom
han1548772930:fix/windows-msvc-target-triple

Conversation

@han1548772930

@han1548772930 han1548772930 commented Jul 23, 2026

Copy link
Copy Markdown
## Summary

This PR fixes building `tikv-jemalloc-sys` for Windows MSVC targets.

## Changes

- Maps Windows MSVC targets to Autoconf-compatible target triples.
- Links the correct `jemalloc_s.lib` library on Windows.
- Preserves the build directory until the final Rust linking step.
- Adds the correct native library search path.

## Building on Windows

Requirements:

- Rust MSVC toolchain
- Visual Studio with the **Desktop development with C++** workload
- MSYS2 with `mingw32-make`

Open the Visual Studio x64 developer command prompt, then add the MSYS2
`ucrt64/bin` and `usr/bin` directories to `PATH`.

Verify the required tools:

```bat
where cl.exe
where lib.exe
where link.exe
where sh.exe
where mingw32-make.exe

Then build:

cargo build

For jemalloc profiling:

tikv-jemallocator = { version = "0.7.0", features = ["profiling"] }

Tested with the x86_64-pc-windows-msvc Rust target.


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved Windows builds by correctly preserving build output and linking the appropriate library.
  * Updated Windows target handling to improve compatibility with supported toolchains.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@ti-chi-bot

ti-chi-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

Welcome @han1548772930! It looks like this is your first PR to tikv/jemallocator 🎉

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The build script now uses Windows-specific target mappings, preserves Windows build output directories, and emits platform-specific linker names and search paths.

Changes

Windows jemalloc build handling

Layer / File(s) Summary
Windows GNU target mapping
jemalloc-sys/build.rs
MSVC Windows targets now map to mingw32 variants instead of win32.
Platform-specific artifact linking
jemalloc-sys/build.rs
Windows retains the build directory and links jemalloc_s from its lib directory; non-Windows builds remove it and link jemalloc_pic from OUT_DIR/lib.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 matches the main change: fixing jemalloc builds for Windows MSVC targets.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ti-chi-bot

ti-chi-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

  • 4a0b928 fix Windows MSVC jemalloc target triple
  • 40226a3 fix MSVC static jemalloc library linkage
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@han1548772930 han1548772930 changed the title Fix/windows msvc target triple Fix jemalloc builds for Windows MSVC targets Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant