141
141
prefer_clang (p:: AbstractPlatform ) =
142
142
Sys. isbsd (p) || sanitize (p) in (" memory" , " memory_origins" , " address" )
143
143
144
+ # Add the string ABI define
145
+ function add_cxx_abi (p:: AbstractPlatform , flags:: Vector{String} )
146
+ if cxxstring_abi (p) == " cxx11"
147
+ push! (flags, " -D_GLIBCXX_USE_CXX11_ABI=1" )
148
+ elseif cxxstring_abi (p) == " cxx03"
149
+ push! (flags, " -D_GLIBCXX_USE_CXX11_ABI=0" )
150
+ end
151
+ end
152
+
144
153
"""
145
154
generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::AbstractString,
146
155
host_platform::AbstractPlatform = $(repr (default_host_platform)) ,
@@ -162,6 +171,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
162
171
allow_unsafe_flags:: Bool = false ,
163
172
lock_microarchitecture:: Bool = true ,
164
173
bootstrap:: Bool = ! isempty (bootstrap_list),
174
+ gcc_version:: Union{Nothing,VersionNumber} = nothing ,
165
175
)
166
176
# Wipe that directory out, in case it already had compiler wrappers
167
177
rm (bin_path; recursive= true , force= true )
@@ -322,17 +332,17 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
322
332
" --sysroot=/opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root" ,
323
333
])
324
334
if ! Sys. isbsd (p)
325
- append! (flags, [
326
- # Find GCC toolchain here (for things like libgcc_s)
327
- " --gcc-toolchain=/opt/$(aatriplet (p)) "
328
- ])
335
+ add_cxx_abi (p, flags)
329
336
if iscxx
330
337
append! (flags, [
331
338
# Link with libstdc++ when compiling c++ on non-BSDs
332
339
" -stdlib=libstdc++"
333
340
])
334
341
end
335
342
end
343
+ if Sys. islinux (p) && ! isnothing (gcc_version)
344
+ append! (flags, [" --gcc-install-dir=/opt/$(aatriplet (p)) /lib/gcc/$(aatriplet (p)) /$(gcc_version) " ])
345
+ end
336
346
if Sys. iswindows (p)
337
347
windows_cflags! (p, flags)
338
348
end
@@ -415,6 +425,15 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
415
425
if Sys. isfreebsd (p)
416
426
add_system_includedir (flags)
417
427
end
428
+
429
+ if ! Sys. isbsd (p) && ! isnothing (gcc_version)
430
+ append! (flags, String[" -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) " ,
431
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) /$(aatriplet (p)) " ,
432
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) /backward" ,
433
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include" ,
434
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/include" ])
435
+ end
436
+
418
437
return flags
419
438
end
420
439
@@ -434,6 +453,12 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
434
453
# Use libgcc as the C runtime library
435
454
" -rtlib=libgcc"
436
455
])
456
+ if ! isnothing (gcc_version)
457
+ append! (flags, String[" -L/opt/$(aatriplet (p)) /lib/gcc/opt/$(aatriplet (p)) /lib/gcc" ,
458
+ " -L/opt/$(aatriplet (p)) /$(aatriplet (p)) /lib" ,
459
+ " -L/opt/$(aatriplet (p)) /lib/gcc/$(aatriplet (p)) /$(gcc_version) " ,
460
+ " -L/opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/lib" ,])
461
+ end
437
462
end
438
463
# we want to use a particular linker with clang. But we want to avoid warnings about unused
439
464
# flags when just compiling, so we put it into "linker-only flags".
@@ -453,7 +478,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
453
478
function macos_gcc_flags! (p:: AbstractPlatform , flags:: Vector{String} = String[])
454
479
# On macOS, if we're on an old GCC, the default -syslibroot that gets
455
480
# passed to the linker isn't calculated correctly, so we have to manually set it.
456
- gcc_version, llvm_version = select_compiler_versions (p, compilers)
457
481
if gcc_version. major in (4 , 5 )
458
482
push! (flags, " -Wl,-syslibroot,/opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root" )
459
483
end
@@ -473,11 +497,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
473
497
474
498
function gcc_flags! (p:: AbstractPlatform , flags:: Vector{String} = String[])
475
499
# Force proper cxx11 string ABI usage w00t w00t!
476
- if cxxstring_abi (p) == " cxx11"
477
- push! (flags, " -D_GLIBCXX_USE_CXX11_ABI=1" )
478
- elseif cxxstring_abi (p) == " cxx03"
479
- push! (flags, " -D_GLIBCXX_USE_CXX11_ABI=0" )
480
- end
500
+ add_cxx_abi (p, flags)
481
501
482
502
# Simulate some of the `__OSX_AVAILABLE()` macro usage that is broken in GCC
483
503
if Sys. isapple (p) && something (os_version (p), v " 14" ) < v " 16"
@@ -513,7 +533,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
513
533
append! (flags, get_march_flags (arch (p), march (p), " gcc" ))
514
534
end
515
535
sanitize_compile_flags! (p, flags)
516
- gcc_version, llvm_version = select_compiler_versions (p, compilers)
517
536
if libc (platform) == " musl" && gcc_version in (v " 4.8.5" , v " 5.2.0" )
518
537
add_system_includedir (flags)
519
538
end
@@ -523,7 +542,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
523
542
function gcc_link_flags! (p:: AbstractPlatform , flags:: Vector{String} = String[])
524
543
# Yes, it does seem that the inclusion of `/lib64` on `powerpc64le` was fixed
525
544
# in GCC 6, broken again in GCC 7, and then fixed again for GCC 8 and 9
526
- gcc_version, llvm_version = select_compiler_versions (p, compilers)
527
545
if arch (p) == " powerpc64le" && Sys. islinux (p) && gcc_version. major in (4 , 5 , 7 )
528
546
append! (flags, String[
529
547
" -L/opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/lib64" ,
@@ -1298,12 +1316,15 @@ function runner_setup!(workspaces, mappings, workspace_root, verbose, kwargs, pl
1298
1316
rb = filter (s -> s. name == " RustBase" , shards)
1299
1317
rust_version = length (rb) == 1 ? only (rb). version : nothing
1300
1318
1319
+ # Determine version of GCC toolchain.
1320
+ gcc = filter (s -> s. name == " GCCBootstrap" && platforms_match (s. target, platform), shards)
1321
+ gcc_version = length (gcc) == 1 ? only (gcc). version : nothing
1301
1322
# Construct environment variables we'll use from here on out
1302
1323
platform:: Platform = get_concrete_platform (platform; compilers... , extract_kwargs (kwargs, (:preferred_gcc_version ,:preferred_llvm_version ))... )
1303
1324
envs:: Dict{String,String} = merge (platform_envs (platform, src_name; rust_version, verbose, compilers... ), extra_env)
1304
1325
1305
1326
# JIT out some compiler wrappers, add it to our mounts
1306
- generate_compiler_wrappers! (platform; bin_path= compiler_wrapper_path, compilers... , extract_kwargs (kwargs, (:allow_unsafe_flags ,:lock_microarchitecture ))... )
1327
+ generate_compiler_wrappers! (platform; bin_path= compiler_wrapper_path, gcc_version, compilers... , extract_kwargs (kwargs, (:allow_unsafe_flags ,:lock_microarchitecture ))... )
1307
1328
push! (workspaces, compiler_wrapper_path => " /opt/bin" )
1308
1329
1309
1330
if isempty (bootstrap_list)
0 commit comments