[flang-commits] [flang] [flang] Fix the memcpy function type model for MinGW-w64 (PR #233251)
via flang-commits
flang-commits at lists.llvm.org
Sun Oct 18 09:00:34 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Daisuke Nishimatsu (wep21)
<details>
<summary>Changes</summary>
`RTBuilder.h` needs a `getModel` specialization for the runtime's `MemcpyFct` type, `void *(*)(void *, const void *, std::size_t)`, that matches `std::size_t`. On 64-bit Windows `std::size_t` is `unsigned long long`, but that specialization was guarded by `_MSC_VER`, so building flang for MinGW-w64 (windows-gnu) failed to link:
```
ld.lld: error: undefined symbol: mlir::Type (*fir::runtime::getModel<void* (*)(void*, void const*, unsigned long long)>())(mlir::MLIRContext*)
```
Guard it by `_WIN32`, which MSVC, clang-cl and MinGW-w64 all define, and spell the type `unsigned long long`, the same type as `unsigned __int64` under MSVC. MSVC and non-Windows builds are unchanged.
Tested by cross-compiling flang for `x86_64-w64-windows-gnu` from LLVM 23.1.2, which fails to link without this change and links with it.
Assisted-by: Claude Code
---
Full diff: https://github.com/llvm/llvm-project/pull/233251.diff
1 Files Affected:
- (modified) flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h (+2-2)
``````````diff
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index 67bdf6867251a5..180e5fe8ae5784 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -266,10 +266,10 @@ getModel<void *(*)(void *, const void *, unsigned long)>() {
return fir::LLVMPointerType::get(context, funcTy);
};
}
-#ifdef _MSC_VER
+#ifdef _WIN32
template <>
constexpr TypeBuilderFunc
-getModel<void *(*)(void *, const void *, unsigned __int64)>() {
+getModel<void *(*)(void *, const void *, unsigned long long)>() {
return [](mlir::MLIRContext *context) -> mlir::Type {
auto voidPtrTy =
fir::LLVMPointerType::get(context, mlir::IntegerType::get(context, 8));
``````````
</details>
https://github.com/llvm/llvm-project/pull/233251
More information about the flang-commits
mailing list