@@ -262,30 +262,27 @@ impl Step for Llvm {
262
262
cfg. define ( "LLVM_LINK_LLVM_DYLIB" , "ON" ) ;
263
263
}
264
264
265
- // For distribution we want the LLVM tools to be *statically* linked to libstdc++
266
- if builder. config . llvm_tools_enabled {
267
- if !target. contains ( "msvc" ) {
265
+ // For distribution we want the LLVM tools to be *statically* linked to libstdc++.
266
+ // We also do this if the user explicitly requested static libstdc++.
267
+ if builder. config . llvm_tools_enabled || builder. config . llvm_static_stdcpp {
268
+ if !target. contains ( "msvc" ) && !target. contains ( "netbsd" ) {
268
269
if target. contains ( "apple" ) {
269
- ldflags. exe . push ( " -static-libstdc++") ;
270
+ ldflags. push_all ( " -static-libstdc++") ;
270
271
} else {
271
- ldflags. exe . push ( " -Wl,-Bsymbolic -static-libstdc++") ;
272
+ ldflags. push_all ( " -Wl,-Bsymbolic -static-libstdc++") ;
272
273
}
273
274
}
274
275
}
275
276
276
- if ! target. contains ( "freebsd ") && target. starts_with ( "riscv ") {
277
+ if target. starts_with ( "riscv ") && ! target. contains ( "freebsd ") {
277
278
// RISC-V GCC erroneously requires linking against
278
279
// `libatomic` when using 1-byte and 2-byte C++
279
280
// atomics but the LLVM build system check cannot
280
281
// detect this. Therefore it is set manually here.
281
282
// FreeBSD uses Clang as its system compiler and
282
283
// provides no libatomic in its base system so does
283
284
// not want this.
284
- if !builder. config . llvm_tools_enabled {
285
- ldflags. exe . push ( " -latomic" ) ;
286
- } else {
287
- ldflags. exe . push ( " -latomic -static-libstdc++" ) ;
288
- }
285
+ ldflags. exe . push ( " -latomic" ) ;
289
286
ldflags. shared . push ( " -latomic" ) ;
290
287
}
291
288
@@ -554,9 +551,6 @@ fn configure_cmake(
554
551
}
555
552
cfg. define ( "CMAKE_C_FLAGS" , cflags) ;
556
553
let mut cxxflags: OsString = builder. cflags ( target, GitRepo :: Llvm ) . join ( " " ) . into ( ) ;
557
- if builder. config . llvm_static_stdcpp && !target. contains ( "msvc" ) && !target. contains ( "netbsd" ) {
558
- cxxflags. push ( " -static-libstdc++" ) ;
559
- }
560
554
if let Some ( ref s) = builder. config . llvm_cxxflags {
561
555
cxxflags. push ( " " ) ;
562
556
cxxflags. push ( s) ;
0 commit comments