Skip to content
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

Add community support for building with MinGW #9137

Merged
merged 3 commits into from
Jan 17, 2020

Conversation

cristianadam
Copy link
Contributor

@cristianadam cristianadam commented Nov 28, 2019

The merge request adds the following commits:

  1. Add needed changes to build vcpkg itself with MinGW.
    Tested with the standalone StephanTLavavej/mingw-distro.
  2. Add toolchain support for building with MinGW compilers.
  3. Add community tripplets to build x86, x64, arm, arm 64.

The arm and arm64 triplets I tested with the Clang-LLVM/MinGW toolchain.

@msftclas
Copy link

msftclas commented Nov 28, 2019

CLA assistant check
All CLA requirements met.

@cbezault
Copy link
Contributor

cbezault commented Dec 3, 2019

Does the [[maybe_unused]] attribute you added compile with vs2015?

@cristianadam
Copy link
Contributor Author

Does the [[maybe_unused]] attribute you added compile with vs2015?

yes it does. See:

$ cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..\toolsrc
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Projects/github/vcpkg/build-msvc2015

c:\Projects\github\vcpkg\build-msvc2015
$ cmake --build .
[0/2 ?/sec]Re-checking globbed directories...
[46/84 1.0/sec]Building CXX object CMakeFiles\vcpkglib.dir\src\vcpkg\logicexpression.cpp.obj
FAILED: CMakeFiles/vcpkglib.dir/src/vcpkg/logicexpression.cpp.obj
"C:\PROGRA~2\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\cl.exe"  /nologo /TP -DDISABLE_METRICS=0 -IC:\Projects\github\vcpkg\toolsrc\include /DWIN32 /D_WINDOWS  /GR /EHsc /MD /O2 /Ob2 /DNDEBUG   -FC -std:c++latest -W4 -WX /showIncludes /FoCMakeFiles\vcpkglib.dir\src\vcpkg\logicexpression.cpp.obj /FdCMakeFiles\vcpkglib.dir\ /FS -c C:\Projects\github\vcpkg\toolsrc\src\vcpkg\logicexpression.cpp
c:\projects\github\vcpkg\toolsrc\src\vcpkg\logicexpression.cpp(74) : error C2220: warning treated as error - no 'object' file generated
c:\projects\github\vcpkg\toolsrc\src\vcpkg\logicexpression.cpp(74) : warning C4702: unreachable code
[55/84 1.1/sec]Building CXX object CMakeFiles\vcpkglib.dir\src\vcpkg\vcpkgcmdarguments.cpp.obj
ninja: build stopped: subcommand failed.

c:\Projects\github\vcpkg\build-msvc2015
$ cmake --build .
[0/2 ?/sec]Re-checking globbed directories...
[30/30 1.2/sec]Linking CXX executable vcpkg-test.exe

But only after applying this unrelated patch:

diff --git a/toolsrc/src/vcpkg/logicexpression.cpp b/toolsrc/src/vcpkg/logicexpression.cpp
index ccb8b00c4..eed27bdf3 100644
--- a/toolsrc/src/vcpkg/logicexpression.cpp
+++ b/toolsrc/src/vcpkg/logicexpression.cpp
@@ -68,11 +68,11 @@ namespace vcpkg
                 add_error("Invalid logic expression");
             }

-            if (err)
-            {
-                err->print_error();
-                final_result = false;
-            }
+//             if (err)
+//             {
+//                 err->print_error();
+//                 final_result = false;
+//             }
         }

         bool get_result() const { return final_result; }

@cbezault
Copy link
Contributor

cbezault commented Dec 3, 2019

Could you please make a PR for that unrelated patch. It would be much appreciated. We're supposed to support vs2015.
Edit: Sorry didn't look at what you were actually doing. Someone needs to fix that issue but it is unnecessary for this PR to go through.

@tstavrianos
Copy link

tstavrianos commented Dec 10, 2019

When trying to use this with nuwen-mingw to build boost-stacktrace (and boost in general) it fails with this in install-x64-mingw-dbg-out.log:

g++.exe: error: x86_64-windows-gnu: No such file or directory

Successfully built sdl2 with it and boost is not a huge issue (as nuwen-mingw has it already included).

@tstavrianos
Copy link

Some extra info that might help, it fails earlier on if I don't have boost-build:x86-windows installed:

CMake Error at installed/x64-mingw/share/boost-build/boost-modular-build.cmake:18 (message):
  The x86 boost-build tools must be installed to build for non-x86/x64
  platforms.  Please run `vcpkg install boost-build:x86-windows`.
Call Stack (most recent call first):
  ports/boost-stacktrace/portfile.cmake:14 (boost_modular_build)
  scripts/ports.cmake:94 (include)

@cristianadam
Copy link
Contributor Author

Some extra info that might help, it fails earlier on if I don't have boost-build:x86-windows installed:

CMake Error at installed/x64-mingw/share/boost-build/boost-modular-build.cmake:18 (message):
  The x86 boost-build tools must be installed to build for non-x86/x64
  platforms.  Please run `vcpkg install boost-build:x86-windows`.
Call Stack (most recent call first):
  ports/boost-stacktrace/portfile.cmake:14 (boost_modular_build)
  scripts/ports.cmake:94 (include)

Not all packages would work with this PR, especially those that require a custom build system like boost.

Somebody would have to make sure that boost-build:x64-mingw gets properly bootstrapped.

@dan-shaw
Copy link
Contributor

@cristianadam Thanks for the PR! We like the idea and implementation. However, since we don't officially support MinGW, the triplet files will need to go into a separate folder: community-triplets. We don't have support for this yet, so we will have to wait before we can merge this.

@dan-shaw dan-shaw added info:reviewed Pull Request changes follow basic guidelines and removed needs-further-review labels Dec 13, 2019
@alcroito
Copy link
Contributor

Hi. Would it be acceptable to merge the PR without the triplet files?

@cristianadam
Copy link
Contributor Author

@dan-shaw I removed the triplets from the MR.

The x64-mingw triplet is nothing more than:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH PATH)

set(VCPKG_CMAKE_SYSTEM_NAME MinGW)

I think if vcpkg would have the MR merged, having to write a six line triplet file won't be such a big deal 😄

@cristianadam
Copy link
Contributor Author

We need to wait for OSX CI to fix before merge this PR.

The CI is stuck since 16th of December.
How can I retriger the OSX CI? On previous commits of this PR everything was green.

@dan-shaw
Copy link
Contributor

I don't think we can, the MacOS CI pipeline is still down.

@cristianadam
Copy link
Contributor Author

I don't think we can, the MacOS CI pipeline is still down.

The macOS CI pipeline is down since 2nd of December 😮

GitHub Actions is up and running fine on macOS, maybe you guys should switch to GitHub Actions ? 😄

@dan-shaw
Copy link
Contributor

dan-shaw commented Jan 6, 2020

We might merge this and not wait for the MacOS CIs to be back up (since it is taking a while). Pinging @ras0219 for review

@cristianadam
Copy link
Contributor Author

The vcpkg-osx-PR is still broken.

I've seen that release 2019.12 was done.
What can we do as externals?

@JackBoosY
Copy link
Contributor

@cristianadam See #9600.

@vicroms
Copy link
Member

vicroms commented Jan 16, 2020

/azp run

@cristianadam
Copy link
Contributor Author

What's the difference between vcpkg-osx-PR and vcpkg-osx-PR-test?

@strega-nil
Copy link
Contributor

@cristianadam vcpkg-osx-PR-test is a better version of vcpkg-osx-PR; vcpkg-osx-PR has been deprecated.

@matwey
Copy link
Contributor

matwey commented Jan 17, 2020

MinGW triplets are not included, but writing a MinGW triplet is as easy as:

Are you going to contribute MinGW triplets later? I think it may be very productive idea when vcpkg is used in CI. Then CI configurations for Visual Studio and MinGW can differ only by the triplet in use.

scripts/cmake/vcpkg_common_definitions.cmake Show resolved Hide resolved
toolsrc/src/vcpkg/sourceparagraph.cpp Outdated Show resolved Hide resolved
Tested with MSYS2 MinGW 8.3.0, gcc-mcf.lhmouse MinGW 9.2.1,
and StephanTLavavej/mingw-distro!
From your MinGW configured shell you could just use vcpkg to
configure packages.

An x64-mingw triplet would look like:
```
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH PATH)

set(VCPKG_CMAKE_SYSTEM_NAME MinGW)
```
@vicroms
Copy link
Member

vicroms commented Jan 17, 2020

Hi @cristianadam

Now that Community Triplets have been merged in #7976 can you please add a x64-mingw triplet in triplets/community/.

@cristianadam
Copy link
Contributor Author

Hi @cristianadam

Now that Community Triplets have been merged in #7976 can you please add a x64-mingw triplet in triplets/community/.

Done. The original triplets that I have had are back in. 🤘

@vicroms
Copy link
Member

vicroms commented Jan 17, 2020

Thanks for the PR!

@vicroms vicroms merged commit 38b9590 into microsoft:master Jan 17, 2020
@vicroms vicroms changed the title Add support for building with MinGW Add community support for building with MinGW Jan 17, 2020
@cristianadam cristianadam deleted the build-with-mingw branch January 23, 2020 19:02
strega-nil pushed a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
* Add support for building with MinGW

Tested with MSYS2 MinGW 8.3.0, gcc-mcf.lhmouse MinGW 9.2.1,
and StephanTLavavej/mingw-distro!

* Add MinGW toolchain

From your MinGW configured shell you could just use vcpkg to
configure packages.

An x64-mingw triplet would look like:
```
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH PATH)

set(VCPKG_CMAKE_SYSTEM_NAME MinGW)
```

* Add MinGW community tripplets

x64 tested with https://github.com/StephanTLavavej/mingw-distro
x86, arm64, arm tested with https://github.com/mstorsjo/llvm-mingw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.