[+] More portable Linux builds

This commit is contained in:
Reece Wilson 2024-06-28 11:37:59 +01:00
parent 382e5c8b1d
commit 072ec58f2a
2 changed files with 63 additions and 3 deletions

View File

@ -52,7 +52,7 @@ local function isNoLinkType(projectType)
return projectType == "StaticLib" or isUtils(projectType)
end
local function addUserDestCopy(name, type, config, platformName, arch, dir)
local function addUserDestCopy(name, type, config, platformName, arch, dir, projectType)
local isWin = platformName == "win32"
local debugSymbolPath = nil
@ -74,9 +74,68 @@ local function addUserDestCopy(name, type, config, platformName, arch, dir)
config ~= Aurora.Settings.sNameOfDebug) then
local debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".dwarf"
postbuildcommands("objcopy --strip-debug --strip-unneeded \"" .. file .. "\" \"" .. outputPath .. "\"")
if (Aurora.Settings.bUseAuBuildHooks and config ~= Aurora.Settings.sNameOfShip) then
if (not Aurora.Settings.bUseAuBuildHooks) then
return
end
if (config ~= Aurora.Settings.sNameOfShip) then
postbuildcommands("objcopy --add-gnu-debuglink=\"" .. debugSymbolPath .. "\" \"" .. outputPath .. "\"")
end
if (platform.forcePortableLibc and not os.getenv("AURORA_LINK_NOT_PORTABLE")) then
local platformSuffix = "System." .. platform.outputName .. "." .. arch
postbuildcommands("patchelf --replace-needed libm.so.6 libm." .. platformSuffix .. ".so \"" .. outputPath .. "\"")
postbuildcommands("patchelf --replace-needed libc.so.6 libc." .. platformSuffix .. ".so \"" .. outputPath .. "\"")
postbuildcommands("patchelf --replace-needed libgcc_s.so.1 libgcc." .. platformSuffix .. ".so \"" .. outputPath .. "\"")
if (arch == "x86_64" or arch == "ARM64" or arch == "aarch64" or arch == "mips64") then
if (projectType == "WindowedApp" or projectType == "ConsoleApp") then
postbuildcommands("patchelf --set-interpreter \"ld-Aurora.System.Linux.x86_64.so\" \"" .. outputPath .. "\"")
end
postbuildcommands("cp -f /lib64/ld-linux-x86-64.so.2 \"" .. dir .. "/ld-Aurora.System.Linux.x86_64.so\"")
postbuildcommands("cp -f /lib64/libc.so.6 \"" .. dir .. "/libc." .. platformSuffix .. ".so\"")
postbuildcommands("cp -f /lib64/libm.so.6 \"" .. dir .. "/libm." .. platformSuffix .. ".so\"")
postbuildcommands("cp -f /lib64/libgcc_s.so.1 \"" .. dir .. "/libgcc." .. platformSuffix .. ".so\"")
else
if (projectType == "WindowedApp" or projectType == "ConsoleApp") then
postbuildcommands("patchelf --set-interpreter \"ld-Aurora.System.Linux.x86_32.so\" \"" .. file .. "\"")
end
postbuildcommands("cp -f /lib/ld-linux.so.2 \"" .. dir .. "/ld-Aurora.System.Linux.x86_32.so\"")
postbuildcommands("cp -f /lib/libc.so.6 \"" .. dir .. "/libc." .. platformSuffix .. ".so\"")
postbuildcommands("cp -f /lib/libm.so.6 \"" .. dir .. "/libm." .. platformSuffix .. ".so\"")
postbuildcommands("cp -f /lib/libgcc_s.so.1 \"" .. dir .. "/libgcc." .. platformSuffix .. ".so\"")
end
postbuildcommands("patchelf --replace-needed libc.so.6 libc." .. platformSuffix .. ".so \"" .. dir .. "/libm." .. platformSuffix .. ".so\"")
postbuildcommands("patchelf --replace-needed libm.so.6 libm." .. platformSuffix .. ".so \"" .. dir .. "/libm." .. platformSuffix .. ".so\"")
postbuildcommands("patchelf --replace-needed libc.so.6 libc." .. platformSuffix .. ".so \"" .. dir .. "/libgcc." .. platformSuffix .. ".so\"")
postbuildcommands("patchelf --replace-needed libm.so.6 libm." .. platformSuffix .. ".so \"" .. dir .. "/libgcc." .. platformSuffix .. ".so\"")
if (os.isfile(dir .. "/libunwind-x86_64.so.8")) then
postbuildcommands("patchelf --replace-needed libc.so.6 libc." .. "System.Linux.x86_64" .. ".so \"" .. dir .. "/libunwind-x86_64.so.8\"")
postbuildcommands("patchelf --replace-needed libm.so.6 libm." .. "System.Linux.x86_64" .. ".so \"" .. dir .. "/libunwind-x86_64.so.8\"")
postbuildcommands("patchelf --replace-needed libgcc_s.so.1 libgcc." .. "System.Linux.x86_64" .. ".so \"" .. dir .. "/libunwind-x86_64.so.8\"")
end
if (os.isfile(dir .. "/libunwind.so.8")) then
postbuildcommands("patchelf --replace-needed libc.so.6 libc." .. platformSuffix .. ".so \"" .. dir .. "/libunwind.so.8\"")
postbuildcommands("patchelf --replace-needed libm.so.6 libm." .. platformSuffix .. ".so \"" .. dir .. "/libunwind.so.8\"")
postbuildcommands("patchelf --replace-needed libgcc_s.so.1 libgcc." .. platformSuffix .. ".so \"" .. dir .. "/libunwind.so.8\"")
end
if (os.isfile(dir .. "/liblzma.so.5")) then
postbuildcommands("patchelf --replace-needed libc.so.6 libc." .. platformSuffix .. ".so \"" .. dir .. "/liblzma.so.5\"")
postbuildcommands("patchelf --replace-needed libm.so.6 libm." .. platformSuffix .. ".so \"" .. dir .. "/liblzma.so.5\"")
postbuildcommands("patchelf --replace-needed libgcc_s.so.1 libgcc." .. platformSuffix .. ".so \"" .. dir .. "/liblzma.so.5\"")
end
if (os.isfile(dir .. "/liblzma.so.6")) then
postbuildcommands("patchelf --replace-needed libc.so.6 libc." .. platformSuffix .. ".so \"" .. dir .. "/liblzma.so.6\"")
postbuildcommands("patchelf --replace-needed libm.so.6 libm." .. platformSuffix .. ".so \"" .. dir .. "/liblzma.so.6\"")
postbuildcommands("patchelf --replace-needed libgcc_s.so.1 libgcc." .. platformSuffix .. ".so \"" .. dir .. "/liblzma.so.6\"")
end
end
else
postbuildcommands(copy)
end
@ -104,7 +163,7 @@ local function addDest(name, projectType, dest)
end
auFilterForConfigPlatforms(function(config, platform, arch)
addUserDestCopy(name, projectType, config, platform, arch, lookup[config] .. append)
addUserDestCopy(name, projectType, config, platform, arch, lookup[config] .. append, projectType)
end)
end

View File

@ -31,6 +31,7 @@ local platforms = {
devChainSupportsElfStrip = true,
devChainCoreUtils = true,
elfSupportsRPath = true,
forcePortableLibc = true,
exts = {
SharedLib = ".so",
StaticLib = ".a"