@@ -120,18 +120,6 @@ if env["platform"] == "macos" and os.environ.get("OSXCROSS_ROOT", ""):
120
120
if env ["macos_deployment_target" ] != "default" :
121
121
env ["ENV" ]["MACOSX_DEPLOYMENT_TARGET" ] = env ["macos_deployment_target" ]
122
122
123
- # Patch linux flags to statically link libgcc and libstdc++
124
- if env ["platform" ] == "linux" :
125
- env .Append (
126
- LINKFLAGS = [
127
- "-Wl,--no-undefined" ,
128
- "-static-libgcc" ,
129
- "-static-libstdc++" ,
130
- ]
131
- )
132
- # And add some linux dependencies.
133
- env .Append (LIBS = ["pthread" , "dl" ])
134
-
135
123
opts .Update (env )
136
124
137
125
target = env ["target" ]
@@ -175,6 +163,24 @@ rtc = env.BuildLibDataChannel(ssl)
175
163
# but it's better to be safe in case of indirect inclusions by one of our other dependencies.
176
164
env .Depends (sources , ssl + rtc )
177
165
166
+ # We want to statically link against libstdc++ on Linux to maximize compatibility, but we must restrict the exported
167
+ # symbols using a GCC version script, or we might end up overriding symbols from other libraries.
168
+ # Using "-fvisibility=hidden" will not work, since libstdc++ explicitly exports its symbols.
169
+ symbols_file = None
170
+ if env ["platform" ] == "linux" :
171
+ if env ["godot_version" ] == "3" :
172
+ symbols_file = env .File ("misc/dist/linux/symbols-gdnative.map" )
173
+ else :
174
+ symbols_file = env .File ("misc/dist/linux/symbols-extension.map" )
175
+ env .Append (
176
+ LINKFLAGS = [
177
+ "-Wl,--no-undefined,--version-script=" + symbols_file .abspath ,
178
+ "-static-libgcc" ,
179
+ "-static-libstdc++" ,
180
+ ]
181
+ )
182
+ env .Depends (sources , symbols_file )
183
+
178
184
# Make the shared library
179
185
result_name = "libwebrtc_native{}{}" .format (env ["suffix" ], env ["SHLIBSUFFIX" ])
180
186
if env ["godot_version" ] != "3" and env ["platform" ] == "macos" :
@@ -190,6 +196,7 @@ if env["godot_version"] != "3" and env["platform"] == "macos":
190
196
library = [library_file , plist_file ]
191
197
else :
192
198
library = env .SharedLibrary (target = os .path .join (result_path , "lib" , result_name ), source = sources )
199
+
193
200
Default (library )
194
201
195
202
# GDNativeLibrary
0 commit comments