-
Notifications
You must be signed in to change notification settings - Fork 215
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
[Build] Boost::Hana on Windows with Clang 3.7.0 using MinGW64 and Visual Studio 2015 #201
Comments
This is great news. I'm going to try this tomorrow. Thanks! |
@m-j-w Thanks a bunch! I'll try to see if I can setup continuous integration on AppVeyor. |
Well, it appears to be rather trivial after all: in
Then simply opening the created The failing tests are:
Well, no doubt about the reason for the missing @ldionne Checking for Clang-CL/MSVC in
A last tip: I initially modified the |
Hmm, actually reading the error helps as well. With respect to test.tuple.empty_member (hana\test\tuple\empty_member.cpp(17,9): error : static_assert failed):
So not really a failure in Hana. |
I'm looking at it right now. Seems like the compiler isn't doing the empty base optimization (EBO)? Regarding the error in |
And with respect to
I'd say the second is apparently wrong... |
@m-j-w Could you please tell me the output of the following program? #include <boost/hana.hpp>
#include <iostream>
#include <tuple>
namespace hana = boost::hana;
struct Empty { };
template <typename T>
struct Holder { T value; };
struct EBO : Empty, Holder<int> { };
int main() {
std::cout << sizeof(hana::tuple<Empty, int>) << std::endl;
std::cout << sizeof(int) << std::endl;
std::cout << sizeof(Empty) << std::endl;
std::cout << sizeof(std::tuple<Empty, int>) << std::endl;
std::cout << sizeof(EBO) << std::endl;
} On my machine, the output is
Regarding [Edit: This should be fixed in cb390d2, which I just pushed to develop.] |
First, it happens both in Debug and Release, and I don't find a switch for changing EBO, but I'd also guess that to be the reason. And the output to your test case is
|
Regarding EBO: Seems to be an emulated special feature of MSVC, aka bug, where only a first base class is optimized. See http://stackoverflow.com/a/12714226 |
The issues with |
Yepp, and |
Thanks a lot for the research. This is seriously fucked up. I could tweak the test to workaround EBO not being available. However, is there no switch to make clang-cl compliant and not emulate MSVC bugs? |
I've only read in some other mailing list that the clang guys had a lot of trouble in actually emulating all those special behaviours to make clang-cl a drop-in replacement for the MS compiler. Same for the types char16_t and char32_t which have supposedly been more or less silently introduced. So I'd guess no. The neat cite reads something like: clang tries to parse, when failing due to MS special behaviour tries to recover, and finally tries to compile. Says pretty much everything... And those specialties need to be handled to be "compatible" with the MSVC standard C library. |
Fixed in 76a0ac1. I truly hate working around such standard noncompliance, but in this case the fix is fairly self-contained. Please let me know if it works. |
Sorry, no, it doesn't.
The warning is issued by |
Of course, static_asserts are parsed during template instantiation. So that deactivation doesn't work since candidate selection happens afterwards. |
Nope, it really should work, since |
Well, you could compare the tuples against equivalently complicated simple non-templated structs, just like in the other test above. And either way, it's just a test, but a nice outlook on what cross-platform support might lead to... |
You're right, thanks. db487b2 should work, I hope. I'd like to get Appveyor set up so I can get Windows feedback without relying on external folks, but I'm terribly clueless with Windows. See for example https://ci.appveyor.com/project/ldionne/hana/build/1.0.13. If you have any idea on how I can download your Clang-cl in powershell or cmd.exe, please let me know. I have to go for now, but thanks a lot for the feedback! I'll check this again tomorrow or in a couple of days (I have some school stuff to do these days). |
Sorry to disappoint you, doesn't. Here's a modified version with outputs: /*
@copyright Louis Dionne 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana/tuple.hpp>
#include <iostream>
namespace hana = boost::hana;
//
// This test makes sure that `hana::tuple` has a simple enough representation.
// In particular, we make sure that the empty base-class optimization (EBO)
// is able to fire, when supported.
//
template <typename T>
struct holder { T value; };
template <typename ...T>
struct inherit : T... { };
struct A { };
struct B { };
//static_assert((sizeof(hana::tuple<int, A>) == sizeof(inherit<holder<int>, A>)), "");
//static_assert((sizeof(hana::tuple<A, int>) == sizeof(inherit<A, holder<int>>)), "");
//static_assert((sizeof(hana::tuple<A, int, B>) == sizeof(inherit<A, holder<int>, B>)), "");
//static_assert((sizeof(hana::tuple<A, B, int>) == sizeof(inherit<A, B, holder<int>>)), "");
//static_assert((sizeof(hana::tuple<int, A, B>) == sizeof(inherit<holder<int>, A, B>)), "");
int main() {
std::cout << "A: " << sizeof(A) << std::endl;
std::cout << "B: " << sizeof(B) << std::endl;
std::cout << std::endl;
std::cout << "hana::tuple<int, A>: " << sizeof(hana::tuple<int, A>) << std::endl;
std::cout << "hana::tuple<A, int>: " << sizeof(hana::tuple<A, int>) << std::endl;
std::cout << "hana::tuple<A, int, B>: " << sizeof(hana::tuple<A, int, B>) << std::endl;
std::cout << "hana::tuple<A, B, int>: " << sizeof(hana::tuple<A, B, int>) << std::endl;
std::cout << "hana::tuple<int, A, B>: " << sizeof(hana::tuple<int, A, B>) << std::endl;
std::cout << std::endl;
std::cout << "inherit<holder<int>, A>: " << sizeof(inherit<holder<int>, A>) << std::endl;
std::cout << "inherit<A, holder<int>>: " << sizeof(inherit<A, holder<int>>) << std::endl;
std::cout << "inherit<A, holder<int>, B>: " << sizeof(inherit<A, holder<int>, B>) << std::endl;
std::cout << "inherit<A, B, holder<int>>: " << sizeof(inherit<A, B, holder<int>>) << std::endl;
std::cout << "inherit<holder<int>, A, B>: " << sizeof(inherit<holder<int>, A, B>) << std::endl;
} MinGW64 clang gives
and MSVC/Clang-cl gives
|
Hmm, not familiar with Appveyor, yet. But the following might help:
The -T defines the platform toolset, meaning the toolchain aka compiler executable and linker executable and all the default flags. The chosen generator -G also defines some defaults and creates the correct solution for VS 2015 (despite the toolset actually reading LLVM-vs2014). However, you then have the Visual Studio solution which you need to open and run. Problably there's also some command line thing, but I don't know that yet... When I tried to run clang-cl from the command line I had quite a lot problems with the libraries for 32 and 64bit. Adding Someone else reading this who might be able to help ? |
Forgot the actual question: Downloading with powershell. No idea, that's why I prefer to use Cygwin and MinGW64 when I have to work on Windows... but that might help: http://www.powershellatoms.com/basic/download-file-website-powershell/ |
@m-j-w My current problem is actually quite stupid. I manage to download http://llvm.org/releases/3.7.0/LLVM-3.7.0-win64.exe, but then I can't extract the archive! I tried many things like |
Ah, I see. Usually that requires the GUI. I checked the .exe for command line args, but it didn't give any, and didn't respond to any. If it actually were a "Windows installer" (extension .msi) then an unattended install from the command line would be possible, see the "package manager" at https://technet.microsoft.com/en-us/library/cc759262(v=ws.10).aspx However, building a visual studio solution (.sln) is possible from the command line with Looks like #202 could also be a reason for the above EBO difficulty. I'll check when you commit. |
On second thought, asking AppVeyor whether they might be willing to add clang-cl and the integration to their portfolio might be less troublesome. They appear to have a large set of software already installed, including MinGW64 and Cygwin. |
Yes, this is what I thought. It's definitely the compiler emulating MSVC's bug. |
And also just for reference, which I could already have done earlier and saved us quite some time, the actual MSVC compiler also results in
for the above test case. Apparently, I couldn't add the |
Thanks. This is indeed not a bug in tuple, just a particularity of Clang-cl that we'll have to workaround. That could be done by simply disabling the tests that check for EBO on that compiler from the CMake files. We already do similar stuff when Boost is missing, or when libc is too old because of a bug in |
I updated the pull-request (and the PR message). |
This time, I also ran all the possible cases and got the correct warning messages for the compiler detection scripts and the Also, finally, I figured how to build and run the tests from the command line (cmd.exe). For future reference, I'll document that here. For a 32bit Debug build:
For a 64bit Release build using a less verbose output comparable to the amount of cmake/make (
Note the difference for the invokation of cmake and MSBuild in the platform tag, and, yes, the For a Hana build and test run, I highly recommend the use of the command line. Due to the close to 1000 test cases (and probably growing), MSVC (the IDE) is rather slow with all those background indexing processes. There also seems to be a chance in generating a build for ARM (replace Win64 with ARM in the above example), since being available as cmake generator. But I can't test that. With these lines you should be able to describe the build matrix in the appveyor JSON definition, once the clang-cl issue is solved. A closing remark: If you would prefer adding such platform specific notes somewhere more permanent, the github wiki might be a good place. I'd expect the compiler landscape as a whole to improve at a faster pace than major releases of boost are released. There could then also be notes for platforms where you don't have an automatic build and test, and which would thus only have limited support. |
While I agree that the Visual Studio IDE is overkill for building the test projects, I found that disabling Intellisense (and then restarting VS) increased UI responsiveness to a usable level, at least once the projects have loaded. |
Well, that wasn't meant to be a general recommendation for application development. But after having run quite a lot of test runs, I find it rather impractical for the very purpose given above. @badair would you mind checking the correctness of the PR by running the tests after @ldionne accepts it ? Most likely he will feel relieved not having to rely solely on one confirmation of one single user. |
Thanks for the notes, I just added them to the wiki.
Actually, could you do that before I merge? It can be done by doing git remote add mjw https://github.com/m-j-w/hana.git
git fetch mjw windows_build
git checkout windows_build and then checking that it works properly. |
I'm going to close this in favour or #207, which is more targeted. |
I checked out mjw's branch, then built and ran tests for 64 bit. Test results:
CTest errors: http://pastebin.com/Q5u2VwyC (re)build results: http://pastebin.com/hiWxKs1w (ctrl f "error") Need me to do this for 32bit as well? |
Small nitpick - technically there should be a |
Fixed. Note that anyone can edit the wiki, so if you see something to fix you can also do it yourself.
Thanks a lot for checking. No need to do it for 32 bit; I've merge the pull request now. I set up a Windows VM and I'm also trying to run the tests myself. |
I just set up the environment on a fresh Windows install the other day. It's pretty straightforward, but I'm happy to help if you get stuck. |
Thanks, actually it was super easy and I'm now proudly running the tests on Windows. Huge thanks to @m-j-w for all the grunt work of making this possible without too much pain. Now, I'll exclude the unit tests that fail on Windows from the build when we detect Clang-Cl (if possible), so we get everything passing. |
Glad to help increase the user experience, and, hopefully, the number of users. And even better that you now have Windows covered semi-automatically on your side, too ;-) |
More a success story than issue: I've been building Hana with Clang 3.7.0 (libstdc of gcc 5.2.0), both provided by MinGW64, and it compiled and ran all tests and examples successfully (917 of 917), with and without exceptions enabled, respectively.
Secondly, I've tried LLVM/Clang on Windows with the prebuilt windows binaries from http://llvm.org/releases/download.html . After generating the solution with cmake, changing manually the platform toolset to
LLVM-vs2014
, I chose manually some of the tests and examples, and compiled and ran them successfully. This includes the known difficult tests with type traits and the 9 parts of tuple tests.The build is a bit verbose due to some warnings about unrequired compiler flags, and features being GNU extensions, such like string literals. To my surprise, even the VS debugger works with the Clang-generated binaries... Unfortunately I'm not too familiar with the Visual Studio toolchain, so I can't provide a patch for the cmake scripts or to automate the testing framework. At least not in the near future.
Anyway, I'd say there are now at least two possible ways to use Boost::Hana on Windows. And Cygwin should also work fine once GCC is upgraded from 4.9.3 to 5.2.0 or higher.
The text was updated successfully, but these errors were encountered: