mcgoo / vcpkg-rs

Build library for finding native libraries in vcpkg for Rust - Windows (msvc), Linux and macOS
https://docs.rs/vcpkg
Apache License 2.0
108 stars 22 forks source link

Support for custom vcpkg triplets #44

Open nico-abram opened 2 years ago

nico-abram commented 2 years ago

I'm using some dependencies which use this crate to link C/C++ libraries on windows (For example leptonica and tesseract).

I am trying to enable cross-language LTO on a build targeting x86_64-pc-windows-msvc. This requires compiling C/C++ code using an LLVM compiler, which means not using MSVC's cl.exe compiler. I have gotten it to compile using clang-cl instead of MSVC's cl.exe and lld-link.exe instead of link.exe manually building the C/C++ code and instructing my dependencies via env vars to not use this crate and instead use the libs I generated, but I think ideally vcpkg can be made to work with it.

I found this issue https://github.com/microsoft/vcpkg/issues/2087 about clang-cl support in vcpkg, which was closed and vcpkg does not support a triplet for it, not as an official triplet, nor as a community maintained triplet shipped with vcpkg. However, vcpkg has support for "custom triplets" which are even less supported than community and you have to manually add to the vcpkg/triplets folder. And in that issue, someone shared their github repository with custom triplets which includes a x64-windows-llvm triplet that uses clang-cl. I'm opening this issue to check/discuss if somehow (Maybe through an environment variable) custom vcpkg triplet support would be in scope for this crate.

I am essentially thinking of something like:

REM I manually make a triplet file for vcpkg and add it to vcpkg/triplets before installing libs and then run this
set VCPKGRS_TRIPLET_OVERRIDE=x64-windows-llvm-thinlto
cargo build --release
ras0219-msft commented 2 years ago

vcpkg itself has an environment variable to inject overlay triplet paths: https://github.com/microsoft/vcpkg/blob/master/docs/users/config-environment.md#vcpkg_overlay_triplets.

Have you tried using that in combination with VCPKGRS_TRIPLET_OVERRIDE?

nico-abram commented 2 years ago

VCPKGRS_TRIPLET_OVERRIDE does not exist, it was hypothetical