-
Notifications
You must be signed in to change notification settings - Fork 7
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 support for the clang compiler on Windows (v18) #138
Conversation
7702939
to
e97489c
Compare
Thank's a lot for the PR and the kind words! 🙂 Unfortunately I am a little bit busy at the moment, but I will go through the changes as soon as I find time for it. With regards to Linux, I have a branch for WSL-support. Unfortunately I could not get GCC to work with stacktrace yet, which I (maybe overhasty) added to the exceptions. Also WSL has this annoying bug, where it does not work if the filesystem is split over multiple physical drives, which is my setup on both systems I have access to. So I put this aside for now with the intention of coming back to it, after GCC fully supports stacktrace. |
I've tested compiling this on my side for now and it works fine. I took the liberty to fix the target triplets and remove an obsolete warning from the build script. x64 builds run through successfully for me. Interestingly, it appears that issue #136 is resolved by this PR, though I am not sure if it's due to the drive-by changes or if it hints to some invalid code generation on the MSVC side yet. However, I couldn't get x86 builds to compile, probably due to my lack of knowledge (I haven't touched clang much before). I have built everything from console, so vcvars must be setup properly (even when building with MSVC). However after this I am no longer able to configure the project. I will give this another try later. In the meantime, could you maybe see if you get it working? Is there anything we need to document with regards to cross-compiling using clang? And does this also affect CI? |
No problem for the delay! We all have other things to do! Regarding Linux, it seems gcc14 added full support for std::stacktrace |
I found out why it was not building in x86. 2 main reasons so far:
The error looks like this:
So, here are the solutions I think about:
I'm more and more curious why you are supporting 32bit despite all bugs and extra work it can cause, for not much benefit I think. |
55eb38b
to
9cfb138
Compare
Thanks for checking. 🙂 I can repro the same issue and I think I've encountered this before. Somehow coroutines break codegen for x86 builds. This even happened on some occasions with MSVC, but I thought I fixed all of them. Still I am not sure if this is undefined behaviour or a compiler issue. It's a bit strange that this only affects x86 release builds, though. Anyway, I believe this will fix itself in the future, as I plan to replace Regarding stacktrace in GCC - there's partial support. You still have to link the libc++exp lib manually, which I wasn't able to get to work (at least in WSL using Ubuntu 24). It's not high on my priority list, but it's there. I will see if I find time to review the rest of the changes later this week to get the PR to merge. I really appreciate your efforts, thanks again! 😊 |
I think I will remove clang x86 presets, so it can't be broken... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got some minor nitpicks, but overall this looks good to me. If you resolve the changes, I am happy to merge the PR. As discussed, please also remove the x86 clang presets (we'll create a follow-up issue after the PR is merged) and document this in the readme (e.g. clang (x64 only)). Regarding the size_t
literal, you don't need to change anything just yet. It isn't supported in MSVC yet and will only be required for working x86 builds in the future. I will test the CI changes in a private repo and update them later. Thanks again! ☺
I think l will make the changes next week when I have time to ! Thanks for your review ! |
This fixes the following errors: - error: 'nodiscard' attribute cannot be applied to types - warning: expected a qualified name after 'typename'
This fixes the following errors: - warning: 'dllexport' attribute only applies to functions, variables, classes, and Objective-C interfaces [-Wignored-attributes]
This fixes the following errors: - error: initialization of incomplete type 'AppBuilder' - warning: 'dllexport' attribute only applies to functions, variables, classes, and Objective-C interfaces [-Wignored-attributes]
The following errors were fixed: - warning: 'dllexport' attribute only applies to functions, variables, classes, and Objective-C interfaces[-Wignored-attributes]
This fixes the following errors: - error: 'nodiscard' attribute cannot be applied to types - error: constexpr function's 3rd parameter type 'RenderTarget' is not a literal type - warning: enumeration value 'Other' not handled in switch [-Wswitch] - warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted] - warning: 'dllexport' attribute only applies to functions, variables, classes, and Objective-C interfaces [-Wignored-attributes] The assignments operators are implictly deleted since the class has a non copy assignable or a non move assignable member. This can be a const& or an Enumerable.
Fixes the following errors: - error: expected value in expression - error: template specialization requires 'template<>' - error: too few argument sprovided to function-like macro invocation For the last error (__cpuid), see: nothings/stb#978
Problem: When compiling any backend, calls to the constructor of ArgumentOutOfRangeException fails due to an ambiguous constructor. One error message: error: call to constructor of 'ArgumentOutOfRangeException' is ambiguous 166 | throw ArgumentOutOfRangeException("buffer", 0ull, buffer->size(), offset + requiredMemory, "The buffer does not contain enough memory after offset {0} to fully contain the acceleration structure.", offset); note: candidate constructor [with T = unsigned long long, TArgs = <unsigned long long &>] 143 | explicit ArgumentOutOfRangeException(std::string_view argument, T fromIncluse, T toExclusive, T value, std::string_view format, TArgs&&... args) noexcept note: candidate constructor [with TArgs = <unsigned long long, unsigned long long, const char (&)[104], unsigned long long &>] 129 | explicit ArgumentOutOfRangeException(std::string_view argument, std::string_view format, TArgs&&... args) noexcept Solution: Use a std::pair fo the value range, it allows to desambiguous the ctors since it's now an explicit type.
c8b94ba
to
fcbf8d6
Compare
The following errors were fixed: - error: virtual function 'XX' has more than one final overrider in 'XX' - error: constraints not satisfied for class template 'XX' - error: enumeration value 'Other' not handled in switch [-Wswitch] - error: alias template 'Tuple' requires template arguments; argument deduction only allowed for class templates - warning: 'EnumeratePushConstants' is deprecated: This symbol is deprecated. Details: Renamed to EnumeratePushConstantBlocks [-Wdeprecated-declarations] - warning: brace elision for designated initializer is a C99 extension [-Wc99-designator] - warning: X enumeration values not handled in switch
We declare vulkan symbols as extern everywhere but nevver define it in a compilation unit. So, the linker complains about undefined extern symbols.
- error: virtual function 'XX' has more than one final overrider in 'XX' - error: constraints not satisfied for class template 'XX' - error: alias template 'Tuple' requires template arguments; argument deduction only allowed for class templates - warning: brace elision for designated initializer is a C99 extension [-Wc99-designator] - warning: X enumeration values not handled in switch - warning: using the result of an assignment as a condition without parentheses [-Wparentheses] - warning: extra tokens at end of #endif directive [-Wextra-tokens] - warning: function previously declared with an implicit exception specification redeclared with an explicit exception specification [-Wimplicit-exception-spec-mismatch]
When compiling the any backend, we have the following error: error: member access into incomplete type 'LiteFX::Rendering::Backends::XBuilder' So, in order to fix it, we reorder builder classes so the parent builders are below the child ones.
Builder holding a pointer to a type with a non constexpr constructor cannot be constexpr.
Applies C++ core guidelines C1.28: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines.html#Rh-override
fcbf8d6
to
5d2a23c
Compare
I squashed your doc commit and fixed all review comments. |
LGTM! I've fixed some places where indentation got too deep (probably caused by this issue). I am going to merge the PR and check if the builds are successful. If so I will include clang to build in weekly builds as well as (future) test and release builds (#129). Thank you! 🙂 |
Describe the pull request
This adds support for compiling the engine using the latest clang compiler (v18).
This is a good step for more adoption, since not all projects only use msvc.
It will also help porting to linux, since clang is stricter and more standard compliant, which will ease the compilation with GCC.
I was not able to test CI changes, so you may need to run it on the branch, and I will fix it without any problem!
Related issues
There are currently none, but I can create one if needed.
A word for you
First, I would like to thank you for this awesome project. It's just the best rendering engine I could find using modern C++!
I made some changes here I'm not a fan with (removing some constexprs). As much as I love those things, they are just not possible, and msvc just allows it wrongfully.
Thank you also for the time you take to read this, and review this if you are interested in it!