@@ -39,8 +39,8 @@ struct CompilerShard
3939 # by higher-level things to choose e.g. which version of GCC
4040 # to use, but once we're at this level we only care about the
4141 # larger-scale things, not the ABI).
42- host = abi_agnostic (host)
43- if target != nothing
42+ host = abi_agnostic (host:: AbstractPlatform )
43+ if target != = nothing
4444 target = abi_agnostic (target)
4545 end
4646
@@ -64,8 +64,8 @@ Return the bound artifact name for a particular shard.
6464"""
6565function artifact_name (cs:: CompilerShard )
6666 target_str = " "
67- if cs. target != nothing
68- target_str = " -$(triplet (cs. target)) "
67+ if cs. target != = nothing
68+ target_str = " -$(triplet (cs. target:: Platform )) "
6969
7070 if cs. name in (" GCCBootstrap" , " PlatformSupport" )
7171 # armv6l uses the same GCC shards as armv7l, so we just rename here.
@@ -84,15 +84,15 @@ function CompilerShard(art_name::String)
8484 end
8585 return CompilerShard (
8686 m. captures[1 ],
87- VersionNumber (m. captures[3 ]),
87+ VersionNumber (m. captures[3 ]:: AbstractString ),
8888 m. captures[4 ],
8989 Symbol (m. captures[5 ]);
9090 target= m. captures[2 ]
9191 )
9292end
9393
9494const ALL_SHARDS = Ref {Union{Vector{CompilerShard},Nothing}} (nothing )
95- function all_compiler_shards ()
95+ function all_compiler_shards ():: Vector{CompilerShard}
9696 if ALL_SHARDS[] === nothing
9797 artifacts_toml = joinpath (dirname (@__DIR__ ), " Artifacts.toml" )
9898 artifact_dict = load_artifacts_toml (artifacts_toml)
@@ -114,13 +114,13 @@ function all_compiler_shards()
114114 end
115115
116116 # If this compiler shard has an os_version, that should be interpreted as the bound it is.
117- if cs. target != = nothing && os_version (cs. target) != = nothing
118- set_compare_strategy! (cs. target, " os_version" , compare_version_cap)
117+ if cs. target != = nothing && os_version (cs. target:: Platform ) != = nothing
118+ set_compare_strategy! (cs. target:: Platform , " os_version" , compare_version_cap)
119119 end
120- push! (ALL_SHARDS[], cs)
120+ push! (ALL_SHARDS[]:: Vector{CompilerShard} , cs)
121121 end
122122 end
123- return ALL_SHARDS[]
123+ return ALL_SHARDS[]:: Vector{CompilerShard}
124124end
125125
126126function shard_source_artifact_hash (cs:: CompilerShard )
@@ -168,7 +168,7 @@ function map_target(cs::CompilerShard)
168168 return " /"
169169 elseif lowercase (cs. name) == " rusttoolchain"
170170 # We override RustToolchain because they all have to sit in the same location
171- return " /opt/$(aatriplet (cs. host)) /$(cs. name) -$(cs. version) -$(aatriplet (cs. target)) )"
171+ return " /opt/$(aatriplet (cs. host)) /$(cs. name) -$(cs. version) -$(aatriplet (cs. target:: Platform )) )"
172172 else
173173 return joinpath (" /opt" , aatriplet (something (cs. target, cs. host)), " $(cs. name) -$(cs. version) " )
174174 end
@@ -231,7 +231,7 @@ function mount(cs::CompilerShard, build_prefix::AbstractString; verbose::Bool =
231231 # they must accept the Xcode EULA. This will be skipped if either the
232232 # environment variable BINARYBUILDER_AUTOMATIC_APPLE has been set to `true`
233233 # or if the SDK has been downloaded in the past.
234- if cs. target != = nothing && Sys. isapple (cs. target) && ! isfile (enable_apple_file ()) && ! macos_sdk_already_installed ()
234+ if cs. target != = nothing && Sys. isapple (cs. target:: Platform ) && ! isfile (enable_apple_file ()) && ! macos_sdk_already_installed ()
235235 if ! isinteractive ()
236236 msg = strip ("""
237237 This is not an interactive Julia session, so we will not prompt you
@@ -343,7 +343,7 @@ Returns `true` if any piece of the MacOS SDK is already installed.
343343function macos_sdk_already_installed ()
344344 # Get all compiler shards we know about
345345 css = all_compiler_shards ()
346- macos_artifact_names = artifact_name .(filter (cs -> cs. target != = nothing && Sys. isapple (cs. target), css))
346+ macos_artifact_names = artifact_name .(filter (cs -> cs. target != = nothing && Sys. isapple (cs. target:: Platform ), css))
347347
348348 artifacts_toml = joinpath (dirname (@__DIR__ ), " Artifacts.toml" )
349349 macos_artifact_hashes = artifact_hash .(macos_artifact_names, artifacts_toml; platform= default_host_platform)
481481
482482function llvm_version (p:: AbstractPlatform , LLVM_builds:: Vector{LLVMBuild} )
483483 if march (p) in (" armv8_2_crypto" , " armv8_4_crypto_sve" )
484- LLVM_builds = filter (b -> getversion (b) >= v " 9.0" )
484+ LLVM_builds = filter (b -> getversion (b) >= v " 9.0" , LLVM_builds )
485485 end
486486 return getversion .(LLVM_builds)
487487end
@@ -527,7 +527,7 @@ function choose_shards(p::AbstractPlatform;
527527 LLVM_builds:: Vector{LLVMBuild} = available_llvm_builds,
528528 Rust_build:: VersionNumber = v " 1.57.0" ,
529529 Go_build:: VersionNumber = v " 1.16.3" ,
530- archive_type:: Symbol = (use_squashfs ? :squashfs : :unpacked ),
530+ archive_type:: Symbol = (use_squashfs[] ? :squashfs : :unpacked ),
531531 bootstrap_list:: Vector{Symbol} = bootstrap_list,
532532 # Because GCC has lots of compatibility issues, we always default to
533533 # the earliest version possible.
@@ -714,7 +714,7 @@ matching. If the given `Platform` already specifies a `libgfortran_version`
714714"""
715715function expand_gfortran_versions (platform:: AbstractPlatform )
716716 # If this platform is already explicitly libgfortran-versioned, exit out fast here.
717- if libgfortran_version (platform) != nothing
717+ if libgfortran_version (platform) != = nothing
718718 return [platform]
719719 end
720720
@@ -857,11 +857,11 @@ function preferred_libgfortran_version(platform::AbstractPlatform, shard::Compil
857857 if shard. name != " GCCBootstrap"
858858 error (" Shard must be `GCCBootstrap`" )
859859 end
860- if arch (shard. target) != arch (platform) || libc (shard. target) != libc (platform)
860+ if arch (shard. target:: Platform ) != arch (platform) || libc (shard. target:: Platform ) != libc (platform)
861861 error (" Incompatible platform and shard target" )
862862 end
863863
864- if libgfortran_version (platform) != nothing
864+ if libgfortran_version (platform) != = nothing
865865 # Here we can't use `shard.target` because the shard always has the
866866 # target as ABI-agnostic, thus we have also to ask for the platform.
867867 return libgfortran_version (platform)
@@ -887,11 +887,11 @@ function preferred_cxxstring_abi(platform::AbstractPlatform, shard::CompilerShar
887887 if shard. name != " GCCBootstrap"
888888 error (" Shard must be `GCCBootstrap`" )
889889 end
890- if arch (shard. target) != arch (platform) || libc (shard. target) != libc (platform)
890+ if arch (shard. target:: Platform ) != arch (platform) || libc (shard. target:: Platform ) != libc (platform)
891891 error (" Incompatible platform and shard target" )
892892 end
893893
894- if cxxstring_abi (platform) != nothing
894+ if cxxstring_abi (platform) != = nothing
895895 # Here we can't use `shard.target` because the shard always has the
896896 # target as ABI-agnostic, thus we have also to ask for the platform.
897897 return cxxstring_abi (platform)
@@ -922,26 +922,26 @@ function download_all_artifacts(; verbose::Bool = false)
922922 )
923923end
924924
925- _sudo_cmd = nothing
926- function sudo_cmd ()
925+ const _sudo_cmd = Ref {Union{Cmd,Nothing}} ( nothing )
926+ function sudo_cmd ():: Cmd
927927 global _sudo_cmd
928928
929929 # Use cached value if we've already run this
930- if _sudo_cmd ! = nothing
931- return _sudo_cmd
930+ if _sudo_cmd[] != = nothing
931+ return _sudo_cmd[] :: Cmd
932932 end
933933
934- if getuid () == 0
934+ _sudo_cmd[] = if getuid () == 0
935935 # If we're already root, don't use any kind of sudo program
936- _sudo_cmd = ` `
936+ ` `
937937 elseif success (` sudo -V` )
938938 # If `sudo` is available, use that
939- _sudo_cmd = ` sudo`
939+ ` sudo`
940940 else
941941 # Fall back to `su` if all else fails
942- _sudo_cmd = ` su root -c`
942+ ` su root -c`
943943 end
944- return _sudo_cmd
944+ return _sudo_cmd[] :: Cmd
945945end
946946
947947"""
0 commit comments