Skip to content

Cannot use clang-cl with LTO because MSVC's lib.exe crashes #644

Closed
@nico-abram

Description

@nico-abram

I'm trying to compile a windows project using the msvc toolchain and cross language LTO. To do this, I'm trying to use clang-cl instead of the MSVC cl.exe to compile the C/C++ code. I'm running into a problem where cc-rs tries to use lib.exe to archive the generated object files, but MSVC's lib.exe does not understand the clang object files with LLVM bitcode for LTO, so it crashes. I'm opening this issue for discussion, ideally I would like a solution like an env var that lets me override the archiver, or identifying clang-cl with LTO and trying to find LLVM-lib (I don't know if rust ships with one, but if not maybe there could be an env var with a path to an installer LLVM/bin).

I also tried to temporarily make a copy of LLVM-lib called lib.exe and put it before lib.exe in my path but it didn't work because cc-rs is finding the specific VS path to lib.exe from the registry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions