Skip to content

Commit 9c15402

Browse files
fingolfingiordano
andauthored
Add -isystem ${includedir} for clang on FreeBSD, and GCC on musl (#226)
* Add `-isystem ${includedir}` for clang on FreeBSD, and GCC on musl Currently several JLLs need to manually add `-I${includedir}` to their CPPFLAGS in order to build correctly on these platforms. Fix this by adjusting the compiler wrappers. See JuliaPackaging/Yggdrasil#3949 Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
1 parent c3a4012 commit 9c15402

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Runner.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,23 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
331331
return "-mmacosx-version-min=$(macos_version(p))"
332332
end
333333

334+
function add_system_includedir(flags::Vector{String})
335+
# GCC 4.8.5 for musl and clang on FreeBSD do not have `SYSROOT/usr/local` (which
336+
# in our build environments is a symlink to $includedir = "$(prefix)/include")
337+
# in the default list of include search directories. As a result, quite some
338+
# builders that work fine everywhere else need to add something like
339+
# `-I${includedir}` to their CPPFLAGS.
340+
#
341+
# To remove this annoyance, we simply add it here. We use `-isystem` instead
342+
# of `-I` to mimic how this dir is treated on other operating systems. It
343+
# is still not a perfect match, as the order of the default search directories
344+
# differs, but this should not matter in practice.
345+
#
346+
# See also https://github.com/JuliaPackaging/Yggdrasil/issues/3949 and
347+
# https://github.com/JuliaPackaging/Yggdrasil/pull/3969 for further details.
348+
append!(flags, ["-isystem", raw"${includedir}"])
349+
end
350+
334351
function clang_compile_flags!(p::AbstractPlatform, flags::Vector{String} = String[])
335352
if lock_microarchitecture
336353
append!(flags, get_march_flags(arch(p), march(p), "clang"))
@@ -351,6 +368,9 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
351368
min_macos_version_flag(p),
352369
])
353370
end
371+
if Sys.isfreebsd(p)
372+
add_system_includedir(flags)
373+
end
354374
return flags
355375
end
356376

@@ -420,6 +440,10 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
420440
if lock_microarchitecture
421441
append!(flags, get_march_flags(arch(p), march(p), "gcc"))
422442
end
443+
gcc_version, llvm_version = select_compiler_versions(p, compilers)
444+
if libc(platform) == "musl" && gcc_version in (v"4.8.5", v"5.2.0")
445+
add_system_includedir(flags)
446+
end
423447
return flags
424448
end
425449

0 commit comments

Comments
 (0)