fix(windows): add memset_explicit symbol export for mingw cross-compilation
Some checks failed
Test / frontend-typecheck (pull_request) Successful in 1m57s
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Successful in 1m46s
PR Review Automation / review (pull_request) Successful in 4m30s
Test / rust-tests (pull_request) Has been cancelled

- Add __declspec(dllexport) to memset_explicit in memset_s_shim.c
- Explicitly link memset_shim library in build.rs for Windows MinGW target
- Fixes undefined reference to memset_explicit when building for x86_64-pc-windows-gnu
This commit is contained in:
Shaun Arman 2026-06-18 23:32:09 -05:00
parent b6ecd49b52
commit d45e767d6d
2 changed files with 9 additions and 1 deletions

View File

@ -13,6 +13,8 @@ fn main() {
.file("memset_s_shim.c") .file("memset_s_shim.c")
.compile("memset_shim"); .compile("memset_shim");
println!("cargo:rerun-if-changed=memset_s_shim.c"); println!("cargo:rerun-if-changed=memset_s_shim.c");
// Explicitly link the shim library
println!("cargo:rustc-link-lib=static=memset_shim");
} }
tauri_build::build() tauri_build::build()

View File

@ -6,7 +6,13 @@
#include <string.h> #include <string.h>
void memset_explicit(void *dest, int val, size_t n) { #ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
EXPORT void memset_explicit(void *dest, int val, size_t n) {
volatile unsigned char *p = (volatile unsigned char *)dest; volatile unsigned char *p = (volatile unsigned char *)dest;
while (n--) { while (n--) {
*p++ = (unsigned char)val; *p++ = (unsigned char)val;