Skip to content

Community triplets not working because of toolchain detection mechanism #12065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
longnguyen2004 opened this issue Jun 23, 2020 · 17 comments · Fixed by #12084
Closed

Community triplets not working because of toolchain detection mechanism #12065

longnguyen2004 opened this issue Jun 23, 2020 · 17 comments · Fixed by #12084
Assignees
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)

Comments

@longnguyen2004
Copy link
Contributor

Trying to use *-mingw triplets gives me an Unable to determine toolchain to use for triplet error. There are no references to community triplets in the documentation either. Am I missing something here?

@NancyLi1013
Copy link
Contributor

Hi @longnguyen2004
Thanks for posting this issue.
Could you please help confirm which triplet you used to install and on which platform? Please also make sure if you have installed the related components in Visual Studio.

@NancyLi1013 NancyLi1013 added the category:question This issue is a question label Jun 23, 2020
@longnguyen2004
Copy link
Contributor Author

I'm using the x64-mingw community triplet on Windows. I have Visual Studio installed, but I only use it for bootstrapping vcpkg, since I'm trying to use vcpkg with the llvm-mingw toolchain.

@NancyLi1013
Copy link
Contributor

Which port do you install?
BTW, those triplets in community folder are currently not guaranteed to be built successfully.

@longnguyen2004
Copy link
Contributor Author

Every port I try results in the same error
image
image
image
If I had to guess, it's due to /toolsrc/src/vcpkg/build.cpp and /script/buildsystems/vcpkg.cmake missing the required mingw toolchain entry. I've tried patching build.cpp and so far I haven't had any problems. But I feel like this is not the correct way to do it

@NancyLi1013
Copy link
Contributor

Thanks for your update. It seems that there is something missing in mingw support.

@cristianadam
Could you please help take a look about this?

@NancyLi1013 NancyLi1013 added category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) and removed category:question This issue is a question labels Jun 24, 2020
@cristianadam
Copy link
Contributor

@NancyLi1013 I tested tag "2020.01" and vcpkg builds with my TDM MinGW GCC 9.2.0 and vcpkg --triplet x64-mingw install zlib does work.

Regarding master, I had to apply #12084 to get it building. But when I tried vcpkg --triplet x64-mingw install zlib it didn't work.

@longnguyen2004 either use vcpkg "2020.01" or wait until the problem with the toolchain gets fixed.

@longnguyen2004
Copy link
Contributor Author

I think I see where the problem is. In 2020.01, if CMAKE_SYSTEM_NAME isn't recognized, it does nothing. In master, it errors out, so the changes need to be reverted.

@cristianadam
Copy link
Contributor

cristianadam commented Jun 24, 2020

@longnguyen2004 Try #12084. vcpkg --triplet x64-mingw install zlib worked fine for me with master.

@longnguyen2004
Copy link
Contributor Author

longnguyen2004 commented Jun 24, 2020

@cristianadam you mentioned the wrong person :) anyway I'll try it now
btw #12084 is exactly what I did to fix the problem, but imo it's a bit unnecessary since vcpkg_configure_cmake already loaded mingw.cmake for us. The real fix here is to remove the error when the triplet isn't official, since I just found out that *-ios is also broken.

@cristianadam
Copy link
Contributor

I've updated the previous comment. Sorry about that.

I used the fix you provided for build.cpp in order not to get the Unable to determine toolchain error. Then the file(TO_CMAKE_PATH) fixes the error that I got building zlib with MinGW, since it took the c:\ part of the path and then CMake would bail with invalid \P characters.

#12084 allows me to build vcpkg and install packages via --triplet x64-mingw.

@longnguyen2004
Copy link
Contributor Author

longnguyen2004 commented Jun 24, 2020

I'm trying to find a better fix since ios is also broken in the same way.
Also, does removing the error message causes anything else, since it wasn't there in 2020.01?

@jimboyeah
Copy link

我遇到这个问题有点恶心,因为 vcpkg 的源代码忽略了 MinGW:

>vcpkg install assimp:x64-mingw
Computing installation plan...
The following packages will be built and installed:
    assimp[core]:x64-mingw
  * minizip[core]:x64-mingw
  * rapidjson[core]:x64-mingw
  * zlib[core]:x64-mingw
Additional packages (*) will be modified to complete this operation.
Unable to determine toolchain to use for triplet x64-mingw with CMAKE_SYSTEM_NAME MinGW

解决方法是修改 build.cpp 重新编译 vcpkg:

diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index c61c6b7..d7c78aa 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -558,6 +558,10 @@ namespace vcpkg::Build
         else if (cmake_system_name == "Android")
         {
             return m_paths.scripts / fs::u8path("toolchains/android.cmake");
+        }
+        else if (cmake_system_name == "MinGW")
+        {
+            return m_paths.scripts / fs::u8path("toolchains/mingw.cmake");
         }
         else if (cmake_system_name.empty() || cmake_system_name == "Windows" || cmake_system_name == "WindowsStore")
         {
--

@longnguyen2004
Copy link
Contributor Author

I think the best way is to simply ignore the toolchain selection in build.cpp for community triplets and use VCPKG_CHAINLOAD_TOOLCHAIN_FILE instead, not sure how it'll work out though.

@longnguyen2004 longnguyen2004 changed the title How do I use community triplets? Community triplets not working because of toolchain detection mechanism Jul 11, 2020
cristianadam added a commit to cristianadam/vcpkg that referenced this issue Jul 16, 2020
strega-nil pushed a commit that referenced this issue Jul 18, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
* Build fix with MinGW GCC 9.2.0

* Fix MinGW tripplets

Fixes #12065

* clang-format

* Fix unused read_symlink_implementation warning marked as error

read_symlink_implementation was used only in copy_symlink_implementation
when #if defined(_WIN32) && !VCPKG_USE_STD_FILESYSTEM  was true.

Removed the warning otherwise.

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
@NancyLi1013
Copy link
Contributor

@longnguyen2004 @jimboyeah
Could you please try to update vcpkg to the latest version and rebuild this?

@longnguyen2004
Copy link
Contributor Author

image
Yep it works now, the pkg-config error is unrelated to this

@NancyLi1013
Copy link
Contributor

@longnguyen2004
Thanks for your update.
For the status of community triplets, please refer to this doc.

@longnguyen2004
Copy link
Contributor Author

Alright got it, I actually have a couple of patches ready 😃

remz1337 pushed a commit to remz1337/vcpkg that referenced this issue Aug 11, 2020
* Build fix with MinGW GCC 9.2.0

* Fix MinGW tripplets

Fixes microsoft#12065

* clang-format

* Fix unused read_symlink_implementation warning marked as error

read_symlink_implementation was used only in copy_symlink_implementation
when #if defined(_WIN32) && !VCPKG_USE_STD_FILESYSTEM  was true.

Removed the warning otherwise.

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
strega-nil pushed a commit to strega-nil/vcpkg that referenced this issue May 5, 2021
* Build fix with MinGW GCC 9.2.0

* Fix MinGW tripplets

Fixes microsoft#12065

* clang-format

* Fix unused read_symlink_implementation warning marked as error

read_symlink_implementation was used only in copy_symlink_implementation
when #if defined(_WIN32) && !VCPKG_USE_STD_FILESYSTEM  was true.

Removed the warning otherwise.

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants