Skip to content

Commit 3e0815e

Browse files
authored
[Platforms] Fix flags for aarch64 microarchitectures (#205)
1 parent 75a3246 commit 3e0815e

File tree

6 files changed

+132
-81
lines changed

6 files changed

+132
-81
lines changed

Manifest.toml

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,186 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
[[ArgTools]]
3+
julia_version = "1.7.2"
4+
manifest_format = "2.0"
5+
6+
[[deps.ArgTools]]
47
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
58

6-
[[Artifacts]]
9+
[[deps.Artifacts]]
710
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
811

9-
[[Base64]]
12+
[[deps.Base64]]
1013
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
1114

12-
[[CodecZlib]]
15+
[[deps.CodecZlib]]
1316
deps = ["TranscodingStreams", "Zlib_jll"]
1417
git-tree-sha1 = "ded953804d019afa9a3f98981d99b33e3db7b6da"
1518
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
1619
version = "0.7.0"
1720

18-
[[Dates]]
21+
[[deps.Dates]]
1922
deps = ["Printf"]
2023
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
2124

22-
[[Downloads]]
25+
[[deps.Downloads]]
2326
deps = ["ArgTools", "LibCURL", "NetworkOptions"]
2427
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
2528

26-
[[InteractiveUtils]]
29+
[[deps.InteractiveUtils]]
2730
deps = ["Markdown"]
2831
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
2932

30-
[[JLLWrappers]]
33+
[[deps.JLLWrappers]]
3134
deps = ["Preferences"]
3235
git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1"
3336
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
3437
version = "1.4.1"
3538

36-
[[JSON]]
39+
[[deps.JSON]]
3740
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
3841
git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e"
3942
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
4043
version = "0.21.3"
4144

42-
[[LibCURL]]
45+
[[deps.LibCURL]]
4346
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
4447
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
4548

46-
[[LibCURL_jll]]
49+
[[deps.LibCURL_jll]]
4750
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
4851
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
4952

50-
[[LibGit2]]
53+
[[deps.LibGit2]]
5154
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
5255
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
5356

54-
[[LibGit2_jll]]
57+
[[deps.LibGit2_jll]]
5558
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
5659
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
5760

58-
[[LibSSH2_jll]]
61+
[[deps.LibSSH2_jll]]
5962
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
6063
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
6164

62-
[[Libdl]]
65+
[[deps.Libdl]]
6366
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
6467

65-
[[Logging]]
68+
[[deps.Logging]]
6669
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
6770

68-
[[Markdown]]
71+
[[deps.Markdown]]
6972
deps = ["Base64"]
7073
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
7174

72-
[[MbedTLS_jll]]
75+
[[deps.MbedTLS_jll]]
7376
deps = ["Artifacts", "Libdl"]
7477
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
7578

76-
[[Mmap]]
79+
[[deps.Mmap]]
7780
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
7881

79-
[[MozillaCACerts_jll]]
82+
[[deps.MozillaCACerts_jll]]
8083
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
8184

82-
[[NetworkOptions]]
85+
[[deps.NetworkOptions]]
8386
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
8487

85-
[[OutputCollectors]]
88+
[[deps.OrderedCollections]]
89+
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
90+
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
91+
version = "1.4.1"
92+
93+
[[deps.OutputCollectors]]
8694
git-tree-sha1 = "5d3f2b3b2e2a9d7d6f1774c78e94530ac7f360cc"
8795
uuid = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
8896
version = "0.1.1"
8997

90-
[[Parsers]]
98+
[[deps.Parsers]]
9199
deps = ["Dates"]
92-
git-tree-sha1 = "13468f237353112a01b2d6b32f3d0f80219944aa"
100+
git-tree-sha1 = "85b5da0fa43588c75bb1ff986493443f821c70b7"
93101
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
94-
version = "2.2.2"
102+
version = "2.2.3"
95103

96-
[[Pkg]]
104+
[[deps.Pkg]]
97105
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
98106
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
99107

100-
[[Preferences]]
108+
[[deps.Preferences]]
101109
deps = ["TOML"]
102-
git-tree-sha1 = "2cf929d64681236a2e074ffafb8d568733d2e6af"
110+
git-tree-sha1 = "d3538e7f8a790dc8903519090857ef8e1283eecd"
103111
uuid = "21216c6a-2e73-6563-6e65-726566657250"
104-
version = "1.2.3"
112+
version = "1.2.5"
105113

106-
[[Printf]]
114+
[[deps.Printf]]
107115
deps = ["Unicode"]
108116
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
109117

110-
[[REPL]]
118+
[[deps.REPL]]
111119
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
112120
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
113121

114-
[[Random]]
122+
[[deps.Random]]
115123
deps = ["SHA", "Serialization"]
116124
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
117125

118-
[[SHA]]
126+
[[deps.SHA]]
119127
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
120128

121-
[[Scratch]]
129+
[[deps.Scratch]]
122130
deps = ["Dates"]
123131
git-tree-sha1 = "0b4b7f1393cff97c33891da2a0bf69c6ed241fda"
124132
uuid = "6c6a2e73-6563-6170-7368-637461726353"
125133
version = "1.1.0"
126134

127-
[[Serialization]]
135+
[[deps.Serialization]]
128136
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
129137

130-
[[SimpleBufferStream]]
138+
[[deps.SimpleBufferStream]]
131139
git-tree-sha1 = "874e8867b33a00e784c8a7e4b60afe9e037b74e1"
132140
uuid = "777ac1f9-54b0-4bf8-805c-2214025038e7"
133141
version = "1.1.0"
134142

135-
[[Sockets]]
143+
[[deps.Sockets]]
136144
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
137145

138-
[[TOML]]
146+
[[deps.TOML]]
139147
deps = ["Dates"]
140148
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
141149

142-
[[Tar]]
150+
[[deps.Tar]]
143151
deps = ["ArgTools", "SHA"]
144152
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
145153

146-
[[Test]]
154+
[[deps.Test]]
147155
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
148156
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
149157

150-
[[TranscodingStreams]]
158+
[[deps.TranscodingStreams]]
151159
deps = ["Random", "Test"]
152160
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
153161
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
154162
version = "0.9.6"
155163

156-
[[UUIDs]]
164+
[[deps.UUIDs]]
157165
deps = ["Random", "SHA"]
158166
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
159167

160-
[[Unicode]]
168+
[[deps.Unicode]]
161169
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
162170

163-
[[Zlib_jll]]
171+
[[deps.Zlib_jll]]
164172
deps = ["Libdl"]
165173
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
166174

167-
[[nghttp2_jll]]
175+
[[deps.nghttp2_jll]]
168176
deps = ["Artifacts", "Libdl"]
169177
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
170178

171-
[[p7zip_jll]]
179+
[[deps.p7zip_jll]]
172180
deps = ["Artifacts", "Libdl"]
173181
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
174182

175-
[[pigz_jll]]
183+
[[deps.pigz_jll]]
176184
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
177185
git-tree-sha1 = "3c0c0b0c133b6ab53e1af05dc526091ce8781f16"
178186
uuid = "1bc43ea1-30af-5bc8-a9d4-c018457e6e3e"

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
1212
LibGit2_jll = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
1313
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1414
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
15+
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1516
OutputCollectors = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
1617
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1718
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -27,6 +28,7 @@ pigz_jll = "1bc43ea1-30af-5bc8-a9d4-c018457e6e3e"
2728
[compat]
2829
CodecZlib = "0.5, 0.6, 0.7"
2930
JSON = "0.21"
31+
OrderedCollections = "1.4.1"
3032
OutputCollectors = "0.1"
3133
Scratch = "1.0"
3234
SimpleBufferStream = "1"

src/Platforms.jl

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Base.BinaryPlatforms
2+
using OrderedCollections
23

34
export AnyPlatform
45

@@ -91,33 +92,41 @@ end
9192
const ARCHITECTURE_FLAGS = Dict(
9293
# Many compiler flags are the same across clang and gcc, store those in "common"
9394
"common" => Dict(
94-
"i686" => Dict(
95+
"i686" => OrderedDict(
9596
"pentium4" => ["-march=pentium4", "-mtune=generic"],
9697
"prescott" => ["-march=prescott", "-mtune=prescott"],
9798
),
98-
"x86_64" => Dict(
99+
"x86_64" => OrderedDict(
99100
# Better be always explicit about `-march` & `-mtune`:
100101
# https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
101102
"x86_64" => ["-march=x86-64", "-mtune=generic"],
102103
"avx" => ["-march=sandybridge", "-mtune=sandybridge"],
103104
"avx2" => ["-march=haswell", "-mtune=haswell"],
104105
"avx512" => ["-march=skylake-avx512", "-mtune=skylake-avx512"],
105106
),
106-
"armv6l" => Dict(
107+
"armv6l" => OrderedDict(
107108
# This is the only known armv6l chip that runs Julia, so it's the only one we care about.
108109
"arm1176jzfs" => ["-mcpu=arm1176jzf-s", "-mfpu=vfp", "-mfloat-abi=hard"],
109110
),
110-
"armv7l" => Dict(
111+
"armv7l" => OrderedDict(
111112
# Base armv7l architecture, with the most basic of FPU's
112113
"armv7l" => ["-march=armv7-a", "-mtune=generic-armv7-a", "-mfpu=vfpv3", "-mfloat-abi=hard"],
113114
# armv7l plus NEON and vfpv4, (Raspberry Pi 2B+, RK3328, most boards Elliot has access to)
114115
"neonvfpv4" => ["-march=armv7-a", "-mtune=cortex-a53", "-mfpu=neon-vfpv4", "-mfloat-abi=hard"],
115116
),
116-
"aarch64" => Dict(
117-
# Base armv8.0-a architecture, tune for generic cortex-a57
118-
"armv8_0" => ["-march=armv8-a", "-mtune=cortex-a57"],
117+
"aarch64" => OrderedDict(
118+
# For GCC, see: <https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html>. For
119+
# LLVM, for the list of features see
120+
# <https://github.com/llvm/llvm-project/blob/1bcc28b884ff4fbe2ecc011b8ea2b84e7987167b/llvm/include/llvm/Support/AArch64TargetParser.def>
121+
# and
122+
# <https://github.com/llvm/llvm-project/blob/85e9b2687a13d1908aa86d1b89c5ce398a06cd39/llvm/lib/Target/AArch64/AArch64.td>.
123+
# Run `clang --print-supported-cpus` for the list of values of `-mtune`.
124+
"armv8_0" => ["-march=armv8-a", "-mtune=cortex-a57"],
125+
"armv8_1" => ["-march=armv8.1-a", "-mtune=thunderx2t99"],
126+
"armv8_2_crypto" => ["-march=armv8.2-a+aes+sha2", "-mtune=cortex-a76"],
127+
"a64fx" => ["-march=armv8.2-a+aes+sha2+fp16+sve", "-mtune=a64fx"],
119128
),
120-
"powerpc64le" => Dict(
129+
"powerpc64le" => OrderedDict(
121130
"power8" => ["-mcpu=power8", "-mtune=power8"],
122131
# Note that power9 requires GCC 6+, and we need CPUID for this
123132
#"power9" => ["-mcpu=power9", "-mtune=power9"],
@@ -126,21 +135,13 @@ const ARCHITECTURE_FLAGS = Dict(
126135
)
127136
),
128137
"gcc" => Dict(
129-
"aarch64" => Dict(
130-
# `clang`/`gcc` disagree on `rdm(a)`
131-
"armv8_1" => ["-march=armv8-a+lse+crc+rdma", "-mtune=thunderx2t99"],
132-
# Note that these targets require gcc 9+
133-
"armv8_2_crypto" => ["-march=armv8-a+lse+crc+rdma+aes+sha2", "-mtune=cortex-a76"],
134-
"armv8_4_crypto_sve" => ["-march=armv8-a+les+crc+rdma+aes+sha2+fp16fml+dotprod+sve", "-mtune=cortex-a76"]
138+
"aarch64" => OrderedDict(
139+
"apple_m1" => ["-march=armv8.5-a+aes+sha2+sha3+fp16fml+fp16+rcpc+dotprod", "-mtune=cortex-a76"],
135140
),
136141
),
137142
"clang" => Dict(
138-
"aarch64" => Dict(
139-
# `clang`/`gcc` disagree on `rdm` vs. `rdma`
140-
"armv8_1" => ["-march=armv8-a+lse+crc+rdm", "-mtune=thunderx2t99"],
141-
# Note that these targets require clang 9+
142-
"armv8_2_crypto" => ["-march=armv8-a+lse+crc+rdm+aes+sha2", "-mtune=cortex-a76"],
143-
"armv8_4_crypto_sve" => ["-march=armv8-a+les+crc+rdm+aes+sha2+fp16fml+dotprod+sve", "-mtune=cortex-a76"]
143+
"aarch64" => OrderedDict(
144+
"apple_m1" => ["-march=armv8.5-a+aes+sha2+sha3+fp16fml+fp16+rcpc+dotprod", "-mtune=apple-a12"],
144145
),
145146
),
146147
)

src/Rootfs.jl

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,18 +487,27 @@ function gcc_version(p::AbstractPlatform,GCC_builds::Vector{GCCBuild},
487487
# "thunderx2t99" introduced in GCC v7.1:
488488
# https://www.gnu.org/software/gcc/gcc-7/changes.html
489489
GCC_builds = filter(b -> getversion(b) >= v"7.1", GCC_builds)
490-
elseif march(p) in ("armv8_2_crypto", "armv8_4_crypto_sve")
491-
# "+aes" and "+sha2" extensions for aarch64 introduced in GCC v8:
492-
# https://www.gnu.org/software/gcc/gcc-8/changes.html
493-
GCC_builds = filter(b -> getversion(b) >= v"8.1", GCC_builds)
490+
elseif march(p) in ("armv8_2_crypto",)
491+
# `cortex-a76` target introduced in GCC v9.1:
492+
# https://www.gnu.org/software/gcc/gcc-9/changes.html
493+
GCC_builds = filter(b -> getversion(b) >= v"9.1", GCC_builds)
494+
elseif march(p) in ("a64fx",)
495+
# `a64fx` target introduced in GCC v10.3:
496+
# https://www.gnu.org/software/gcc/gcc-10/changes.html
497+
GCC_builds = filter(b -> getversion(b) >= v"10.3", GCC_builds)
498+
elseif march(p) in ("apple_m1",)
499+
# At the moment we can only target this CPU with GCC 12
500+
GCC_builds = filter(b -> getversion(b) >= v"12", GCC_builds)
494501
end
495502

496503
return getversion.(GCC_builds)
497504
end
498505

499506
function llvm_version(p::AbstractPlatform, LLVM_builds::Vector{LLVMBuild})
500-
if march(p) in ("armv8_2_crypto", "armv8_4_crypto_sve")
507+
if march(p) in ("armv8_2_crypto",)
501508
LLVM_builds = filter(b -> getversion(b) >= v"9.0", LLVM_builds)
509+
elseif march(p) in ("a64fx", "apple_m1",)
510+
LLVM_builds = filter(b -> getversion(b) >= v"11.0", LLVM_builds)
502511
end
503512
return getversion.(LLVM_builds)
504513
end
@@ -827,8 +836,22 @@ function expand_microarchitectures(platform::AbstractPlatform)
827836
return [platform]
828837
end
829838

830-
# Otherwise, return a bunch of Platform objects with appropriately-set `march` tags
831-
return map(get_all_march_names(arch(platform))) do march
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
842+
if (!Sys.isapple(platform) && march == "apple_m1") ||
843+
(Sys.isapple(platform) && arch(platform) == "aarch64" && march ("armv8_0", "apple_m1"))
844+
# `apple_m1` makes sense only on macOS, and the only aarch64 microarchitectures
845+
# that make sense on macOS are M1 and the generic one.
846+
return false
847+
elseif march == "a64fx" && !(Sys.islinux(platform) && libc(platform) == "glibc")
848+
# Let's be honest: it's unlikely we'll see Alpine Linux on A64FX.
849+
return false
850+
end
851+
return true
852+
end
853+
854+
return map(all_marchs) do march
832855
p = deepcopy(platform)
833856
p["march"] = march
834857
return p

0 commit comments

Comments
 (0)