@@ -108,34 +108,31 @@ const gcc_version_sources = Dict{VersionNumber,Vector}(
108
108
ArchiveSource (" https://mirrors.kernel.org/gnu/gmp/gmp-6.1.2.tar.xz" ,
109
109
" 87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912" ),
110
110
],
111
- v " 14.1 .0" => [
112
- ArchiveSource (" https://mirrors.kernel.org/gnu/gcc/gcc-14.1 .0/gcc-14.1 .0.tar.xz" ,
113
- " e283c654987afe3de9d8080bc0bd79534b5ca0d681a73a11ff2b5d3767426840 " ),
111
+ v " 14.2 .0" => [
112
+ ArchiveSource (" https://mirrors.kernel.org/gnu/gcc/gcc-14.2 .0/gcc-14.2 .0.tar.xz" ,
113
+ " a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9 " ),
114
114
ArchiveSource (" https://mirrors.kernel.org/gnu/mpfr/mpfr-4.1.0.tar.xz" ,
115
115
" 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f" ,
116
- target= " gcc-14.1 .0" ),
116
+ target= " gcc-14.2 .0" ),
117
117
ArchiveSource (" https://mirrors.kernel.org/gnu/mpc/mpc-1.2.1.tar.gz" ,
118
118
" 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459" ,
119
- target= " gcc-14.1 .0" ),
119
+ target= " gcc-14.2 .0" ),
120
120
ArchiveSource (" https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.24.tar.bz2" ,
121
121
" fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0" ,
122
- target= " gcc-14.1 .0" ),
122
+ target= " gcc-14.2 .0" ),
123
123
ArchiveSource (" https://mirrors.kernel.org/gnu/gmp/gmp-6.2.1.tar.xz" ,
124
124
" fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2" ,
125
- target= " gcc-14.1 .0" ),
125
+ target= " gcc-14.2 .0" ),
126
126
],
127
127
)
128
128
129
129
130
130
script = raw """
131
131
cd ${WORKSPACE}/srcdir
132
132
133
- # Move all `target` dependencies over to the `host` prefix,
134
- # because we need those deps available in the `host` prefix
135
-
136
133
# Figure out the GCC version from the directory name
137
134
gcc_version="$(echo gcc-* | cut -d- -f2)"
138
- if [[ "${target}" != *mingw* ]]; then
135
+ if [[ "${target}" != *mingw* ]] && [[ "${target}" != *darwin* ]] ; then
139
136
lib64="lib${target_nbits%32}"
140
137
else
141
138
lib64="lib"
@@ -151,6 +148,14 @@ done
151
148
# Initialize GCC_CONF_ARGS
152
149
GCC_CONF_ARGS=()
153
150
151
+ ## If we're doing a bootstrapping build (GCC does not, GCCBootstrapMacOS does)
152
+ # add in the appropriate configure arguments:
153
+ if [[ "${GCC_ENABLE_BOOTSTRAP:-false}" == "true" ]]; then
154
+ GCC_CONF_ARGS+=( --enable-bootstrap )
155
+ else
156
+ GCC_CONF_ARGS+=( --disable-bootstrap )
157
+ fi
158
+
154
159
## Architecture-dependent arguments
155
160
# Choose a default arch, and on arm*hf targets, pass `--with-float=hard` explicitly
156
161
if [[ "${target}" == arm*hf ]]; then
@@ -194,6 +199,16 @@ elif [[ "${target}" == *-darwin* ]]; then
194
199
# that are available only starting in later macOS versions such as `clock_gettime` or `mkostemp`
195
200
export ac_cv_func_clock_gettime=no
196
201
export ac_cv_func_mkostemp=no
202
+
203
+ # Force GCC to use its own libiconv, don't use Apple's
204
+ ICONV_PATHS=(
205
+ /opt/target-*
206
+ ${target_prefix}
207
+ )
208
+ if [[ "${host}" == *-darwin* ]]; then
209
+ ICONV_PATHS+=( /opt/host-* )
210
+ fi
211
+ find ${ICONV_PATHS[@]} -name iconv.h -o -name libiconv\* | xargs rm -fv
197
212
fi
198
213
199
214
# Get rid of version numbers at the end of GCC deps
@@ -228,9 +243,12 @@ for TOOL in CC CPP CXX AS AR NM LD RANLIB; do
228
243
export ${TOOL}_FOR_TARGET=${!TARGET_NAME}
229
244
230
245
# These target tool autodetections do not work
231
- export ac_cv_path_${TOOL}_FOR_TARGET=${!TARGET_NAME}
246
+ # export ac_cv_path_${TOOL}_FOR_TARGET=${!TARGET_NAME}
232
247
done
233
248
249
+ # libcc1 fails with an error about `-rdynamic` unless we defien this
250
+ export gcc_cv_nm="${NM_FOR_TARGET}"
251
+
234
252
# Make sure the tools that GCC itself wants to use ("ld", "as", "dysmutil") are available
235
253
# not just as "host-ld" or "host-as", etc... Otherwise, the `collect2` we generate looks
236
254
# for these names. This lovely mess of bash results in `--with-ld=x86_64-linux-gnu-ld`
@@ -252,7 +270,6 @@ $WORKSPACE/srcdir/gcc-*/configure \
252
270
--target="${target}" \
253
271
--disable-multilib \
254
272
--disable-werror \
255
- --disable-bootstrap \
256
273
--enable-threads=posix \
257
274
--enable-languages=c,c++ \
258
275
--with-build-sysroot="${target_prefix}/${target}" \
@@ -275,6 +292,16 @@ install_license ${WORKSPACE}/srcdir/gcc-*/COPYING*
275
292
"""
276
293
277
294
function gcc_extract_spec_generator (build:: BuildConfig , platform:: AbstractPlatform )
295
+ gcc_crt_object_names = [" libgcc.a" ]
296
+ if Sys. isapple (platform. target)
297
+ append! (gcc_crt_object_names, [" crttms.o" , " crt3.o" ])
298
+ else
299
+ append! (gcc_crt_object_names, [" crtbegin.o" , " crtend.o" ])
300
+ end
301
+ gcc_crt_object_products = [
302
+ FileProduct ([string (raw " lib/gcc/${target}/${gcc_version}/" , name)],
303
+ Symbol (replace (name, " ." => " _" ))) for name in gcc_crt_object_names
304
+ ]
278
305
return Dict (
279
306
" libstdcxx" => ExtractSpec (
280
307
raw """
@@ -312,11 +339,7 @@ function gcc_extract_spec_generator(build::BuildConfig, platform::AbstractPlatfo
312
339
raw """
313
340
extract ${prefix}/lib/gcc/${target}/${gcc_version}
314
341
""" ,
315
- [
316
- FileProduct ([raw " lib/gcc/${target}/${gcc_version}/crtbegin.o" ], :crtbegin_o ),
317
- FileProduct ([raw " lib/gcc/${target}/${gcc_version}/crtend.o" ], :crtend_o ),
318
- FileProduct ([raw " lib/gcc/${target}/${gcc_version}/libgcc.a" ], :libgcc_a ),
319
- ],
342
+ gcc_crt_object_products,
320
343
get_target_spec_by_name (build, " host" );
321
344
platform = platform. target,
322
345
),
@@ -369,14 +392,25 @@ target_platforms = [
369
392
370
393
Platform (" x86_64" , " windows" ),
371
394
Platform (" i686" , " windows" ),
395
+
396
+ Platform (" x86_64" , " macos" ),
397
+ Platform (" aarch64" , " macos" ),
372
398
]
373
399
374
- platforms = vcat (
375
- # Build cross-gcc from `host => target`
376
- (CrossPlatform (host, target) for host in host_platforms, target in target_platforms if host != target). .. ,
377
- # Build native gcc for all targets as well
378
- (CrossPlatform (target, target) for target in target_platforms). .. ,
379
- )
400
+ function gcc_platforms (version:: VersionNumber )
401
+ platforms = vcat (
402
+ # Build cross-gcc from `host => target`
403
+ (CrossPlatform (host, target) for host in host_platforms, target in target_platforms if host != target). .. ,
404
+ # Build native gcc for all targets as well
405
+ (CrossPlatform (target, target) for target in target_platforms). .. ,
406
+ )
407
+ # aarch64-apple-darwin can't be targeted by GCC versions before
408
+ # Iain Sandoe's legendary porting effort.
409
+ if version < v " 12"
410
+ filter! (p -> ! (os (p) == " macos" && arch (p) == " aarch64" ), platforms)
411
+ end
412
+ return platforms
413
+ end
380
414
381
415
function gcc_build_spec_generator (host, platform)
382
416
target_str = triplet (gcc_platform (platform. target))
@@ -436,6 +470,17 @@ function gcc_build_spec_generator(host, platform)
436
470
),
437
471
target= target_str,
438
472
))
473
+ elseif os (platform. target) == " macos"
474
+ push! (target_sources, JLLSource (
475
+ " macOSSDK_jll" ,
476
+ platform. target;
477
+ uuid= Base. UUID (" 52f8e75f-aed1-5264-b4c9-b8da5a6d5365" ),
478
+ repo= Pkg. Types. GitRepo (
479
+ rev= " main" ,
480
+ source= " https://github.com/staticfloat/macOSSDK_jll.jl"
481
+ ),
482
+ target= target_str,
483
+ ))
439
484
else
440
485
throw (ArgumentError (" Don't know how to install libc sources for $(triplet (platform. target)) " ))
441
486
end
@@ -444,21 +489,21 @@ function gcc_build_spec_generator(host, platform)
444
489
BuildTargetSpec (
445
490
" build" ,
446
491
CrossPlatform (host => host),
447
- [CToolchain (; vendor= :bootstrap , lock_microarchitecture), HostToolsToolchain ()],
492
+ [CToolchain (; vendor= :gcc_bootstrap , lock_microarchitecture), HostToolsToolchain ()],
448
493
[],
449
494
Set ([:host ]),
450
495
),
451
496
BuildTargetSpec (
452
497
" host" ,
453
498
CrossPlatform (host => platform. host),
454
- [CToolchain (; vendor= :bootstrap , lock_microarchitecture)],
499
+ [CToolchain (; vendor= :gcc_bootstrap , lock_microarchitecture)],
455
500
[],
456
501
Set ([:default ]),
457
502
),
458
503
BuildTargetSpec (
459
504
" target" ,
460
505
CrossPlatform (host => platform. target),
461
- [CToolchain (; vendor= :bootstrap , lock_microarchitecture)],
506
+ [CToolchain (; vendor= :gcc_bootstrap , lock_microarchitecture)],
462
507
target_sources,
463
508
Set ([]),
464
509
),
0 commit comments