@@ -155,7 +155,7 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin
155
155
# On macOS, if we're on an old GCC, the default -syslibroot that gets
156
156
# passed to the linker isn't calculated correctly, so we have to manually set it.
157
157
if select_gcc_version (p). major == 4
158
- FLAGS *= " -Wl,-syslibroot,/opt/$(target) /$(target ) /sys-root"
158
+ FLAGS *= " -Wl,-syslibroot,/opt/$(triplet (p)) /$(triplet (p) ) /sys-root"
159
159
end
160
160
return FLAGS
161
161
end
@@ -169,7 +169,7 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin
169
169
# On macOS, if we're on an old GCC, the default -syslibroot that gets
170
170
# passed to the linker isn't calculated correctly, so we have to manually set it.
171
171
if select_gcc_version (p). major == 4
172
- FLAGS *= " -Wl,-syslibroot,/opt/$(target) /$(target ) /sys-root"
172
+ FLAGS *= " -Wl,-syslibroot,/opt/$(triplet (p)) /$(triplet (p) ) /sys-root"
173
173
end
174
174
return FLAGS
175
175
end
@@ -187,25 +187,27 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin
187
187
# Next, on MacOS, we need to override the typical C++ include search paths, because it always includes
188
188
# the toolchain C++ headers first. Valentin tracked this down to:
189
189
# https://github.com/llvm/llvm-project/blob/0378f3a90341d990236c44f297b923a32b35fab1/clang/lib/Driver/ToolChains/Darwin.cpp#L1944-L1978
190
- FLAGS *= " -nostdinc++ -isystem /opt/$(target) /$(target ) /sys-root/usr/include/c++/v1"
190
+ FLAGS *= " -nostdinc++ -isystem /opt/$(triplet (p)) /$(triplet (p) ) /sys-root/usr/include/c++/v1"
191
191
return FLAGS
192
192
end
193
193
194
+ # On FreeBSD, our clang flags are simple
194
195
clang_flags (p:: FreeBSD ) = clang_targeting_laser (p)
195
- # For everything else, there's MasterCard (TM) (.... also, we need to provide `-rtlib=libgcc` because clang-builtins are broken)
196
- clang_flags (p:: Platform ) = " $(clang_targeting_laser (p)) --gcc-toolchain=/opt/$(triplet (p)) -rtlib=libgcc"
196
+
197
+ # For everything else, there's MasterCard (TM) (.... also, we need to provide `-rtlib=libgcc` because clang-builtins are broken,
198
+ # and we also need to provide `-stdlib=libstdc++` to match Julia on these platforms.)
199
+ clang_flags (p:: Platform ) = " $(clang_targeting_laser (p)) --gcc-toolchain=/opt/$(triplet (p)) -rtlib=libgcc -stdlib=libstdc++"
197
200
198
201
199
202
# On macos, we want to use a particular linker with clang. But we want to avoid warnings about unused
200
203
# flags when just compiling, so we put it into "linker-only flags".
201
- clang_link_flags (p:: Platform ) = String[]
202
- clang_link_flags (p:: FreeBSD ) = [" -L/opt/$(target) /$(target) /lib" ]
203
- clang_link_flags (p:: MacOS ) = [" -L/opt/$(target) /$(target) /lib" , " -fuse-ld=macos" ]
204
+ clang_link_flags (p:: Platform ) = String[" -fuse-ld=$(triplet (p)) " ]
205
+ clang_link_flags (p:: Union{FreeBSD,MacOS} ) = [" -L/opt/$(triplet (p)) /$(triplet (p)) /lib" , " -fuse-ld=$(triplet (p)) " ]
204
206
205
207
gcc_link_flags (p:: Platform ) = String[]
206
208
function gcc_link_flags (p:: Linux )
207
209
if arch (p) == :powerpc64le && select_gcc_version (p). major == 4
208
- return [" -L/opt/$(target) /$(target) /sys-root/lib64" , " -Wl,-rpath-link,/opt/$(target) /$(target ) /sys-root/lib64" ]
210
+ return [" -L/opt/$(triplet (p)) /$(triplet (p)) /sys-root/lib64" , " -Wl,-rpath-link,/opt/$(triplet (p)) /$(triplet (p) ) /sys-root/lib64" ]
209
211
end
210
212
return String[]
211
213
end
@@ -320,6 +322,12 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin
320
322
write_wrapper (cpp, p, " $(t) -cpp" )
321
323
write_wrapper (cxxfilt, p, " $(t) -c++filt" )
322
324
write_wrapper (ld, p, " $(t) -ld" )
325
+ # ld wrappers for clang's `-fuse-ld=$(target)`
326
+ if isa (p, MacOS)
327
+ write_wrapper (ld, p, " ld64.$(t) " )
328
+ else
329
+ write_wrapper (ld, p, " ld.$(t) " )
330
+ end
323
331
write_wrapper (nm, p, " $(t) -nm" )
324
332
write_wrapper (libtool, p, " $(t) -libtool" )
325
333
write_wrapper (objcopy, p, " $(t) -objcopy" )
0 commit comments