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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with building SFML 3 (and 2.6) on Windows with Clang #2046
Comments
#1957 This PR changed how we were defining the fixed-width
The missing braces seem like an easy fix. Can you try to fix that locally and confirm whether it works? If so then that might be a viable PR.
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170 |
I have tried Clang with MSVC-like command-line, and it works! It even produces the desired effect for #2047!! |
I've lost track of what was and wasn't fixed. Can you provide an update on the buildability of 2.6.x and master? |
Sorry for the delay.. Unfortunately I have reinstalled windows like 5 times by now, so I don't have the same development environment at the moment. I'll comment as soon as I'll be able to test it again! |
I'm still having this issue (clang windows msvc 15). Got everything working by doing: // /include/SFML/Config.hpp
#if defined(_MSC_VER) && !defined(__clang__) // Added !defined(__clang__)
typedef signed __int64 Int64;
typedef unsigned __int64 Uint64;
#else
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++11-long-long"
#endif
typedef signed long long Int64;
typedef unsigned long long Uint64;
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif Then got lots of other warnings like deprecated items which can be solved by adding: add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS) However this is at global CMake scope and dislike this. So either, SFML must use Also, bool isWindowsXpOrOlder()
{
// Windows XP was the last 5.x version of Windows
return false;//static_cast<DWORD>(LOBYTE(LOWORD(GetVersion()))) < 6; // Added '//' and return false
} Since I don't have an old version of Windows. Kind of thought this was fixed in #469. This can also be fixed by IsWindowsXpOrGreater |
Are you using clang with MSVC like interface or gnu-like? I did a fix for some of the MSVC like, but there's still outstanding work I plan on resolving. Also we don't need to worry about the config header changes as we removed those typedefs in master. They only matter for 2.x versions, and I think 2.6.x should have them. Edit Seems we opted to just disable warnings as errors for the build to at least pass for 2.6.x & master. I'll take another look this weekend at improving this situation, we can probably resolve these in SFML3 at least. |
Right how can I check this? I'm thinking gnu-like cause it uses dashes ( |
Thanks, yeah that was part of the work I hadn't got around to resolving. Well now I have a motivation! You could open a PR with those changes for 2.6.x, I'll happily test & review it. I believe there was more to resolve, but your initial changes may be enough to get us past hurdle 1. We don't have a CI clang++ on Windows so that may block progress, but we can probably overcome that quickly. |
Alright, so hurdle 2 being the deprecation warnings? Cause if so, it'll take me a bit longer and/or maybe should be in a different PR? Also not sure how to fix those since there are two possible solutions (one being the |
I think we had discussions about the deprecation warnings, some of them may be solveable within 2.6.x, some maybe not and we can't get over them in that version but can in master. But I'm not 100% certain, I think the question of how we get all this work done, where it all goes and how many PRs probably needs some insight from a maintainer so I'll tag the usual suspects @eXpl0it3r @ChrisThrasher |
Ignore deprecation warnings for now. Use the |
I will try and make a PR somewhere this week to disable the deprecated errors to the 2.6.x branch then |
Sorry for all the fuzz, just let me know once the CI job is up and running if you want me to look into the issue. |
Don't worry, I think we could've been a bit more clear on what needs to be done. Looking at it, it seems that the latest VS version 17.4 ships with Clang 15, while the VS version 17.3, which is currently shipped with the Windows image, ships with Clang 14. So as of right now, we can't really setup a "new" CI, unless we manually install VS 17.4, which most likely takes too long for a CI process. I'm a bit confused, as SFML seems to build fine for me despite having the
|
Yea... I'm sorry, I didn't know about the CMake option at all, but yes adding |
I'm curious, how are you building SFML? When using the ClangCL frontend we disable that option already, so you must be using Clang in a different way. How exactly? |
They're not using the MSVC-like clang interface, they are using the GNU-like one. The GNU one uses GCC like flags ( |
I submitted #2293 which is a step towards better Windows Clang support. I plan on doing something similar once an GNU-like Clang Windows CI job is added. If someone could build this with GNU-like Clang and let me know what happens, I would really appreciate that. |
Can the Windows Clang users test PR #2293 and tell me if it fixes your build issues? I think I've fixed both the clang-cl.exe and the clang.exe builds. Thank you! |
Will check in a sec |
I should clarify that I'm fixing the |
Just cloned the master branch, compiling with clang15 gives:
|
The fixes aren't merged yet. See the PR I linked and use that branch instead. |
Oh god I'm stupid |
Tested it, works, thanks! |
I just merged #2293 which should fix the Clang Windows builds for anyone using SFML 3! I'll see what I can do about fixing it in 2.6.x as well. |
Please try out #2294 to see if it fixes the issues with the 2.6.x build. |
Hmm, I checked out at |
https://github.com/ChrisThrasher/SFML/actions/runs/3670457670/jobs/6205007134 We're trying to add a Clang Windows CI job but we're getting a link error when consuming SFML in static release builds. Perhaps your error was similar? Hopefully we can sort this out but it's unclear what the cause of the problem is right now. |
With the merging of #2294, I believe all Clang-on-Windows build errors are fixed. I'm going to leave this issue open for a few more days in case we missed something but I believe this issue has been addressed. We hope to add new CI jobs to the pipeline such that future issues don't creep back into SFML. Sorry for the long time to get this fixed but thanks for reporting it! |
The link error looked very similar but IIRC didn't have anything to do with mismatching release/debug configurations. I just tried out to compile the 2.6.x branch from scratch and didn't have any problems with it so I guess it's fixed. |
SFML 3 will be getting some Clang.exe CI jobs so we never introduce more of these build issues ever again. We 鉂わ笍 our Windows + Clang users. |
I believe everything in this thread has been addressed now so I'm closing this. Please let us know if you encounter any more issues with Clang and Windows! |
Thanks for raising your issue here! 馃檪
Before you submit the issue however, we'd like you to consider the follow points.
Subject of the issue
While I have been constructing a minimal example for another issue (with
sf::String
s and wide strings), I noticed there were problems with building SFML 2.6 & 3.0 when using non-MSVC compilers (soMinGWand both Clang-like command-lines (clang-cl.exe
&clang++.exe
))Your environment
Your OS / distro / window manager used: Windows 10, 64bit, build 21H2
Your version of SFML (2.5.0, git master, etc): 2.6 (branch
2.6.x
, tag3315456dc32e2da000145bb7f97083154806b59b
) and 3.0 (branchmaster
, tag5c9b571c70eeb0171affbce08b005a1d65765115
)Your compiler and compiler version used: Clang and MinGW (GNU 11.2.0, bundled with CLion)
Clang versions:
Special compiler flags used: none
Steps to reproduce
Here is the ZIP archive I used for both text and build tests (the standard is set to C++17): SFMLTest.zip
MD5 Checksum:
4c99ca98215ccc919181fd2dd8d24c79
Here is just the
main.cpp
without any resources:Expected behavior
The code compiles successfully and creates a window with a text.
Actual behavior
2.6
MinGW
Compiles successfully (AND works correctly)
MSVC
Compiles successfully (with runtime wide string issues, see
Notes
)Clang with MinGW-like command-line
Clang with MSVC-like command-line
3.0
MinGW
Compiles, but exits withProcess finished with exit code -1073741819 (0xC0000005)
The debugger gives points, but gives an exception:
Exception: Exception 0xc0000005 encountered at address 0x500e178c: User-mode data execution prevention (DEP) violation at location 0x500e178c
After another rebuild, for whatever reason started working.
MSVC
Compiles successfully (with runtime wide string issues, see
Notes
)Clang with MinGW-like command-line
Clang with MSVC-like command-line
Compiles, but exits with
Exception 0xc0000005 encountered at address 0x500e178c: User-mode data execution prevention (DEP) violation at location 0x500e178c
.Debugger shows this:
Bonus: MSVC and Clang with MSVC-like command-line with
-std:c++latest
3.0
MSVC
#2039
Clang with MSVC-like command-line
Same problem as with C++17 (access violation).
2.6
MSVC
Compiles successfully (with runtime wide string issues, see
Notes
)Clang with MSVC-like command-line
Does not have such a flag (??)
Notes
sf::String
s and wide strings (std::wstring
)聽#2047The text was updated successfully, but these errors were encountered: