string GetSharedArguments_Global(CppConfiguration Configuration, bool bOptimizeForSize, string Architecture, bool bEnableShadowVariableWarnings, bool bShadowVariableWarningsAsErrors, bool bEnableUndefinedIdentifierWarnings, bool bUndefinedIdentifierWarningsAsErrors, bool bUseInlining, bool bUE423_OSX_LinkerFix = false) { string Result = " "; // string Result = " -Werror"; Result += " -fdiagnostics-format=msvc"; Result += " -fno-exceptions"; Result += " -Wdelete-non-virtual-dtor"; Result += " -Wno-switch"; // many unhandled cases Result += " -Wno-tautological-constant-out-of-range-compare"; // comparisons from TCHAR being a char Result += " -Wno-tautological-compare"; // comparison of unsigned expression < 0 is always false" (constant comparisons, which are possible with template arguments) Result += " -Wno-tautological-undefined-compare"; // pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate Result += " -Wno-inconsistent-missing-override"; // as of 1.35.0, overriding a member function but not marked as 'override' triggers warnings Result += " -Wno-undefined-var-template"; // 1.36.11 Result += " -Wno-invalid-offsetof"; // using offsetof on non-POD types Result += " -Wno-gnu-string-literal-operator-template"; // allow static FNames if (bEnableShadowVariableWarnings) { Result += " -Wshadow"; //+ (bShadowVariableWarningsAsErrors ? "" : " -Wno-error=shadow"); } if (bEnableUndefinedIdentifierWarnings) { Result += " -Wundef"; //+ (bUndefinedIdentifierWarningsAsErrors ? "" : " -Wno-error=undef"); } // -------------------------------------------------------------------------------- if (Configuration == CppConfiguration.Debug) { // WARNING: UEBuildTarget.cs :: GetCppConfiguration() Result += " -O0"; // faster compile time // DebugGame is forced to Development } // i.e. this will never get hit... else if (bOptimizeForSize) { // Engine/Source/Programs/UnrealBuildTool/HTML5/UEBuildHTML5.cs Result += " -Oz"; // favor size over speed // bCompileForSize=true; // set false, to build -O2 or -O3 } // SOURCE BUILD ONLY else if (Configuration == CppConfiguration.Development) { Result += " -O2"; // aggressive size and speed optimization } else if (Configuration == CppConfiguration.Shipping) { if (bUE423_OSX_LinkerFix && (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac)) { // UE-78966 - TEMP HACK - remove this on next EMSCRIPTEN_TOOLCHAIN_UPGRADE_CHECK Result += " -O2"; } else { Result += " -O3"; // favor speed over size } } if (!bUseInlining) { Result += " -fno-inline-functions"; } PrintOnce(Configuration, bOptimizeForSize); // -------------------------------------------------------------------------------- // JavaScript option overrides (see src/settings.js) if (enableSIMD) { // Result += " -msse2 -s SIMD=1"; } if (enableMultithreading) { // Result += " -msse2 -s USE_PTHREADS=1"; Result += " -s USE_PTHREADS=1"; Result += " -DEXPERIMENTAL_OPENGL_RHITHREAD=" + (bMultithreading_UseOffscreenCanvas ? "0" : "1"); // NOTE: use "emscripten native" video, keyboard, mouse } else { // SDL2 is not supported for multi-threading WASM builds // WARNING: SDL2 may be removed in a future UE4 release // can comment out to use "emscripten native" single threaded // Result += " -DHTML5_USE_SDL2"; } if (useLLVMwasmBackend) // experimental - LLVMWasmBackend { Result += " -s WASM_OBJECT_FILES=1"; Environment.SetEnvironmentVariable("EMCC_WASM_BACKEND", "1"); } // -------------------------------------------------------------------------------- // emscripten ports // WARNING: seems emscripten ports cannot be currently used // there might be UE4 changes needed that are found in Engine/Source/ThirdParty/... // Result += " -s USE_ZLIB=1"; // Result += " -s USE_LIBPNG=1"; // Result += " -s USE_VORBIS=1"; // Result += " -s USE_OGG=1"; // Result += " -s USE_FREETYPE=1"; // TAG = 'release_1' // Result += " -s USE_HARFBUZZ=1"; // TAG = '1.2.4 note: path is https://github.com/harfbuzz/harfbuzz/archive/1.2.4.zip // Result += " -s USE_ICU=1"; // TAG = 'release-53-1' // SDL_Audio needs to be linked in [no matter if -DHTML5_USE_SDL2 is used or not] // TODO: remove AudioMixerSDL from Engine/Source/Runtime/Launch/Launch.Build.cs and replace with emscripten native functions // Result += " -s USE_SDL=2"; // -------------------------------------------------------------------------------- // Expect that Emscripten SDK has been properly set up ahead in time (with emsdk and prebundled toolchains this is always the case) // This speeds up builds a tiny bit. Environment.SetEnvironmentVariable("EMCC_SKIP_SANITY_CHECK", "1"); // THESE ARE TEST/DEBUGGING -- TRY NOT TO USE THESE // Environment.SetEnvironmentVariable("EMCC_DEBUG", "1"); // NOTE: try to use -v instead of EMCC_DEBUG // Environment.SetEnvironmentVariable("EMCC_DEBUG_SAVE", "1"); // very useful for compiler bughunts // Environment.SetEnvironmentVariable("EMCC_CORES", "8"); // Environment.SetEnvironmentVariable("EMCC_OPTIMIZE_NORMALLY", "1"); // enable verbose mode // Result += " -v"; // useful for path hunting issues if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux) { // Packaging on Linux needs this - or else system clang will be attempted to be picked up instead of UE4's included emsdk Environment.SetEnvironmentVariable(HTML5SDKInfo.PLATFORM_USER_HOME, HTML5SDKInfo.HTML5Intermediatory); } if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64 || BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win32) { // Packaging on Window needs this - zap any existing HOME environment variables to prevent any accidental pick ups Environment.SetEnvironmentVariable("HOME", ""); } if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac) { Environment.SetEnvironmentVariable("LD_LIBRARY_PATH", HTML5SDKInfo.MacPythonLib()); // UE-75402 } return(Result); }