Skip to content

Commit 128480c

Browse files
authored
Babysit meson so it doesn't do the wrong thing (#352)
it tries really hard
1 parent 2181175 commit 128480c

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/BuildToolchains.jl

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ function cmake_os(p::AbstractPlatform)
3131
end
3232
end
3333

34-
lld_str(p::AbstractPlatform) = Sys.isapple(p) ? "ld64.lld" : "ld.lld"
35-
function linker_string(p::AbstractPlatform, clang_use_lld)
34+
lld_string(p::AbstractPlatform) = Sys.isapple(p) ? "ld64.lld" : "ld.lld"
35+
function linker_string(bt::CMake{:gcc}, p::AbstractPlatform, clang_use_lld)
3636
target = triplet(p)
3737
aatarget = aatriplet(p)
38-
return clang_use_lld ? "/opt/bin/$(target)/$(lld_str(p))" : "/opt/bin/$(target)/$(aatarget)-ld"
38+
return "/opt/bin/$(target)/$(aatarget)-ld"
39+
end
40+
41+
function linker_string(bt::CMake{:clang}, p::AbstractPlatform, clang_use_lld)
42+
target = triplet(p)
43+
aatarget = aatriplet(p)
44+
return clang_use_lld ? "/opt/bin/$(target)/$(lld_string(p))" : "/opt/bin/$(target)/$(aatarget)-ld"
3945
end
4046

4147
function toolchain_file(bt::CMake, p::AbstractPlatform, host_platform::AbstractPlatform; is_host::Bool=false, clang_use_lld::Bool=false)
@@ -95,7 +101,7 @@ function toolchain_file(bt::CMake, p::AbstractPlatform, host_platform::AbstractP
95101
set(CMAKE_CXX_COMPILER /opt/bin/$(target)/$(aatarget)-$(cxx_compiler(bt)))
96102
set(CMAKE_Fortran_COMPILER /opt/bin/$(target)/$(aatarget)-$(fortran_compiler(bt)))
97103
98-
set(CMAKE_LINKER $(linker_string(p, clang_use_lld)))
104+
set(CMAKE_LINKER $(linker_string(bt, p, clang_use_lld)))
99105
set(CMAKE_OBJCOPY /opt/bin/$(target)/$(aatarget)-objcopy)
100106
101107
set(CMAKE_AR /opt/bin/$(target)/$(aatarget)-ar)
@@ -167,6 +173,18 @@ function meson_cpu_family(p::AbstractPlatform)
167173
end
168174
end
169175

176+
function linker_string(bt::Meson{:gcc}, p::AbstractPlatform, clang_use_lld)
177+
target = triplet(p)
178+
aatarget = aatriplet(p)
179+
return "bfd"
180+
end
181+
182+
function linker_string(bt::Meson{:clang}, p::AbstractPlatform, clang_use_lld)
183+
target = triplet(p)
184+
aatarget = aatriplet(p)
185+
return clang_use_lld ? "/opt/bin/$(target)/$(lld_string(p))" : "/opt/bin/$(target)/$(aatarget)-ld"
186+
end
187+
170188
function toolchain_file(bt::Meson, p::AbstractPlatform, envs::Dict{String,String};
171189
is_host::Bool=false, clang_use_lld::Bool=false)
172190
target = triplet(p)
@@ -179,9 +197,9 @@ function toolchain_file(bt::Meson, p::AbstractPlatform, envs::Dict{String,String
179197
fortran = '/opt/bin/$(target)/$(aatarget)-$(fortran_compiler(bt))'
180198
objc = '/opt/bin/$(target)/$(aatarget)-cc'
181199
ar = '/opt/bin/$(target)/$(aatarget)-ar'
182-
ld = '$(linker_string(p, clang_use_lld))'
183-
cpp_ld = '$(linker_string(p, clang_use_lld))'
184-
c_ld = '$(linker_string(p, clang_use_lld))'
200+
ld = '$(linker_string(bt, p, clang_use_lld))'
201+
cpp_ld = '$(linker_string(bt, p, clang_use_lld))'
202+
c_ld = '$(linker_string(bt, p, clang_use_lld))'
185203
nm = '/opt/bin/$(target)/$(aatarget)-nm'
186204
strip = '/opt/bin/$(target)/$(aatarget)-strip'
187205
pkgconfig = '/usr/bin/pkg-config'

src/Runner.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
792792
return wrapper(io, "/opt/$(host_target)/bin/lld"; env=Dict("LD_LIBRARY_PATH"=>ld_library_path(platform, host_platform; csl_paths=false)), allow_ccache=false,)
793793
function lld(io::IO, p::AbstractPlatform)
794794
return wrapper(io,
795-
"/opt/$(host_target)/bin/$(lld_str(p))";
795+
"/opt/$(host_target)/bin/$(lld_string(p))";
796796
env=Dict("LD_LIBRARY_PATH"=>ld_library_path(platform, host_platform; csl_paths=false)), allow_ccache=false,
797797
)
798798
end
@@ -877,7 +877,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
877877
else
878878
write_wrapper(ld, p, "ld.$(t)")
879879
end
880-
write_wrapper(lld,p,"$(t)-$(lld_str(p))")
880+
write_wrapper(lld,p,"$(t)-$(lld_string(p))")
881881
write_wrapper(lld_generic, p, "$(t)-lld")
882882
write_wrapper(nm, p, "$(t)-nm")
883883
write_wrapper(libtool, p, "$(t)-libtool")
@@ -944,7 +944,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
944944
elseif Sys.iswindows(platform)
945945
append!(default_tools, ("dlltool", "windres", "winmc"))
946946
end
947-
append!(default_tools, ("cc", "c++", "cpp", "f77", "gfortran", "gcc", "clang", "g++", "clang++", "lld", lld_str(platform)))
947+
append!(default_tools, ("cc", "c++", "cpp", "f77", "gfortran", "gcc", "clang", "g++", "clang++", "lld", lld_string(platform)))
948948
end
949949
if :rust in compilers
950950
append!(default_tools, ("rustc","rustup","cargo"))

0 commit comments

Comments
 (0)