These changes allow UE4 to compile and run (in Debug) on Clang 3.7 alpha (r231657 only!)
- Disabled editor source file discovery (crashes with Clang currently)
- Disabled FThreadIdleStats in UnrealHeaderTool with Clang on Windows (causes link errors due to inlining bugs with Clang and DLL imports)
- Use MSVC linker by default, even when compiling with Clang (can be tweaked with bAllowClangLinker)
- Enabled shadow variable warnings on Windows with Clang
- Limited max size of reflection code source files (Clang on Windows crashes with huge source files)
- Fixed UE4 deprecation warnings not showing up when using Clang on Windows
- Make sure initialization list order only triggers a warning on Clang for Windows
Other changes:
- Fixed issues with pushed pragmas not getting popped (PRAGMA_ENABLE_DEPRECATION_WARNINGS)
- Removed EMIT_DEPRECATED_WARNING_MESSAGE, wasn't used
- Fixed various third party library includes not being treated as system headers (prevents compiler warnings)
To test Clang on Windows (beta!!):
- Get latest UE4 main branch (4.9)
- Install LLVM+Clang for Windows version r231657. It's a quick install, you don't need to compile anything yourself.
- Open UEBuildWindows.cs, and change bCompileWithClang to true. Be careful not to check that in. We'll probably make this config-driven later, after the Clang toolchain gets more mature.
- Switch to Debug Editor configuration. (See below for more info.)
- Rebuild the game or engine
Notes:
- You must use Clang r231657 (3.7.0 alpha). There are no other releases that I've found that are able to compile UE4 successfully. Most of the newer releases crash during compiling, and older releases aren't able to digest Windows header files well enough.
- Compiling in Development currently will not work due to bugs with Clangs handling of inlining and DLL exports. Monolithic builds should work, though.
- Occasionally you may see runtime crashes (stack overflows or access violations) when running UE4 compiled with Clang on Windows. These may very well be bugs in Clang (remember, we're using an alpha release of Clang 3.7.0.) Unfortunately without better debugger support, it can be difficult to workaround these
- When debugging, you will only have functions and line numbers, no variables or parameters. Clang only has preliminary support for Microsoft's PDB format currently.
XGE is fully supported with Clang on Windows. Best case rebuild times I've seen are 3.5 minutes in Debug.
- Shared PCHs aren't supported yet (similar to on Mac and Linux), so iterative compile times may be slower compared to Visual C++. However the Clang compiler is actually quite fast for rebuilds, probably because of missing debug info though.
- There may be some compiler warnings that are different between Mac/Linux and Windows. We haven't done a line-by-line comparison yet.
- Build products and executables for Clang and VC++ overlap on disk. So you have to rebuild to switch back and forth. Sorry.
- Clang on Windows has a few bugs that we've had to work around. You might see some strange things from time to time. Every new release of Clang has different behavior on Windows.
- We still use the VC++ Linker, even when compiling using Clang. The new Clang linker (lld.exe) can be enabled with bAllowClangLinker but it will crash when linking some modules. It also doesn't produce usable debug symbols by Visual Studio (yet).
#codereview mikolaj.sieluzycki
[CL 2532260 by Mike Fricker in Main branch]
Bunch of extra checks for this kind of failure in future.
Some scope bracing fixes.
#codereview robert.manuszewski
[CL 2531944 by Steve Robb in Main branch]
Introduce versioning system to GENERATED_*BODY macros
Search for existing functions using case sensitive and whole word match.
Move checks for existing of *_Validate and *_Implementation functions to *generated.cpp to allow changing that code in hotfixes.
#codereview Robert.Manuszewski
[CL 2508131 by Mikolaj Sieluzycki in Main branch]
- Optimized Tabify and Macroize
- Replaced various %s Spc(constant) calls with direct string literals
- Replaced injected indentation spaces with tabs (avoiding some of the work in Tabify; they were ultimately being replaced anyways)
- Replaced various %s of LINE_TERMINATOR with compile-time string literal concatenation
- Avoided case-insensitive work in various places
- Replaced direct references to FStringOutputDevice with a typedef to facilitate future optimizations
- Used Reset() instead of Empty() on various string builders and strings to reduce reallocations
[INTEGRATE] Change 2494450 by Michael.Noland@mnoland-T2784-HDepot on 2015/03/27 16:48:25
[CL 2494606 by Michael Noland in Main branch]
This will not fix warnings for UObject classes that implement legacy C++ interfaces for which we generate code (GENERATED_IINTERFACE_BODY), because, as far as I can tell, the code generator is currently not able to detect those cases. For example: class UFont : public UObject, public IFontProviderInterface --- IFontProviderInterface gets a _getUObject() injected, but we cannot detect this in the code generation for UFont. Some more work is needed here. It might be better to simply always generate _getUObject() for all classes, so that there are no weird special cases.
#CodeReview: steve.robb, dmitry.rekman
[CL 2492772 by Max Preussner in Main branch]
Slate Widget was failing, because of missing Slate dependencies. Testing introduced a couple of problems which all was fixed by this CL:
1. I introduced AdditionalDependencies in .uproject file and change "Add Code To Project..." procedure to fill this array if needed. UBT reads this field and builds the project with required modules. Needed for Slate classes.
2. Changed UHT to #include missing headers in generated.h files if it was missing an include for it's super class. It was causing problems if we were trying to add a subclass of BrushShape -- BrushShape.h didn't have #include "Brush.h" and UBrushShape was inheriting from UBrush.
3. Above problems also occured for Slate classes, but not all of them was UCLASSes, so I had to fixed that manually.
4. "Add Code To Project..." functionality was not invalidating UBT makefiles, which lead to omitting new source files during hot-reloading (even thought it was reporting a success). This change also should improve a bit performance, cause right now there is no "gathering" step -- there is only invalidate step which is a lot quicker.
5. Fixed "Selected Class Source" link to source class in Slate Widget and Slate Widget Style class.
#codereview Robert.Manuszewski
[CL 2481488 by Jaroslaw Palczynski in Main branch]