675
675
choose_shards (:: AnyPlatform ; kwargs... ) = choose_shards (default_host_platform; kwargs... )
676
676
677
677
"""
678
- supported_platforms(;exclude::Union{Vector{<:Platform},Function}=x-> false,
678
+ supported_platforms(;exclude::Union{Vector{<:Platform},Function}=Returns( false) ,
679
679
experimental::Bool=false)
680
680
681
681
Return the list of supported platforms as an array of `Platform`s. These are the platforms we
@@ -690,7 +690,7 @@ or a function that returns true for exclusions i.e.
690
690
supported_platforms(exclude=Sys.islinux)
691
691
```
692
692
"""
693
- function supported_platforms (;exclude:: Union{Vector{<:Platform},Function} = x -> false ,
693
+ function supported_platforms (;exclude:: Union{Vector{<:Platform},Function} = Returns ( false ) ,
694
694
experimental:: Bool = false )
695
695
exclude_platforms! (platforms, exclude:: Function ) = filter (! exclude, platforms)
696
696
exclude_platforms! (platforms, exclude:: Vector{<:Platform} ) = filter! (! in (exclude), platforms)
@@ -796,11 +796,12 @@ function expand_cxxstring_abis(ps::Vector{<:AbstractPlatform}; kwargs...)
796
796
end
797
797
798
798
"""
799
- expand_microarchitectures(p::AbstractPlatform)
799
+ expand_microarchitectures(p::AbstractPlatform, [microarchitectures::Vector{String}] )
800
800
801
801
Given a `Platform`, returns a vector of `Platforms` with differing `march` attributes
802
802
as specified by the `ARCHITECTURE_FLAGS` mapping. If the given `Platform` alread has a
803
- `march` tag specified, only that platform is returned.
803
+ `march` tag specified, only that platform is returned. If the `microarchitectures`
804
+ argument is given, limit the expansion to the given microarchitectures.
804
805
805
806
```jldoctest
806
807
julia> using BinaryBuilderBase
@@ -817,28 +818,30 @@ julia> expand_microarchitectures(Platform("armv7l", "linux"))
817
818
Linux armv7l {call_abi=eabihf, libc=glibc, march=armv7l}
818
819
Linux armv7l {call_abi=eabihf, libc=glibc, march=neonvfpv4}
819
820
820
- julia> expand_microarchitectures(Platform("aarch64", "linux"))
821
- 4 -element Vector{Platform}:
821
+ julia> expand_microarchitectures(Platform("aarch64", "linux"), ["armv8_0", "a64fx"] )
822
+ 2 -element Vector{Platform}:
822
823
Linux aarch64 {libc=glibc, march=armv8_0}
823
- Linux aarch64 {libc=glibc, march=armv8_4_crypto_sve}
824
- Linux aarch64 {libc=glibc, march=armv8_2_crypto}
825
- Linux aarch64 {libc=glibc, march=armv8_1}
824
+ Linux aarch64 {libc=glibc, march=a64fx}
826
825
827
826
julia> expand_microarchitectures(Platform("i686", "windows"))
828
827
2-element Vector{Platform}:
829
828
Windows i686 {march=pentium4}
830
829
Windows i686 {march=prescott}
831
830
```
832
831
"""
833
- function expand_microarchitectures (platform:: AbstractPlatform )
834
- # If this already has a `march`, or it's an `AnyPlatform`, just return it.
835
- if isa (platform, AnyPlatform) || march (platform) != = nothing
832
+ function expand_microarchitectures (platform:: AbstractPlatform ,
833
+ microarchitectures:: Vector{String} = get_all_march_names (arch (platform)))
834
+ all_marchs = get_all_march_names (arch (platform))
835
+
836
+ # If this already has a `march`, or it's an `AnyPlatform`, or the microarchitectures we
837
+ # want to expand aren't relative to this platform, just return it.
838
+ if isa (platform, AnyPlatform) || march (platform) != = nothing ||
839
+ ! any (in (all_marchs), microarchitectures)
836
840
return [platform]
837
841
end
838
842
839
- # Otherwise, return a bunch of Platform objects with appropriately-set `march` tags, but
840
- # first filter out some meaningless combinations of microarchitectures.
841
- all_marchs = filter (get_all_march_names (arch (platform))) do march
843
+ # First, filter out some meaningless combinations of microarchitectures.
844
+ marchs = filter (all_marchs) do march
842
845
if (! Sys. isapple (platform) && march == " apple_m1" ) ||
843
846
(Sys. isapple (platform) && arch (platform) == " aarch64" && march ∉ (" armv8_0" , " apple_m1" ))
844
847
# `apple_m1` makes sense only on macOS, and the only aarch64 microarchitectures
@@ -851,39 +854,89 @@ function expand_microarchitectures(platform::AbstractPlatform)
851
854
return true
852
855
end
853
856
854
- return map (all_marchs) do march
855
- p = deepcopy (platform)
856
- p[ " march " ] = march
857
- return p
857
+ # But if none of the remaining microarchitectures are among those we want to expand,
858
+ # return the given platform as is.
859
+ if ! any ( in (microarchitectures), marchs)
860
+ return [platform]
858
861
end
862
+
863
+ # Otherwise, return a bunch of Platform objects with appropriately-set `march` tags
864
+ return [(p = deepcopy (platform); p[" march" ] = march; p) for march in marchs if march in microarchitectures]
859
865
end
860
866
861
867
"""
862
- expand_microarchitectures(ps::Vector{<:Platform})
868
+ expand_microarchitectures(ps::Vector{<:Platform}, [microarchitectures::Vector{String}];
869
+ filter=Returns(true))
870
+
871
+ Expand all platforms in the vector `ps` with the supported microarchitectures.
863
872
864
- Expand all platforms in the given vector with the supported microarchitectures.
873
+ If the `microarchitectures` argument is given, limit the expansion to the given
874
+ platforms. This is useful if you do not want to expand to all available
875
+ microarchitectures.
876
+
877
+ The expansion is applied only to the platforms matching the `filter` predicate, by
878
+ default all platforms. This is useful if you want to limit the expansion to some
879
+ platforms, without having to explicitly list its microarchitectures in the second
880
+ argument.
865
881
866
882
```jldoctest
867
883
julia> using BinaryBuilderBase
868
884
869
885
julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()))
870
- 13 -element Vector{Platform}:
886
+ 14 -element Vector{Platform}:
871
887
Linux i686 {libc=glibc, march=pentium4}
872
888
Linux i686 {libc=glibc, march=prescott}
873
889
Linux x86_64 {libc=glibc, march=x86_64}
874
890
Linux x86_64 {libc=glibc, march=avx}
875
891
Linux x86_64 {libc=glibc, march=avx2}
876
892
Linux x86_64 {libc=glibc, march=avx512}
877
893
Linux aarch64 {libc=glibc, march=armv8_0}
878
- Linux aarch64 {libc=glibc, march=armv8_4_crypto_sve}
879
- Linux aarch64 {libc=glibc, march=armv8_2_crypto}
880
894
Linux aarch64 {libc=glibc, march=armv8_1}
895
+ Linux aarch64 {libc=glibc, march=armv8_2_crypto}
896
+ Linux aarch64 {libc=glibc, march=a64fx}
897
+ Linux armv6l {call_abi=eabihf, libc=glibc, march=arm1176jzfs}
881
898
Linux armv7l {call_abi=eabihf, libc=glibc, march=armv7l}
882
899
Linux armv7l {call_abi=eabihf, libc=glibc, march=neonvfpv4}
883
900
Linux powerpc64le {libc=glibc, march=power8}
901
+
902
+ julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()), ["x86_64", "avx2"])
903
+ 7-element Vector{Platform}:
904
+ Linux i686 {libc=glibc}
905
+ Linux x86_64 {libc=glibc, march=x86_64}
906
+ Linux x86_64 {libc=glibc, march=avx2}
907
+ Linux aarch64 {libc=glibc}
908
+ Linux armv6l {call_abi=eabihf, libc=glibc}
909
+ Linux armv7l {call_abi=eabihf, libc=glibc}
910
+ Linux powerpc64le {libc=glibc}
911
+
912
+ julia> expand_microarchitectures(filter!(p -> Sys.islinux(p) && libc(p) == "glibc", supported_platforms()); filter=p->arch(p)=="x86_64")
913
+ 9-element Vector{Platform}:
914
+ Linux i686 {libc=glibc}
915
+ Linux x86_64 {libc=glibc, march=x86_64}
916
+ Linux x86_64 {libc=glibc, march=avx}
917
+ Linux x86_64 {libc=glibc, march=avx2}
918
+ Linux x86_64 {libc=glibc, march=avx512}
919
+ Linux aarch64 {libc=glibc}
920
+ Linux armv6l {call_abi=eabihf, libc=glibc}
921
+ Linux armv7l {call_abi=eabihf, libc=glibc}
922
+ Linux powerpc64le {libc=glibc}
884
923
```
885
924
"""
886
- expand_microarchitectures (ps:: Vector{<:AbstractPlatform} ) = collect (Iterators. flatten (expand_microarchitectures .(ps)))
925
+ function expand_microarchitectures (ps:: Vector{<:AbstractPlatform} ,
926
+ microarchitectures:: Vector{String} = collect (Iterators. flatten (get_all_march_names .(unique! (arch .(ps)))));
927
+ filter= Returns (true ),
928
+ )
929
+ out = map (ps) do p
930
+ return if filter (p)
931
+ # If the platform satisfies the predicate, expand its microarchitectures
932
+ expand_microarchitectures (p, microarchitectures)
933
+ else
934
+ # otherwise return it as-is.
935
+ [p]
936
+ end
937
+ end
938
+ return collect (Iterators. flatten (out))
939
+ end
887
940
888
941
"""
889
942
preferred_libgfortran_version(platform::AbstractPlatform, shard::CompilerShard;
0 commit comments