tpoechtrager / wclang

Cross compile source code easily for Windows with clang on Linux/Unix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for clang ASAN

fabceolin opened this issue · comments

When I trying to compile a hello world using -fsanitize=address, clang is trying to search for a nonexistent files.

x86_64-w64-mingw32-clang  -fsanitize=address  hello-world.c 
hello-world.c:2:5: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
    printf("Hello World");
    ^
hello-world.c:2:5: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
/usr/bin/x86_64-w64-mingw32-ld: cannot find /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic-x86_64.dll.a: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic_runtime_thunk-x86_64.a: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic_runtime_thunk-x86_64.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I was wondering if I can't get these files from windows installation.

I sucessfully generate /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic-x86_64.dll.a from the original ./lib/clang/10.0.0/lib/windows/clang_rt.asan_dynamic-x86_64.dll for llvm10 windows installation using gendef and dlltool, but I don't know how to convert the original ./lib/clang/10.0.0/lib/windows/clang_rt.asan_dynamic_runtime_thunk-x86_64.lib to /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic_runtime_thunk-x86_64.a

Are there some way to solve this problem?

You can't use the dlls from the LLVM installer. They use MSVC mangling and aren't compatible with the MinGW target.

You must compile ASAN with wclang in order to get it working. I am not sure if that's even possible.