File tree 2 files changed +20
-3
lines changed
2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,8 @@ def main():
142
142
dest = 'dridriverdir' )
143
143
parser .add_option ('--version-as-components' , action = 'store_true' ,
144
144
dest = 'version_as_components' )
145
+ parser .add_option ('--static' , action = 'store_true' ,
146
+ dest = 'static' )
145
147
(options , args ) = parser .parse_args ()
146
148
147
149
# Make a list of regular expressions to strip out.
@@ -203,7 +205,13 @@ def main():
203
205
sys .stdout .write (dridriverdir .strip ())
204
206
return
205
207
206
- cmd = [options .pkg_config , "--cflags" , "--libs" ] + args
208
+ cmd = [options .pkg_config , "--cflags" , "--libs" ]
209
+
210
+ if options .static :
211
+ cmd .append ("--static" )
212
+
213
+ cmd .extend (args )
214
+
207
215
if options .debug :
208
216
sys .stderr .write ('Running: %s\n ' % ' ' .join (cmd ))
209
217
Original file line number Diff line number Diff line change @@ -137,10 +137,19 @@ template("pkg_config") {
137
137
138
138
# Link libraries statically for OSS-Fuzz fuzzer build
139
139
if (oss_fuzz ) {
140
+ # Output libs needed for static linking (direct + transitive/non-direct libs), we will re-execute the script to get those libs
141
+ args += [ " --static" ]
142
+ pkgresult_static = exec_script (pkg_config_script , args , " value" )
140
143
libs = []
141
144
ldflags = [ " -Wl,-Bstatic" ]
142
- foreach (lib , pkgresult [3 ]) {
143
- ldflags += [ " -l$lib " ]
145
+ foreach (lib , pkgresult_static [3 ]) {
146
+ # dl(dynamic loading) lib is not needed for linking statically and its presence triggers errors.
147
+ # example of errors:
148
+ # ld.lld: error: undefined symbol: __dlsym
149
+ # >>> referenced by dlsym.o:(dlsym) in archive /lib/x86_64-linux-gnu/libdl.a
150
+ if (lib != " dl" ) {
151
+ ldflags += [ " -l$lib " ]
152
+ }
144
153
}
145
154
ldflags += [ " -Wl,-Bdynamic" ]
146
155
lib_dirs = pkgresult [4 ]
You can’t perform that action at this time.
0 commit comments