Fix: Libgodot build on Linux.

This commit is contained in:
Ben Rog-Wilhelm 2025-10-08 17:11:20 -05:00
parent 295e465fe4
commit 0a584250ae
4 changed files with 41 additions and 38 deletions

View file

@ -43,7 +43,6 @@ if env["dbus"]:
if env["library_type"] == "static_library": if env["library_type"] == "static_library":
prog = env.add_library("#bin/godot", common_linuxbsd) prog = env.add_library("#bin/godot", common_linuxbsd)
elif env["library_type"] == "shared_library": elif env["library_type"] == "shared_library":
env.Append(CCFLAGS=["-fPIC"])
prog = env.add_shared_library("#bin/godot", common_linuxbsd) prog = env.add_shared_library("#bin/godot", common_linuxbsd)
else: else:
prog = env.add_program("#bin/godot", common_linuxbsd) prog = env.add_program("#bin/godot", common_linuxbsd)

View file

@ -182,6 +182,9 @@ def configure(env: "SConsEnvironment"):
env.Append(CCFLAGS=["-ffp-contract=off"]) env.Append(CCFLAGS=["-ffp-contract=off"])
if env["library_type"] == "shared_library":
env.Append(CCFLAGS=["-fPIC"])
# LTO # LTO
if env["lto"] == "auto": # Enable LTO for production. if env["lto"] == "auto": # Enable LTO for production.

View file

@ -3,6 +3,8 @@ from misc.utility.scons_hints import *
Import("env") Import("env")
File = env.File
# TODO: Add warning to headers and code about their autogenerated status. # TODO: Add warning to headers and code about their autogenerated status.
if env["use_sowrap"]: if env["use_sowrap"]:
# We have to implement separate builders for so wrappers as the # We have to implement separate builders for so wrappers as the
@ -41,14 +43,14 @@ else:
def generate_from_xml(name, path): def generate_from_xml(name, path):
header = env.WAYLAND_API_HEADER(f"protocol/{name}.gen.h", path) header = env.WAYLAND_API_HEADER(File(f"protocol/{name}.gen.h"), path)
source = env.WAYLAND_API_CODE(f"protocol/{name}.gen.c", path) source = env.WAYLAND_API_CODE(File(f"protocol/{name}.gen.c"), path)
env.NoCache(header, source) env.NoCache(header, source)
return env.Object(f"protocol/{name}.gen.c") return source
objects = [ generated_sources = [
# Core protocol # Core protocol
generate_from_xml("wayland", "#thirdparty/wayland/protocol/wayland.xml"), generate_from_xml("wayland", "#thirdparty/wayland/protocol/wayland.xml"),
# Stable protocols # Stable protocols
@ -97,34 +99,31 @@ objects = [
), ),
] ]
source_files = [ source_files = generated_sources + [
"detect_prime_egl.cpp", File("detect_prime_egl.cpp"),
"display_server_wayland.cpp", File("display_server_wayland.cpp"),
"key_mapping_xkb.cpp", File("key_mapping_xkb.cpp"),
"wayland_thread.cpp", File("wayland_thread.cpp"),
] ]
if env["use_sowrap"]: if env["use_sowrap"]:
source_files.append( source_files.append(
[ [
"dynwrappers/wayland-cursor-so_wrap.c", File("dynwrappers/wayland-cursor-so_wrap.c"),
"dynwrappers/wayland-client-core-so_wrap.c", File("dynwrappers/wayland-client-core-so_wrap.c"),
"dynwrappers/wayland-egl-core-so_wrap.c", File("dynwrappers/wayland-egl-core-so_wrap.c"),
] ]
) )
if env["libdecor"]: if env["libdecor"]:
source_files.append("dynwrappers/libdecor-so_wrap.c") source_files.append(File("dynwrappers/libdecor-so_wrap.c"))
if env["vulkan"]: if env["vulkan"]:
source_files.append("rendering_context_driver_vulkan_wayland.cpp") source_files.append(File("rendering_context_driver_vulkan_wayland.cpp"))
if env["opengl3"]: if env["opengl3"]:
source_files.append("egl_manager_wayland.cpp") source_files.append(File("egl_manager_wayland.cpp"))
source_files.append("egl_manager_wayland_gles.cpp") source_files.append(File("egl_manager_wayland_gles.cpp"))
for source_file in source_files: Return("source_files")
objects.append(env.Object(source_file))
Return("objects")

View file

@ -3,36 +3,38 @@ from misc.utility.scons_hints import *
Import("env") Import("env")
File = env.File
source_files = [ source_files = [
"display_server_x11.cpp", File("display_server_x11.cpp"),
"key_mapping_x11.cpp", File("key_mapping_x11.cpp"),
] ]
if env["use_sowrap"]: if env["use_sowrap"]:
source_files.append( source_files.append(
[ [
"dynwrappers/xlib-so_wrap.c", File("dynwrappers/xlib-so_wrap.c"),
"dynwrappers/xcursor-so_wrap.c", File("dynwrappers/xcursor-so_wrap.c"),
"dynwrappers/xinerama-so_wrap.c", File("dynwrappers/xinerama-so_wrap.c"),
"dynwrappers/xinput2-so_wrap.c", File("dynwrappers/xinput2-so_wrap.c"),
"dynwrappers/xrandr-so_wrap.c", File("dynwrappers/xrandr-so_wrap.c"),
"dynwrappers/xrender-so_wrap.c", File("dynwrappers/xrender-so_wrap.c"),
"dynwrappers/xext-so_wrap.c", File("dynwrappers/xext-so_wrap.c"),
] ]
) )
if env["vulkan"]: if env["vulkan"]:
source_files.append("rendering_context_driver_vulkan_x11.cpp") source_files.append(File("rendering_context_driver_vulkan_x11.cpp"))
if env["opengl3"]: if env["opengl3"]:
env.Append(CPPDEFINES=["GLAD_GLX_NO_X11"]) env.Append(CPPDEFINES=["GLAD_GLX_NO_X11"])
source_files.append( source_files.append(
["gl_manager_x11_egl.cpp", "gl_manager_x11.cpp", "detect_prime_x11.cpp", "#thirdparty/glad/glx.c"] [
File("gl_manager_x11_egl.cpp"),
File("gl_manager_x11.cpp"),
File("detect_prime_x11.cpp"),
File("#thirdparty/glad/glx.c"),
]
) )
objects = [] Return("source_files")
for source_file in source_files:
objects.append(env.Object(source_file))
Return("objects")