purpleprotocol / mimalloc_rust

A Rust wrapper over Microsoft's MiMalloc memory allocator
MIT License
481 stars 42 forks source link

Building with `cargo-xwin` fails to link: `lld-link: error: undefined symbol: __movsb` #104

Open s1341 opened 9 months ago

s1341 commented 9 months ago

When trying to build for windows on a linux host, mimalloc fails to link with the following error:

  = note: lld-link: error: undefined symbol: __movsb
          >>> referenced by /src/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/include/mimalloc/internal.h:926
          >>>               liblibmimalloc_sys-087f9fdc909808e0.rlib(static.o):(_mi_memcpy)

I'm using cargo-xwin to cross compile.

namse commented 3 months ago

I could successfully build with below command in ubuntu for msvc,

rustup component add llvm-tools-preview
rustup target add x86_64-pc-windows-msvc
rustup update

cargo xwin check --target x86_64-pc-windows-msvc --xwin-arch x86_64 --xwin-version 17 --tests
// you can run `build` instead of `check`
s1341 commented 3 months ago

I'm still getting an error, using clang/lld-link 17 and rustc 1.77.1

namse commented 3 months ago

Could you show me the command you tried? Are you sure the same command with my suggestion?

s1341 commented 3 months ago

Here is my command:

cargo xwin build  --target x86_64-pc-windows-msvc --release --xwin-version 17 --xwin-arch x86_64

Note that I am building a project which relies on mimalloc, not mimalloc directly.

namse commented 3 months ago

If your project is open source, may I check it directly? or would you make a minimal reproducible example?

s1341 commented 2 months ago

https://github.com/AFLplusplus/LibAFL/pull/1607 build fuzzers/frida_gdiplus with cargo xwin. Make sure to switch from dlmalloc to mimalloc in fuzzers/frida_gdiplus/src/lib.rs....

s1341 commented 1 month ago

It has been merged to main, so it should be easier to check now.