Merge branch 'linux_linker_changes' of https://github.com/GoaLitiuM/FlaxEngine into GoaLitiuM-linux_linker_changes

This commit is contained in:
Wojtek Figat
2023-02-15 15:39:56 +01:00
3 changed files with 45 additions and 9 deletions

View File

@@ -36,6 +36,7 @@ Flax Visual Studio extension provides better programming workflow, C# scripts de
* Install Windows 8.1 SDK or newer (via Visual Studio Installer) * Install Windows 8.1 SDK or newer (via Visual Studio Installer)
* Install Microsoft Visual C++ 2015 v140 toolset or newer (via Visual Studio Installer) * Install Microsoft Visual C++ 2015 v140 toolset or newer (via Visual Studio Installer)
* Install .Net Framework 4.5.2 SDK/Targeting Pack (via Visual Studio Installer) * Install .Net Framework 4.5.2 SDK/Targeting Pack (via Visual Studio Installer)
* Install Git with LFS
* Clone repo (with LFS) * Clone repo (with LFS)
* Run **GenerateProjectFiles.bat** * Run **GenerateProjectFiles.bat**
* Open `Flax.sln` and set solution configuration to **Editor.Development** and solution platform to **Win64** * Open `Flax.sln` and set solution configuration to **Editor.Development** and solution platform to **Win64**
@@ -48,12 +49,23 @@ Flax Visual Studio extension provides better programming workflow, C# scripts de
## Linux ## Linux
* Install Visual Studio Code * Install Visual Studio Code
* Install Mono ([https://www.mono-project.com/download/stable](https://www.mono-project.com/download/stable)) * Install Mono
* Install Vulkan SDK ([https://vulkan.lunarg.com/](https://vulkan.lunarg.com/)) * Ubuntu: see the instructions here: ([https://www.mono-project.com/download/stable](https://www.mono-project.com/download/stable))
* Arch: `sudo pacman -S mono`
* Install Vulkan SDK
* Ubuntu: see the instructions here: ([https://vulkan.lunarg.com/](https://vulkan.lunarg.com/))
* Arch: `sudo pacman -S spirv-tools vulkan-headers vulkan-tools vulkan-validation-layers`
* Install Git with LFS * Install Git with LFS
* Install requried packages: `sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev nuget autoconf libogg-dev automake build-essential gettext cmake python libtool libtool-bin libpulse-dev libasound2-dev libjack-dev portaudio19-dev` * Ubuntu: `sudo apt-get install git git-lfs`
* Install compiler `sudo apt-get install clang lldb lld` (Clang 6 or newer) * Arch: `sudo pacman -S git git-lfs`
* Clone repo (with LFS) * `git-lfs install`
* Install the required packages:
* Ubuntu: `sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev zlib1g-dev`
* Arch: `sudo pacman -S base-devel libx11 libxcursor libxinerama zlib`
* Install Clang compiler (version 6 or later):
* Ubuntu: `sudo apt-get install clang lldb lld`
* Arch: `sudo pacman -S clang lldb lld`
* Clone the repository (with LFS)
* Run `./GenerateProjectFiles.sh` * Run `./GenerateProjectFiles.sh`
* Open workspace with Visual Code * Open workspace with Visual Code
* Build and run (configuration and task named `Flax|Editor.Linux.Development|x64`) * Build and run (configuration and task named `Flax|Editor.Linux.Development|x64`)

View File

@@ -85,7 +85,8 @@ namespace Flax.Build.Platforms
args.Add("-Wl,-rpath,\"\\$ORIGIN\""); args.Add("-Wl,-rpath,\"\\$ORIGIN\"");
//args.Add("-Wl,--as-needed"); //args.Add("-Wl,--as-needed");
args.Add("-Wl,--copy-dt-needed-entries"); if (LdKind == "bfd")
args.Add("-Wl,--copy-dt-needed-entries");
args.Add("-Wl,--hash-style=gnu"); args.Add("-Wl,--hash-style=gnu");
//args.Add("-Wl,--build-id"); //args.Add("-Wl,--build-id");
@@ -105,6 +106,7 @@ namespace Flax.Build.Platforms
args.Add("-pthread"); args.Add("-pthread");
args.Add("-ldl"); args.Add("-ldl");
args.Add("-lrt"); args.Add("-lrt");
args.Add("-lz");
// Link X11 // Link X11
args.Add("-L/usr/X11R6/lib"); args.Add("-L/usr/X11R6/lib");

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Flax.Build.Graph; using Flax.Build.Graph;
using Flax.Build.NativeCpp; using Flax.Build.NativeCpp;
@@ -61,6 +62,11 @@ namespace Flax.Build.Platforms
/// </summary> /// </summary>
protected string LdPath; protected string LdPath;
/// <summary>
/// The type of the linker.
/// </summary>
protected string LdKind;
/// <summary> /// <summary>
/// The clang tool version. /// The clang tool version.
/// </summary> /// </summary>
@@ -91,7 +97,19 @@ namespace Flax.Build.Platforms
RanlibPath = UnixPlatform.Which("ranlib"); RanlibPath = UnixPlatform.Which("ranlib");
StripPath = UnixPlatform.Which("strip"); StripPath = UnixPlatform.Which("strip");
ObjcopyPath = UnixPlatform.Which("objcopy"); ObjcopyPath = UnixPlatform.Which("objcopy");
LdPath = UnixPlatform.Which("ld");
LdPath = UnixPlatform.Which("ld.lld");
LdKind = "lld";
if (LdPath == null)
{
LdPath = UnixPlatform.Which("ld.gold");
LdKind = "gold";
}
if (LdPath == null)
{
LdPath = UnixPlatform.Which("ld"); // ld.bfd
LdKind = "bfd";
}
} }
else else
{ {
@@ -478,6 +496,9 @@ namespace Flax.Build.Platforms
// TODO: linkEnvironment.LinkTimeCodeGeneration // TODO: linkEnvironment.LinkTimeCodeGeneration
// TODO: linkEnvironment.Optimization // TODO: linkEnvironment.Optimization
// TODO: linkEnvironment.UseIncrementalLinking // TODO: linkEnvironment.UseIncrementalLinking
if (!string.IsNullOrEmpty(LdKind))
args.Add(string.Format("-fuse-ld={0}", LdKind));
} }
SetupLinkFilesArgs(graph, options, args, outputFilePath); SetupLinkFilesArgs(graph, options, args, outputFilePath);
@@ -536,9 +557,10 @@ namespace Flax.Build.Platforms
} }
} }
// Input files // Input files (link static libraries last)
task.PrerequisiteFiles.AddRange(linkEnvironment.InputFiles); task.PrerequisiteFiles.AddRange(linkEnvironment.InputFiles);
foreach (var file in linkEnvironment.InputFiles) foreach (var file in linkEnvironment.InputFiles.Where(x => !x.EndsWith(".a"))
.Concat(linkEnvironment.InputFiles.Where(x => x.EndsWith(".a"))))
{ {
args.Add(string.Format("\"{0}\"", file.Replace('\\', '/'))); args.Add(string.Format("\"{0}\"", file.Replace('\\', '/')));
} }