@@ -56,13 +56,6 @@ struct Bindings {
56
56
cplusplus : bool ,
57
57
}
58
58
59
- fn is_debug ( ) -> bool {
60
- // Check the build profile and not whether debug symbols are enabled (i.e.,
61
- // `env::var("DEBUG")`), because we enable those for benchmarking/profiling and still want
62
- // to build NSS in release mode.
63
- env:: var ( "PROFILE" ) . unwrap_or_default ( ) == "debug"
64
- }
65
-
66
59
// bindgen needs access to libclang.
67
60
// On windows, this doesn't just work, you have to set LIBCLANG_PATH.
68
61
// Rather than download the 400Mb+ files, like gecko does, let's just reuse their work.
@@ -138,31 +131,34 @@ fn build_nss(dir: PathBuf, nsstarget: &str) {
138
131
}
139
132
140
133
fn dynamic_link ( ) {
141
- let libs = if env:: consts:: OS == "windows" {
142
- & [ "nssutil3.dll" , "nss3.dll" , "ssl3.dll" ]
134
+ let dynamic_libs = if env:: consts:: OS == "windows" {
135
+ [
136
+ "nssutil3.dll" ,
137
+ "nss3.dll" ,
138
+ "ssl3.dll" ,
139
+ "libplds4.dll" ,
140
+ "libplc4.dll" ,
141
+ "libnspr4.dll" ,
142
+ ]
143
143
} else {
144
- & [ "nssutil3" , "nss3" , "ssl3" ]
144
+ [ "nssutil3" , "nss3" , "ssl3" , "plds4" , "plc4" , "nspr4 "]
145
145
} ;
146
- dynamic_link_both ( libs) ;
147
- }
148
-
149
- fn dynamic_link_both ( extra_libs : & [ & str ] ) {
150
- let nspr_libs = if env:: consts:: OS == "windows" {
151
- & [ "libplds4" , "libplc4" , "libnspr4" ]
152
- } else {
153
- & [ "plds4" , "plc4" , "nspr4" ]
154
- } ;
155
- for lib in nspr_libs. iter ( ) . chain ( extra_libs) {
146
+ for lib in dynamic_libs {
156
147
println ! ( "cargo:rustc-link-lib=dylib={lib}" ) ;
157
148
}
158
149
}
159
150
160
151
fn static_link ( ) {
161
- let mut static_libs = vec ! [
152
+ let static_libs = [
162
153
"certdb" ,
163
154
"certhi" ,
164
155
"cryptohi" ,
165
156
"freebl" ,
157
+ if env:: consts:: OS == "windows" {
158
+ "libnspr4"
159
+ } else {
160
+ "nspr4"
161
+ } ,
166
162
"nss_static" ,
167
163
"nssb" ,
168
164
"nssdev" ,
@@ -171,30 +167,23 @@ fn static_link() {
171
167
"pk11wrap" ,
172
168
"pkcs12" ,
173
169
"pkcs7" ,
170
+ if env:: consts:: OS == "windows" {
171
+ "libplc4"
172
+ } else {
173
+ "plc4"
174
+ } ,
175
+ if env:: consts:: OS == "windows" {
176
+ "libplds4"
177
+ } else {
178
+ "plds4"
179
+ } ,
174
180
"smime" ,
175
181
"softokn_static" ,
176
182
"ssl" ,
177
183
] ;
178
- if env:: consts:: OS != "macos" {
179
- static_libs. push ( "sqlite" ) ;
180
- }
181
184
for lib in static_libs {
182
185
println ! ( "cargo:rustc-link-lib=static={lib}" ) ;
183
186
}
184
-
185
- // Dynamic libs that aren't transitively included by NSS libs.
186
- let mut other_libs = Vec :: new ( ) ;
187
- if env:: consts:: OS != "windows" {
188
- if env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap_or_default ( ) != "android" {
189
- // On Android, pthread is part of libc.
190
- other_libs. push ( "pthread" ) ;
191
- }
192
- other_libs. extend_from_slice ( & [ "dl" , "c" , "z" ] ) ;
193
- }
194
- if env:: consts:: OS == "macos" {
195
- other_libs. push ( "sqlite3" ) ;
196
- }
197
- dynamic_link_both ( & other_libs) ;
198
187
}
199
188
200
189
fn get_includes ( nsstarget : & Path , nssdist : & Path ) -> Vec < PathBuf > {
@@ -342,7 +331,9 @@ fn setup_standalone(nss: &str) -> Vec<String> {
342
331
"cargo:rustc-link-search=native={}" ,
343
332
nsslibdir. to_str( ) . unwrap( )
344
333
) ;
345
- if is_debug ( ) || env:: consts:: OS == "windows" {
334
+ #[ expect( unexpected_cfgs, reason = "cargo-fuzz defines fuzzing" ) ]
335
+ // FIXME: NSPR doesn't build proper dynamic libraries on Windows.
336
+ if cfg ! ( any( debug_assertions, fuzzing) ) || env:: consts:: OS == "windows" {
346
337
static_link ( ) ;
347
338
} else {
348
339
dynamic_link ( ) ;
0 commit comments