Skip to content

CLang/Mingw Linker Bug When -p mingw is excluded. #958

@RussellHaley

Description

@RussellHaley

Describe the bug

I am using the llvm-mingw project which combines CLang and mingw-64. I noticed when configuring a project that excluding -p mingw causes the linker to fail when compiling lua due to it attempting to link directly to the dll. So these configurations work:

xmake f -v -a $arch -p mingw --toolchain=clang --mrc="$triplet-windres.exe" --mingw=$stdlib_dir
xmake config -v -a $arch -p mingw --toolchain=clang --mrc="$triplet-windres.exe" --sdk=$stdlib_dir

but this does not:

xmake config -v -a $arch --toolchain=clang --mrc="$triplet-windres.exe" --sdk=$stdlib_dir

[ 97%]: linking.release lua51.exe
error: lld: error: lld doesn't support linking directly against build\windows\x86_64\release\lua51.dll, use an import library
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

Since the CLang lld linker cannot link against DLLs, the "Platform" should not matter, both mingw and windows should generate and use lib files for linking.

Expected behavior

The linker call generated by xmake should always use a lib file when building for platforms mingw and windows.

Feature Request

I would like to note that on *Nix and Windows, the LLVM-MinGW package always includes the sdk in a directory adjacent to bin in triplet form: <arch>-w64-migw32. It would be really slick if xmake could figure out the compiler path so one would only need to do:

xmake f -p mingw --toolchain=clang

which should default to x86_64, or optionally include an arch:

xmake f -a aarch64 -p mingw --toolchain=clang

I build the llvm-mingw toolchain on a FreeBSD host then cross compile my WinLua toolchain (which include llvm-mingw for windows) and then test the compiler in windows. The directory structure is identical on both platforms. Here is a screen shot of my WinLua install. It uses the "official" llvm-mingw build and I directly install the cmake install output.

image

Thanks!
Russ

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions