@@ -394,7 +394,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
394
394
end
395
395
396
396
function sanitize_compile_flags! (p:: AbstractPlatform , flags:: Vector{String} )
397
- san = sanitize (p)
398
397
if sanitize (p) != = nothing
399
398
if sanitize (p) == " memory"
400
399
append! (flags, [" -fsanitize=memory" ])
@@ -427,35 +426,52 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
427
426
if lock_microarchitecture
428
427
append! (flags, get_march_flags (arch (p), march (p), " clang" ))
429
428
end
429
+
430
+ append! (flags, [
431
+ # We add `-Wno-unused-command-line-argument` so that if someone does something like
432
+ # `clang -Werror -o foo a.o b.o`, it doesn't complain due to the fact that that is using
433
+ # `clang` as a linker (and we have no real way to detect that in the wrapper), which
434
+ # will cause `clang` to complain about compiler flags being passed in.
435
+ " -Wno-unused-command-line-argument" ,
436
+ # We need to override the typical C++ include search paths, because it always includes
437
+ # the toolchain C++ headers first. Valentin tracked this down to:
438
+ # https://github.com/llvm/llvm-project/blob/0378f3a90341d990236c44f297b923a32b35fab1/clang/lib/Driver/ToolChains/Darwin.cpp#L1944-L1978
439
+ " -nostdinc++" ,
440
+ # For systems other than macOS this directory doesn't exist out-of-the-box in our
441
+ # toolchain, but you can put in there the headers of the C++ standard library for libc++
442
+ # from LLLVMLibcxx_jll. This must come before GCC header files (added below).
443
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/usr/include/c++/v1" ,
444
+ ])
445
+
430
446
if Sys. isapple (p)
431
447
macos_version_flags = clang_use_lld ? (min_macos_version_flags ()[1 ],) : min_macos_version_flags ()
432
448
append! (flags, String[
433
- # On MacOS, we need to override the typical C++ include search paths, because it always includes
434
- # the toolchain C++ headers first. Valentin tracked this down to:
435
- # https://github.com/llvm/llvm-project/blob/0378f3a90341d990236c44f297b923a32b35fab1/clang/lib/Driver/ToolChains/Darwin.cpp#L1944-L1978
436
- " -nostdinc++" ,
437
- " -isystem" ,
438
- " /opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/usr/include/c++/v1" ,
439
- # We also add `-Wno-unused-command-line-argument` so that if someone does something like
440
- # `clang -Werror -o foo a.o b.o`, it doesn't complain due to the fact that that is using
441
- # `clang` as a linker (and we have no real way to detect that in the wrapper), which will
442
- # cause `clang` to complain about compiler flags being passed in.
443
- " -Wno-unused-command-line-argument" ,
444
449
macos_version_flags... ,
445
450
])
446
451
end
452
+
447
453
sanitize_compile_flags! (p, flags)
448
454
if Sys. isfreebsd (p)
449
455
add_system_includedir (flags)
450
456
end
451
457
452
- if ! Sys. isbsd (p) && ! isnothing (gcc_version)
453
- append! (flags, String[" -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) " ,
454
- " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) /$(aatriplet (p)) " ,
455
- " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) /backward" ,
456
- " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include" ,
457
- " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/include" ])
458
+ if ! Sys. isbsd (p)
459
+ # GCC header files
460
+ if ! isnothing (gcc_version)
461
+ append! (flags, [
462
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) " ,
463
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) /$(aatriplet (p)) " ,
464
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include/c++/$(gcc_version) /backward" ,
465
+ ])
466
+ end
467
+ # MinGW header files
468
+ if Sys. iswindows (p)
469
+ append! (flags, [
470
+ " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /include" ,
471
+ ])
472
+ end
458
473
end
474
+
459
475
if Sys. iswindows (p) && nbits (p) == 32
460
476
push! (flags, " -fsjlj-exceptions" )
461
477
end
0 commit comments