You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This became an issue for me while working on a fix for godotengine/godot#66231 , as the library reload would immediately cause a crash. After setting the visibility, the library could load, though it seems there is still much work to be done for dynamic reloading of dynamic gdextension libraries within godot itself.
This can be fixed in a platform independent way by default in godot-cpp/SConstruct, since that is used to initialize env
On my build I view the exported symbols: nm -gm demo/bin/libgdexample.macos.editor.framework/libgdexample.macos.editor
provided SConstruct:
#!/usr/bin/env python
import os
import sys
env = SConscript("godot-cpp/SConstruct")
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")
if env["platform"] == "macos":
library = env.SharedLibrary(
"demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"demo/bin/libgdexample{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
Default(library)
Good Sconstruct(macos+clang):
#!/usr/bin/env python
import os
import sys
env = SConscript("godot-cpp/SConstruct")
# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["src/"])
env.Append(CXXFLAGS=["-fvisibility=hidden"])
env.Append(LINKFLAGS=["-dynamiclib","-fvisibility=hidden"])
sources = Glob("src/*.cpp")
if env["platform"] == "macos":
library = env.SharedLibrary(
"demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"demo/bin/libgdexample{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)
Default(library)
jpedrick
changed the title
godot-cpp SConstruct linker visibility flags
godot-cpp SConstruct cpp/linker visibility flags should be default 'hidden' + dynlib
May 5, 2023
Your Godot version:
N/A issue is with current tutorial
Issue description:
The library should have everything except the
entry_symbol
hidden. See Apple's guidelines: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.htmlThis became an issue for me while working on a fix for godotengine/godot#66231 , as the library reload would immediately cause a crash. After setting the visibility, the library could load, though it seems there is still much work to be done for dynamic reloading of dynamic gdextension libraries within godot itself.
This can be fixed in a platform independent way by default in
godot-cpp/SConstruct
, since that is used to initializeenv
On my build I view the exported symbols:
nm -gm demo/bin/libgdexample.macos.editor.framework/libgdexample.macos.editor
provided SConstruct:
Good Sconstruct(macos+clang):
URL to the documentation page:
https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html
The text was updated successfully, but these errors were encountered: