2019-12-26 23:01:54 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
using System ;
using System.Collections.Generic ;
using System.Text ;
using System.Diagnostics ;
using System.IO ;
2020-12-21 23:07:37 -04:00
using EpicGames.Core ;
2017-12-14 10:07:13 -05:00
using System.Text.RegularExpressions ;
2021-06-09 12:54:42 -04:00
using UnrealBuildBase ;
2014-03-14 14:13:41 -04:00
2020-12-20 17:32:59 -04:00
#nullable disable
2014-07-17 13:49:42 -04:00
namespace UnrealBuildTool
2014-03-14 14:13:41 -04:00
{
2017-01-30 16:52:08 -05:00
/** Architecture as stored in the ini. */
enum LinuxArchitecture
{
/** x86_64, most commonly used architecture.*/
X86_64UnknownLinuxGnu ,
/** A.k.a. AArch32, ARM 32-bit with hardware floats */
ArmUnknownLinuxGnueabihf ,
2021-06-14 13:39:47 -04:00
/** Arm64, ARM 64-bit */
2017-03-10 15:37:02 -05:00
AArch64UnknownLinuxGnueabi ,
/** i686, Intel 32-bit */
I686UnknownLinuxGnu
2017-01-30 16:52:08 -05:00
}
2018-09-12 15:59:49 -04:00
/// <summary>
/// Linux-specific target settings
/// </summary>
2021-01-11 21:17:03 -04:00
public partial class LinuxTargetRules
2018-09-12 15:59:49 -04:00
{
/// <summary>
/// Constructor
/// </summary>
public LinuxTargetRules ( )
{
XmlConfig . ApplyTo ( this ) ;
}
/// <summary>
/// Enables address sanitizer (ASan)
/// </summary>
[CommandLine("-EnableASan")]
[XmlConfigFile(Category = "BuildConfiguration", Name = "bEnableAddressSanitizer")]
public bool bEnableAddressSanitizer = false ;
/// <summary>
/// Enables thread sanitizer (TSan)
/// </summary>
[CommandLine("-EnableTSan")]
[XmlConfigFile(Category = "BuildConfiguration", Name = "bEnableThreadSanitizer")]
public bool bEnableThreadSanitizer = false ;
/// <summary>
/// Enables undefined behavior sanitizer (UBSan)
/// </summary>
[CommandLine("-EnableUBSan")]
[XmlConfigFile(Category = "BuildConfiguration", Name = "bEnableUndefinedBehaviorSanitizer")]
public bool bEnableUndefinedBehaviorSanitizer = false ;
2018-09-25 10:11:35 -04:00
2020-01-27 16:57:24 -05:00
/// <summary>
2020-01-27 16:38:57 -05:00
/// Enables memory sanitizer (MSan)
/// </summary>
[CommandLine("-EnableMSan")]
[XmlConfigFile(Category = "BuildConfiguration", Name = "bEnableMemorySanitizer")]
public bool bEnableMemorySanitizer = false ;
2019-02-18 19:44:39 -05:00
/// <summary>
/// Enables "thin" LTO
/// </summary>
[CommandLine("-ThinLTO")]
public bool bEnableThinLTO = false ;
2018-09-25 10:11:35 -04:00
/// <summary>
/// Whether or not to preserve the portable symbol file produced by dump_syms
/// </summary>
[ConfigFile(ConfigHierarchyType.Engine, "/Script/LinuxPlatform.LinuxTargetSettings")]
public bool bPreservePSYM = false ;
2018-09-12 15:59:49 -04:00
}
/// <summary>
/// Read-only wrapper for Linux-specific target settings
/// </summary>
2021-01-11 21:17:03 -04:00
public partial class ReadOnlyLinuxTargetRules
2018-09-12 15:59:49 -04:00
{
/// <summary>
/// Accessors for fields on the inner TargetRules instance
/// </summary>
2018-11-19 07:03:18 -05:00
#region Read - only accessor properties
#pragma warning disable CS1591
2018-09-12 15:59:49 -04:00
2018-09-25 10:11:35 -04:00
public bool bPreservePSYM
{
get { return Inner . bPreservePSYM ; }
}
2018-09-12 15:59:49 -04:00
public bool bEnableAddressSanitizer
{
get { return Inner . bEnableAddressSanitizer ; }
}
public bool bEnableThreadSanitizer
{
get { return Inner . bEnableThreadSanitizer ; }
}
public bool bEnableUndefinedBehaviorSanitizer
{
get { return Inner . bEnableUndefinedBehaviorSanitizer ; }
}
2020-01-27 16:38:57 -05:00
public bool bEnableMemorySanitizer
{
get { return Inner . bEnableMemorySanitizer ; }
}
2019-02-18 19:44:39 -05:00
public bool bEnableThinLTO
{
get { return Inner . bEnableThinLTO ; }
}
2018-11-19 07:03:18 -05:00
#pragma warning restore CS1591
#endregion
2018-09-12 15:59:49 -04:00
}
2017-01-30 16:52:08 -05:00
class LinuxPlatform : UEBuildPlatform
{
/// <summary>
2019-09-14 09:45:25 -04:00
/// Linux host architecture (compiler target triplet)
2017-01-30 16:52:08 -05:00
/// </summary>
2019-09-14 09:45:25 -04:00
public const string DefaultHostArchitecture = "x86_64-unknown-linux-gnu" ;
2017-01-30 16:52:08 -05:00
2018-05-04 14:14:10 -04:00
/// <summary>
/// SDK in use by the platform
/// </summary>
protected LinuxPlatformSDK SDK ;
2017-01-30 16:52:08 -05:00
/// <summary>
/// Constructor
/// </summary>
2018-03-21 11:09:41 -04:00
public LinuxPlatform ( LinuxPlatformSDK InSDK )
2019-05-24 11:51:54 -04:00
: this ( UnrealTargetPlatform . Linux , InSDK )
2018-03-21 11:09:41 -04:00
{
SDK = InSDK ;
}
2019-05-24 11:51:54 -04:00
public LinuxPlatform ( UnrealTargetPlatform UnrealTarget , LinuxPlatformSDK InSDK )
2020-06-22 14:32:25 -04:00
: base ( UnrealTarget , InSDK )
2017-01-30 16:52:08 -05:00
{
SDK = InSDK ;
}
/// <summary>
/// Find the default architecture for the given project
/// </summary>
public override string GetDefaultArchitecture ( FileReference ProjectFile )
{
2021-06-14 13:39:47 -04:00
if ( Platform = = UnrealTargetPlatform . LinuxArm64 )
2016-11-21 20:27:58 -05:00
{
2019-09-14 09:45:25 -04:00
return "aarch64-unknown-linux-gnueabi" ;
2016-11-21 20:27:58 -05:00
}
2019-09-14 09:45:25 -04:00
else
2016-11-21 20:27:58 -05:00
{
2019-09-14 09:45:25 -04:00
return "x86_64-unknown-linux-gnu" ;
2016-11-21 20:27:58 -05:00
}
2015-09-24 12:37:21 -04:00
}
2014-03-14 14:13:41 -04:00
2015-11-24 16:45:24 -05:00
/// <summary>
/// Get name for architecture-specific directories (can be shorter than architecture name itself)
/// </summary>
2017-01-30 16:52:08 -05:00
public override string GetFolderNameForArchitecture ( string Architecture )
2015-11-24 16:45:24 -05:00
{
// shorten the string (heuristically)
uint Sum = 0 ;
2017-01-30 16:52:08 -05:00
int Len = Architecture . Length ;
2015-11-24 16:45:24 -05:00
for ( int Index = 0 ; Index < Len ; + + Index )
{
2017-01-30 16:52:08 -05:00
Sum + = ( uint ) ( Architecture [ Index ] ) ;
2015-11-24 16:45:24 -05:00
Sum < < = 1 ; // allowed to overflow
}
return Sum . ToString ( "X" ) ;
}
2017-01-30 16:52:08 -05:00
public override void ResetTarget ( TargetRules Target )
2015-09-29 10:44:49 -04:00
{
2017-01-30 16:52:08 -05:00
ValidateTarget ( Target ) ;
2015-09-29 10:44:49 -04:00
}
2017-01-30 16:52:08 -05:00
public override void ValidateTarget ( TargetRules Target )
2019-01-11 04:11:30 -05:00
{
2019-02-18 19:44:39 -05:00
if ( Target . LinuxPlatform . bEnableThinLTO )
{
Target . bAllowLTCG = true ;
}
2020-06-23 18:40:00 -04:00
if ( ! Target . IsNameOverriden ( ) )
{
string SanitizerSuffix = null ;
if ( Target . LinuxPlatform . bEnableAddressSanitizer )
{
SanitizerSuffix = "ASan" ;
}
else if ( Target . LinuxPlatform . bEnableThreadSanitizer )
{
SanitizerSuffix = "TSan" ;
}
else if ( Target . LinuxPlatform . bEnableUndefinedBehaviorSanitizer )
{
SanitizerSuffix = "UBSan" ;
}
else if ( Target . LinuxPlatform . bEnableMemorySanitizer )
{
SanitizerSuffix = "MSan" ;
}
if ( ! String . IsNullOrEmpty ( SanitizerSuffix ) )
{
Target . Name = Target . Name + "-" + SanitizerSuffix ;
}
}
2019-01-11 04:11:30 -05:00
if ( Target . bAllowLTCG & & Target . LinkType ! = TargetLinkType . Monolithic )
{
throw new BuildException ( "LTO (LTCG) for modular builds is not supported (lld is not currently used for dynamic libraries)." ) ;
}
2016-11-21 20:27:58 -05:00
// depends on arch, APEX cannot be as of November'16 compiled for AArch32/64
2021-05-13 16:06:24 -04:00
Target . bCompileAPEX = Target . bCompileAPEX & & Target . Architecture . StartsWith ( "x86_64" ) ;
Target . bCompileNvCloth = Target . bCompileNvCloth & & Target . Architecture . StartsWith ( "x86_64" ) ;
2017-01-30 16:52:08 -05:00
if ( Target . GlobalDefinitions . Contains ( "USE_NULL_RHI=1" ) )
2019-01-09 06:58:40 -05:00
{
2017-08-01 15:55:31 -04:00
Target . bCompileCEF3 = false ;
2017-01-30 16:52:08 -05:00
}
2017-08-01 15:55:31 -04:00
// check if OS update invalidated our build
Target . bCheckSystemHeadersForModification = ( BuildHostPlatform . Current . Platform = = UnrealTargetPlatform . Linux ) ;
2021-04-08 14:32:07 -04:00
Target . bCompileISPC = true ;
2015-09-30 16:40:04 -04:00
}
/// <summary>
/// Allows the platform to override whether the architecture name should be appended to the name of binaries.
/// </summary>
/// <returns>True if the architecture name should be appended to the binary</returns>
public override bool RequiresArchitectureSuffix ( )
{
// Linux ignores architecture-specific names, although it might be worth it to prepend architecture
2015-09-25 08:37:49 -04:00
return false ;
}
2015-09-30 16:40:04 -04:00
public override bool CanUseXGE ( )
{
2018-05-04 14:14:10 -04:00
// [RCL] 2018-05-02: disabling XGE even during a native build because the support is not ready and you can have mysterious build failures when ib_console is installed.
2018-07-10 10:31:59 -04:00
// [RCL] 2018-07-10: enabling XGE for Windows to see if the crash from 2016 still persists. Please disable if you see spurious build errors that don't repro without XGE
2018-08-24 13:38:30 -04:00
// [bschaefer] 2018-08-24: disabling XGE due to a bug where XGE seems to be lower casing folders names that are headers ie. misc/Header.h vs Misc/Header.h
2019-01-07 05:38:46 -05:00
// [bschaefer] 2018-10-04: enabling XGE as an update in xgConsole seems to have fixed it for me
// [bschaefer] 2018-12-17: disable XGE again, as the same issue before seems to still be happening but intermittently
2019-07-18 15:53:24 -04:00
// [bschaefer] 2019-6-13: enable XGE, as the bug from before is now fixed
return BuildHostPlatform . Current . Platform = = UnrealTargetPlatform . Win64 ;
2015-09-30 16:40:04 -04:00
}
2018-05-23 21:04:31 -04:00
public override bool CanUseParallelExecutor ( )
{
// No known problems with parallel executor, always use for build machines
return true ;
}
2017-08-31 12:08:38 -04:00
/// <summary>
/// Determines if the given name is a build product for a target.
/// </summary>
/// <param name="FileName">The name to check</param>
2020-09-10 15:39:00 -04:00
/// <param name="NamePrefixes">Target or application names that may appear at the start of the build product name (eg. "UnrealEditor", "ShooterGameEditor")</param>
2017-08-31 12:08:38 -04:00
/// <param name="NameSuffixes">Suffixes which may appear at the end of the build product name</param>
/// <returns>True if the string matches the name of a build product, false otherwise</returns>
public override bool IsBuildProduct ( string FileName , string [ ] NamePrefixes , string [ ] NameSuffixes )
{
if ( FileName . StartsWith ( "lib" ) )
{
return IsBuildProductName ( FileName , 3 , FileName . Length - 3 , NamePrefixes , NameSuffixes , ".a" )
2019-07-19 14:27:23 -04:00
| | IsBuildProductName ( FileName , 3 , FileName . Length - 3 , NamePrefixes , NameSuffixes , ".so" )
| | IsBuildProductName ( FileName , 3 , FileName . Length - 3 , NamePrefixes , NameSuffixes , ".sym" )
| | IsBuildProductName ( FileName , 3 , FileName . Length - 3 , NamePrefixes , NameSuffixes , ".debug" ) ;
2017-08-31 12:08:38 -04:00
}
else
{
return IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , "" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".so" )
2019-07-19 14:27:23 -04:00
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".a" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".sym" )
| | IsBuildProductName ( FileName , NamePrefixes , NameSuffixes , ".debug" ) ;
2017-08-31 12:08:38 -04:00
}
}
2015-09-30 16:40:04 -04:00
/// <summary>
/// Get the extension to use for the given binary type
/// </summary>
/// <param name="InBinaryType"> The binary type being built</param>
/// <returns>string The binary extension (i.e. 'exe' or 'dll')</returns>
public override string GetBinaryExtension ( UEBuildBinaryType InBinaryType )
{
switch ( InBinaryType )
{
case UEBuildBinaryType . DynamicLinkLibrary :
return ".so" ;
case UEBuildBinaryType . Executable :
return "" ;
case UEBuildBinaryType . StaticLibrary :
return ".a" ;
}
return base . GetBinaryExtension ( InBinaryType ) ;
}
/// <summary>
2018-05-04 14:14:10 -04:00
/// Get the extensions to use for debug info for the given binary type
2015-09-30 16:40:04 -04:00
/// </summary>
2017-01-30 16:52:08 -05:00
/// <param name="InTarget">Rules for the target being built</param>
2015-09-30 16:40:04 -04:00
/// <param name="InBinaryType"> The binary type being built</param>
2018-05-04 14:14:10 -04:00
/// <returns>string[] The debug info extensions (i.e. 'pdb')</returns>
public override string [ ] GetDebugInfoExtensions ( ReadOnlyTargetRules InTarget , UEBuildBinaryType InBinaryType )
2015-09-30 16:40:04 -04:00
{
2018-05-04 14:14:10 -04:00
switch ( InBinaryType )
{
case UEBuildBinaryType . DynamicLinkLibrary :
case UEBuildBinaryType . Executable :
2018-09-25 10:11:35 -04:00
if ( InTarget . LinuxPlatform . bPreservePSYM )
{
return new string [ ] { ".psym" , ".sym" , ".debug" } ;
}
else
{
return new string [ ] { ".sym" , ".debug" } ;
}
2018-05-04 14:14:10 -04:00
}
return new string [ ] { } ;
2015-09-30 16:40:04 -04:00
}
/// <summary>
/// Modify the rules for a newly created module, where the target is a different host platform.
/// This is not required - but allows for hiding details of a particular platform.
/// </summary>
/// <param name="ModuleName">The name of the module</param>
/// <param name="Rules">The module rules</param>
/// <param name="Target">The target being build</param>
2017-01-30 16:52:08 -05:00
public override void ModifyModuleRulesForOtherPlatform ( string ModuleName , ModuleRules Rules , ReadOnlyTargetRules Target )
2015-09-30 16:40:04 -04:00
{
2019-12-06 09:16:21 -05:00
// don't do any target platform stuff if SDK is not available
2021-04-29 19:32:06 -04:00
if ( ! UEBuildPlatform . IsPlatformAvailableForTarget ( Platform , Target ) )
2019-12-06 09:16:21 -05:00
{
return ;
}
2020-05-22 09:57:29 -04:00
if ( Target . Platform = = UnrealTargetPlatform . Win64 )
2015-09-30 16:40:04 -04:00
{
2017-01-30 16:52:08 -05:00
if ( ! Target . bBuildRequiresCookedData )
2015-09-30 16:40:04 -04:00
{
if ( ModuleName = = "Engine" )
{
2017-01-30 16:52:08 -05:00
if ( Target . bBuildDeveloperTools )
2015-09-30 16:40:04 -04:00
{
2018-01-20 11:19:29 -05:00
Rules . DynamicallyLoadedModuleNames . Add ( "LinuxTargetPlatform" ) ;
2021-06-14 13:39:47 -04:00
Rules . DynamicallyLoadedModuleNames . Add ( "LinuxArm64TargetPlatform" ) ;
2015-09-30 16:40:04 -04:00
}
}
}
// allow standalone tools to use targetplatform modules, without needing Engine
2017-01-30 16:52:08 -05:00
if ( Target . bForceBuildTargetPlatforms & & ModuleName = = "TargetPlatform" )
2015-09-30 16:40:04 -04:00
{
2018-01-20 11:19:29 -05:00
Rules . DynamicallyLoadedModuleNames . Add ( "LinuxTargetPlatform" ) ;
2021-06-14 13:39:47 -04:00
Rules . DynamicallyLoadedModuleNames . Add ( "LinuxArm64TargetPlatform" ) ;
2015-09-30 16:40:04 -04:00
}
}
}
/// <summary>
2017-02-21 15:51:42 -05:00
/// Modify the rules for a newly created module, in a target that's being built for this platform.
/// This is not required - but allows for hiding details of a particular platform.
2015-09-30 16:40:04 -04:00
/// </summary>
2017-02-21 15:51:42 -05:00
/// <param name="ModuleName">The name of the module</param>
/// <param name="Rules">The module rules</param>
/// <param name="Target">The target being build</param>
public override void ModifyModuleRulesForActivePlatform ( string ModuleName , ModuleRules Rules , ReadOnlyTargetRules Target )
2015-09-30 16:40:04 -04:00
{
2017-02-21 15:51:42 -05:00
bool bBuildShaderFormats = Target . bForceBuildShaderFormats ;
if ( ! Target . bBuildRequiresCookedData )
{
if ( ModuleName = = "TargetPlatform" )
{
bBuildShaderFormats = true ;
}
}
// allow standalone tools to use target platform modules, without needing Engine
if ( ModuleName = = "TargetPlatform" )
{
if ( Target . bForceBuildTargetPlatforms )
{
Rules . DynamicallyLoadedModuleNames . Add ( "LinuxTargetPlatform" ) ;
2021-06-14 13:39:47 -04:00
Rules . DynamicallyLoadedModuleNames . Add ( "LinuxArm64TargetPlatform" ) ;
2017-02-21 15:51:42 -05:00
}
if ( bBuildShaderFormats )
{
Rules . DynamicallyLoadedModuleNames . Add ( "ShaderFormatOpenGL" ) ;
2017-04-06 22:03:51 -04:00
Rules . DynamicallyLoadedModuleNames . Add ( "VulkanShaderFormat" ) ;
2020-01-24 18:07:01 -05:00
Rules . DynamicallyLoadedModuleNames . Add ( "ShaderFormatVectorVM" ) ;
2017-02-21 15:51:42 -05:00
}
}
}
2019-10-16 11:53:16 -04:00
public virtual void SetUpSpecificEnvironment ( ReadOnlyTargetRules Target , CppCompileEnvironment CompileEnvironment , LinkEnvironment LinkEnvironment )
2018-03-21 11:09:41 -04:00
{
CompileEnvironment . Definitions . Add ( "PLATFORM_LINUX=1" ) ;
CompileEnvironment . Definitions . Add ( "PLATFORM_UNIX=1" ) ;
CompileEnvironment . Definitions . Add ( "LINUX=1" ) ; // For libOGG
// this define does not set jemalloc as default, just indicates its support
CompileEnvironment . Definitions . Add ( "PLATFORM_SUPPORTS_JEMALLOC=1" ) ;
2019-09-14 09:45:25 -04:00
2021-06-14 13:39:47 -04:00
// LinuxArm64 uses only Linux header files
2019-09-14 09:45:25 -04:00
CompileEnvironment . Definitions . Add ( "OVERRIDE_PLATFORM_HEADER_NAME=Linux" ) ;
2019-10-16 11:53:16 -04:00
2021-06-14 13:39:47 -04:00
CompileEnvironment . Definitions . Add ( "PLATFORM_LINUXARM64=" +
( Target . Platform = = UnrealTargetPlatform . LinuxArm64 ? "1" : "0" ) ) ;
2018-03-21 11:09:41 -04:00
}
2017-02-21 15:51:42 -05:00
/// <summary>
/// Setup the target environment for building
/// </summary>
/// <param name="Target">Settings for the target being compiled</param>
/// <param name="CompileEnvironment">The compile environment for this target</param>
/// <param name="LinkEnvironment">The link environment for this target</param>
public override void SetUpEnvironment ( ReadOnlyTargetRules Target , CppCompileEnvironment CompileEnvironment , LinkEnvironment LinkEnvironment )
{
2017-08-01 15:55:31 -04:00
// During the native builds, check the system includes as well (check toolchain when cross-compiling?)
2018-05-04 14:14:10 -04:00
string BaseLinuxPath = SDK . GetBaseLinuxPathForArchitecture ( Target . Architecture ) ;
if ( BuildHostPlatform . Current . Platform = = UnrealTargetPlatform . Linux & & String . IsNullOrEmpty ( BaseLinuxPath ) )
2017-08-01 15:55:31 -04:00
{
2019-01-14 12:11:24 -05:00
CompileEnvironment . SystemIncludePaths . Add ( new DirectoryReference ( "/usr/include" ) ) ;
2017-08-01 15:55:31 -04:00
}
2019-01-28 17:35:18 -05:00
if ( CompileEnvironment . bPGOOptimize ! = LinkEnvironment . bPGOOptimize )
{
throw new BuildException ( "Inconsistency between PGOOptimize settings in Compile ({0}) and Link ({1}) environments" ,
CompileEnvironment . bPGOOptimize ,
LinkEnvironment . bPGOOptimize
) ;
}
if ( CompileEnvironment . bPGOProfile ! = LinkEnvironment . bPGOProfile )
{
throw new BuildException ( "Inconsistency between PGOProfile settings in Compile ({0}) and Link ({1}) environments" ,
CompileEnvironment . bPGOProfile ,
LinkEnvironment . bPGOProfile
) ;
}
if ( CompileEnvironment . bPGOOptimize )
{
2021-06-11 18:20:44 -04:00
DirectoryReference BaseDir = Unreal . EngineDirectory ;
2019-01-28 17:35:18 -05:00
if ( Target . ProjectFile ! = null )
{
BaseDir = DirectoryReference . FromFile ( Target . ProjectFile ) ;
}
CompileEnvironment . PGODirectory = Path . Combine ( BaseDir . FullName , "Build" , Target . Platform . ToString ( ) , "PGO" ) . Replace ( '\\' , '/' ) + "/" ;
CompileEnvironment . PGOFilenamePrefix = "profile.profdata" ;
LinkEnvironment . PGODirectory = CompileEnvironment . PGODirectory ;
LinkEnvironment . PGOFilenamePrefix = CompileEnvironment . PGOFilenamePrefix ;
}
// For consistency with other platforms, also enable LTO whenever doing profile-guided optimizations.
// Obviously both PGI (instrumented) and PGO (optimized) binaries need to have that
if ( CompileEnvironment . bPGOProfile | | CompileEnvironment . bPGOOptimize )
{
CompileEnvironment . bAllowLTCG = true ;
LinkEnvironment . bAllowLTCG = true ;
}
2017-11-06 18:22:01 -05:00
if ( CompileEnvironment . bAllowLTCG ! = LinkEnvironment . bAllowLTCG )
{
2019-01-11 04:11:30 -05:00
throw new BuildException ( "Inconsistency between LTCG settings in Compile ({0}) and Link ({1}) environments" ,
CompileEnvironment . bAllowLTCG ,
LinkEnvironment . bAllowLTCG
) ;
2017-11-06 18:22:01 -05:00
}
2017-02-21 15:51:42 -05:00
// link with Linux libraries.
2020-04-10 11:30:32 -04:00
LinkEnvironment . SystemLibraries . Add ( "pthread" ) ;
2018-03-21 11:09:41 -04:00
// let this class or a sub class do settings specific to that class
2019-10-16 11:53:16 -04:00
SetUpSpecificEnvironment ( Target , CompileEnvironment , LinkEnvironment ) ;
2017-02-21 15:51:42 -05:00
}
/// <summary>
/// Whether this platform should create debug information or not
/// </summary>
/// <param name="Target">The target being built</param>
/// <returns>bool true if debug info should be generated, false if not</returns>
public override bool ShouldCreateDebugInfo ( ReadOnlyTargetRules Target )
{
switch ( Target . Configuration )
{
case UnrealTargetConfiguration . Development :
case UnrealTargetConfiguration . Shipping :
case UnrealTargetConfiguration . Test :
case UnrealTargetConfiguration . Debug :
default :
return true ;
} ;
}
/// <summary>
/// Creates a toolchain instance for the given platform.
/// </summary>
/// <param name="Target">The target being built</param>
/// <returns>New toolchain instance.</returns>
2019-05-24 11:51:54 -04:00
public override UEToolChain CreateToolChain ( ReadOnlyTargetRules Target )
2017-02-21 15:51:42 -05:00
{
2018-09-12 15:59:49 -04:00
LinuxToolChainOptions Options = LinuxToolChainOptions . None ;
2020-06-23 18:40:00 -04:00
if ( Target . LinuxPlatform . bEnableAddressSanitizer )
2018-09-12 15:59:49 -04:00
{
Options | = LinuxToolChainOptions . EnableAddressSanitizer ;
2020-01-27 16:38:57 -05:00
if ( Target . LinkType ! = TargetLinkType . Monolithic )
{
Options | = LinuxToolChainOptions . EnableSharedSanitizer ;
}
2018-09-12 15:59:49 -04:00
}
2020-06-23 18:40:00 -04:00
if ( Target . LinuxPlatform . bEnableThreadSanitizer )
2018-09-12 15:59:49 -04:00
{
Options | = LinuxToolChainOptions . EnableThreadSanitizer ;
2020-01-27 16:38:57 -05:00
if ( Target . LinkType ! = TargetLinkType . Monolithic )
{
throw new BuildException ( "Thread Sanitizer (TSan) unsupported for non-monolithic builds" ) ;
}
2018-09-12 15:59:49 -04:00
}
2020-06-23 18:40:00 -04:00
if ( Target . LinuxPlatform . bEnableUndefinedBehaviorSanitizer )
2018-09-12 15:59:49 -04:00
{
Options | = LinuxToolChainOptions . EnableUndefinedBehaviorSanitizer ;
2020-01-27 16:38:57 -05:00
if ( Target . LinkType ! = TargetLinkType . Monolithic )
{
Options | = LinuxToolChainOptions . EnableSharedSanitizer ;
}
}
2020-06-23 18:40:00 -04:00
if ( Target . LinuxPlatform . bEnableMemorySanitizer )
2020-01-27 16:38:57 -05:00
{
Options | = LinuxToolChainOptions . EnableMemorySanitizer ;
if ( Target . LinkType ! = TargetLinkType . Monolithic )
{
throw new BuildException ( "Memory Sanitizer (MSan) unsupported for non-monolithic builds" ) ;
}
2018-09-12 15:59:49 -04:00
}
2020-06-23 18:40:00 -04:00
if ( Target . LinuxPlatform . bEnableThinLTO )
2019-02-18 19:44:39 -05:00
{
Options | = LinuxToolChainOptions . EnableThinLTO ;
}
2018-09-12 15:59:49 -04:00
2020-06-23 18:40:00 -04:00
// When building a monolithic editor we have to avoid using objcopy.exe as it cannot handle files
// larger then 4GB. This is only an issue with our binutils objcopy.exe.
// llvm-objcopy.exe does not have this issue and once we switch over to using that in clang 10.0.1 we can remove this!
if ( ( BuildHostPlatform . Current . Platform = = UnrealTargetPlatform . Win64 ) & &
( Target . LinkType = = TargetLinkType . Monolithic ) & &
( Target . Type = = TargetType . Editor ) )
{
Options | = LinuxToolChainOptions . DisableSplitDebugInfoWithObjCopy ;
}
2018-09-25 10:11:35 -04:00
return new LinuxToolChain ( Target . Architecture , SDK , Target . LinuxPlatform . bPreservePSYM , Options ) ;
2015-09-30 16:40:04 -04:00
}
2016-12-13 11:58:16 -05:00
/// <summary>
/// Deploys the given target
/// </summary>
2019-01-14 12:11:24 -05:00
/// <param name="Receipt">Receipt for the target being deployed</param>
public override void Deploy ( TargetReceipt Receipt )
2016-12-13 11:58:16 -05:00
{
}
2015-09-24 12:37:21 -04:00
}
2015-09-29 08:56:10 -04:00
class LinuxPlatformFactory : UEBuildPlatformFactory
{
2019-01-14 12:11:24 -05:00
public override UnrealTargetPlatform TargetPlatform
2015-12-04 09:32:58 -05:00
{
get { return UnrealTargetPlatform . Linux ; }
}
2015-09-29 08:56:10 -04:00
/// <summary>
/// Register the platform with the UEBuildPlatform class
/// </summary>
2019-01-14 12:11:24 -05:00
public override void RegisterBuildPlatforms ( )
2015-09-29 08:56:10 -04:00
{
LinuxPlatformSDK SDK = new LinuxPlatformSDK ( ) ;
2021-06-14 13:39:47 -04:00
LinuxPlatformSDK SDKArm64 = new LinuxPlatformSDK ( ) ;
2015-09-29 08:56:10 -04:00
2021-06-14 13:39:47 -04:00
// Register this build platform for Linux x86-64 and Arm64
2019-12-06 09:16:21 -05:00
UEBuildPlatform . RegisterBuildPlatform ( new LinuxPlatform ( UnrealTargetPlatform . Linux , SDK ) ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Linux , UnrealPlatformGroup . Linux ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Linux , UnrealPlatformGroup . Unix ) ;
2020-02-12 13:27:19 -05:00
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . Linux , UnrealPlatformGroup . Desktop ) ;
2019-09-14 09:45:25 -04:00
2021-06-14 13:39:47 -04:00
UEBuildPlatform . RegisterBuildPlatform ( new LinuxPlatform ( UnrealTargetPlatform . LinuxArm64 , SDKArm64 ) ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . LinuxArm64 , UnrealPlatformGroup . Linux ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . LinuxArm64 , UnrealPlatformGroup . Unix ) ;
UEBuildPlatform . RegisterPlatformWithGroup ( UnrealTargetPlatform . LinuxArm64 , UnrealPlatformGroup . Desktop ) ;
2015-09-29 08:56:10 -04:00
}
}
2014-03-14 14:13:41 -04:00
}