summaryrefslogtreecommitdiffstats
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/linuxbsd/detect.py18
-rw-r--r--platform/linuxbsd/godot_linuxbsd.cpp12
-rw-r--r--platform/linuxbsd/pck_embed.ld10
-rw-r--r--platform/linuxbsd/pck_embed.legacy.ld10
-rw-r--r--platform/windows/godot_windows.cpp4
5 files changed, 14 insertions, 40 deletions
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index eaaaad82b9..a5050c253c 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -458,24 +458,6 @@ def configure(env: "Environment"):
if env["execinfo"]:
env.Append(LIBS=["execinfo"])
- if not env.editor_build:
- import subprocess
- import re
-
- linker_version_str = subprocess.check_output(
- [env.subst(env["LINK"]), "-Wl,--version"] + env.subst(env["LINKFLAGS"])
- ).decode("utf-8")
- gnu_ld_version = re.search(r"^GNU ld [^$]*(\d+\.\d+)$", linker_version_str, re.MULTILINE)
- if not gnu_ld_version:
- print(
- "Warning: Creating export template binaries enabled for PCK embedding is currently only supported with GNU ld, not gold, LLD or mold."
- )
- else:
- if float(gnu_ld_version.group(1)) >= 2.30:
- env.Append(LINKFLAGS=["-T", "platform/linuxbsd/pck_embed.ld"])
- else:
- env.Append(LINKFLAGS=["-T", "platform/linuxbsd/pck_embed.legacy.ld"])
-
if platform.system() == "FreeBSD":
env.Append(LINKFLAGS=["-lkvm"])
diff --git a/platform/linuxbsd/godot_linuxbsd.cpp b/platform/linuxbsd/godot_linuxbsd.cpp
index efad9c8594..a2b6fbeb25 100644
--- a/platform/linuxbsd/godot_linuxbsd.cpp
+++ b/platform/linuxbsd/godot_linuxbsd.cpp
@@ -41,6 +41,18 @@
#include <sys/resource.h>
#endif
+// For export templates, add a section; the exporter will patch it to enclose
+// the data appended to the executable (bundled PCK).
+#if !defined(TOOLS_ENABLED) && defined(__GNUC__)
+static const char dummy[8] __attribute__((section("pck"), used)) = { 0 };
+
+// Dummy function to prevent LTO from discarding "pck" section.
+extern "C" const char *pck_section_dummy_call() __attribute__((used));
+extern "C" const char *pck_section_dummy_call() {
+ return &dummy[0];
+}
+#endif
+
int main(int argc, char *argv[]) {
#if defined(SANITIZERS_ENABLED)
// Note: Set stack size to be at least 30 MB (vs 8 MB default) to avoid overflow, address sanitizer can increase stack usage up to 3 times.
diff --git a/platform/linuxbsd/pck_embed.ld b/platform/linuxbsd/pck_embed.ld
deleted file mode 100644
index 57a1994043..0000000000
--- a/platform/linuxbsd/pck_embed.ld
+++ /dev/null
@@ -1,10 +0,0 @@
-SECTIONS
-{
- /* Add a zero-sized section; the exporter will patch it to enclose the data appended to the executable (embedded PCK) */
- pck 0 (INFO) :
- {
- /* binutils >= 2.30 allow it being zero-sized, but needs something between the braces to keep the section */
- . = ALIGN(8);
- }
-}
-INSERT AFTER .rodata;
diff --git a/platform/linuxbsd/pck_embed.legacy.ld b/platform/linuxbsd/pck_embed.legacy.ld
deleted file mode 100644
index a23013ba7a..0000000000
--- a/platform/linuxbsd/pck_embed.legacy.ld
+++ /dev/null
@@ -1,10 +0,0 @@
-SECTIONS
-{
- /* The exporter will patch this section to enclose the data appended to the executable (embedded PCK) */
- pck 0 (INFO) : AT ( ADDR (.rodata) + SIZEOF (.rodata) )
- {
- /* binutils < 2.30 need some actual content for the linker not to discard the section */
- BYTE(0);
- }
-}
-INSERT AFTER .rodata;
diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index 8d63b1747e..f86ecd87fb 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -36,7 +36,7 @@
#include <stdio.h>
// For export templates, add a section; the exporter will patch it to enclose
-// the data appended to the executable (bundled PCK)
+// the data appended to the executable (bundled PCK).
#ifndef TOOLS_ENABLED
#if defined _MSC_VER
#pragma section("pck", read)
@@ -45,7 +45,7 @@ __declspec(allocate("pck")) static char dummy[8] = { 0 };
// Dummy function to prevent LTO from discarding "pck" section.
extern "C" char *__cdecl pck_section_dummy_call() {
return &dummy[0];
-};
+}
#if defined _AMD64_
#pragma comment(linker, "/include:pck_section_dummy_call")
#elif defined _X86_