@@ -394,7 +394,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
394394 end
395395
396396 function sanitize_compile_flags! (p:: AbstractPlatform , flags:: Vector{String} )
397- san = sanitize (p)
398397 if sanitize (p) != = nothing
399398 if sanitize (p) == " memory"
400399 append! (flags, [" -fsanitize=memory" ])
@@ -427,41 +426,36 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
427426 if lock_microarchitecture
428427 append! (flags, get_march_flags (arch (p), march (p), " clang" ))
429428 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+
430446 if Sys. isapple (p)
431447 macos_version_flags = clang_use_lld ? (min_macos_version_flags ()[1 ],) : min_macos_version_flags ()
432448 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" ,
444449 macos_version_flags... ,
445450 ])
446451 end
452+
447453 sanitize_compile_flags! (p, flags)
448454 if Sys. isfreebsd (p)
449455 add_system_includedir (flags)
450456 end
451457
452458 if ! Sys. isbsd (p)
453- # libc++ header files
454- append! (flags, [
455- # NOTE: this first directory doesn't exist out-of-the-box in our toolchain,
456- # but you should put in there the C++ standard libraries for libc++ from
457- # LLLVMLibcxx_jll. This must come before GCC header files (added below).
458- " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/include/c++/v1" ,
459- # This directory contains C header files. Must come after the C++ ones, see
460- # for example <https://github.com/llvm/llvm-project/blob/4bcdb26dac4cdadd7f8850a5f9b2e775b73aaf7f/libcxx/include/cmath#L336-L338>.
461- # This directory is in default search paths, but we have to explicitly put
462- # it here to give it higher precedence than the following directories.
463- " -isystem /opt/$(aatriplet (p)) /$(aatriplet (p)) /sys-root/usr/include" ,
464- ])
465459 # GCC header files
466460 if ! isnothing (gcc_version)
467461 append! (flags, [
0 commit comments