Skip to content

Commit 0fb6ba2

Browse files
Make AARCH64 primary, add ARM64 as alias, deprecate incorrect arch aliases (#2591)
1 parent ab7bfe5 commit 0fb6ba2

File tree

12 files changed

+106
-31
lines changed

12 files changed

+106
-31
lines changed

modules/vstudio/_preload.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@
709709
}
710710

711711
p.api.addAllowed("system", p.ANDROID)
712-
p.api.addAllowed("architecture", { "armv5", "armv7", "aarch64", "mips", "mips64", "arm" })
712+
p.api.addAllowed("architecture", { "armv5", "armv7", "mips", "mips64" })
713713
p.api.addAllowed("vectorextensions", { "NEON", "MXU" })
714714
p.api.addAllowed("exceptionhandling", {"UnwindTables"})
715715
p.api.addAllowed("kind", p.PACKAGING)

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,8 +3033,7 @@
30333033
if cfg.system == p.WINDOWS then
30343034
if cfg.architecture == p.ARM then
30353035
p.w('<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>')
3036-
end
3037-
if cfg.architecture == p.ARM64 then
3036+
elseif cfg.architecture == p.AARCH64 then
30383037
p.w('<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>')
30393038
end
30403039
end
@@ -4349,10 +4348,10 @@
43494348

43504349
if (cfg.architecture ~= nil or cfg.toolchainversion ~= nil) and archMap[arch] ~= nil then
43514350
local defaultToolsetMap = {
4352-
arm = "arm-linux-androideabi-",
4351+
[ p.ARM ] = "arm-linux-androideabi-",
43534352
armv5 = "arm-linux-androideabi-",
43544353
armv7 = "arm-linux-androideabi-",
4355-
aarch64 = "aarch64-linux-android-",
4354+
[ p.AARCH64 ] = "aarch64-linux-android-",
43564355
mips = "mipsel-linux-android-",
43574356
mips64 = "mips64el-linux-android-",
43584357
x86 = "x86-",

modules/vstudio/vstudio.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424

2525
vstudio.vs200x_architectures =
2626
{
27-
win32 = "x86",
28-
x86 = "x86",
29-
x86_64 = "x64",
30-
ARM = "ARM",
31-
ARM64 = "ARM64",
27+
win32 = "x86",
28+
x86 = "x86",
29+
x86_64 = "x64",
30+
ARM = "ARM",
31+
AARCH64 = "ARM64",
3232
}
3333

3434
vstudio.vs2010_architectures =

premake5.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
description = "Set the architecture of the binary to be built.",
170170
allowed = {
171171
{ "ARM", "ARM (On macOS, same as ARM64.)" },
172-
{ "ARM64", "ARM64" },
172+
{ "AARCH64", "AARCH64" },
173173
{ "x86", "x86 (On macOS, same as x86_64.)" },
174174
{ "x86_64", "x86_64" },
175175
{ "ppc", "PowerPC 32-bit" },
@@ -178,6 +178,7 @@
178178
--
179179
{ "Win32", "Same as x86" },
180180
{ "x64", "Same as x86_64" },
181+
{ "ARM64", "Same as AARCH64" },
181182
},
182183
-- "Generates default platforms for targets, x86 and x86_64 projects for Windows." }
183184
default = nil,
@@ -235,7 +236,7 @@
235236
filter { "options:lua-src=contrib" }
236237
defines { "LUA_STATICLIB" }
237238

238-
filter { "system:macosx", "options:arch=ARM or arch=ARM64" }
239+
filter { "system:macosx", "options:arch=ARM or arch=AARCH64" }
239240
buildoptions { "-arch arm64" }
240241
linkoptions { "-arch arm64" }
241242

@@ -258,7 +259,7 @@
258259
filter { "system:windows", "options:arch=ARM" }
259260
platforms { "ARM" }
260261

261-
filter { "system:windows", "options:arch=ARM64" }
262+
filter { "system:windows", "options:arch=AARCH64" }
262263
platforms { "ARM64" }
263264

264265
filter { "system:windows", "options:arch=x86 or arch=Win32" }

src/_premake_init.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
p.X86,
2828
p.X86_64,
2929
p.ARM,
30-
p.ARM64,
30+
p.AARCH64,
3131
p.RISCV64,
3232
p.LOONGARCH64,
3333
p.PPC,
@@ -38,13 +38,17 @@
3838
p.MIPS64EL
3939
},
4040
aliases = {
41-
i386 = p.X86,
42-
amd64 = p.X86_64,
43-
x32 = p.X86, -- these should be DEPRECATED
44-
x64 = p.X86_64,
41+
i386 = p.X86,
42+
amd64 = p.X86_64,
43+
x32 = p.X86,
44+
x64 = p.X86_64,
45+
ARM64 = p.AARCH64,
4546
},
4647
}
4748

49+
api.deprecateAlias("architecture", "i386", "Use 'x86' instead with `buildoptions { '-march=i386' }`.")
50+
api.deprecateAlias("architecture", "x32", "Use 'x86' instead. There is no x32 ABI support currently.")
51+
4852
api.register {
4953
name = "basedir",
5054
scope = "project",

src/base/_foundation.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
premake.X86 = "x86"
6464
premake.X86_64 = "x86_64"
6565
premake.ARM = "ARM"
66-
premake.ARM64 = "ARM64"
66+
premake.AARCH64 = "AARCH64"
6767
premake.RISCV64 = "RISCV64"
6868
premake.LOONGARCH64 = "loongarch64"
6969
premake.PPC = "ppc"

src/base/api.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,37 @@
455455
end
456456

457457

458+
--
459+
-- Mark a specific alias value of a field as deprecated.
460+
--
461+
-- @param name
462+
-- The name of the field containing the alias.
463+
-- @param alias
464+
-- The alias or aliases to mark as deprecated. May be a string
465+
-- for a single alias or an array of multiple aliases.
466+
-- @param message
467+
-- A optional message providing more information, to be shown
468+
-- as part of the deprecation warning message.
469+
--
470+
471+
function api.deprecateAlias(name, alias, message)
472+
if type(alias) == "table" then
473+
for _, a in pairs(alias) do
474+
api.deprecateAlias(name, a, message)
475+
end
476+
else
477+
local field = p.fields[name]
478+
field.deprecatedaliases = field.deprecatedaliases or {}
479+
local actual = field.aliases[alias:lower()]
480+
if actual then
481+
field.deprecatedaliases[alias] = {
482+
message = message
483+
}
484+
end
485+
end
486+
end
487+
488+
458489
--
459490
-- Control the handling of API deprecations.
460491
--
@@ -648,6 +679,18 @@
648679
local canonical, result
649680
local lowerValue = value:lower()
650681

682+
if field.deprecatedaliases and field.deprecatedaliases[lowerValue] then
683+
local handler = field.deprecatedaliases[lowerValue]
684+
if handler.message and api._deprecations ~= "off" then
685+
local caller = filelineinfo(9)
686+
local key = field.name .. "_" .. value .. "_" .. caller
687+
p.warnOnce(key, "the %s alias %s has been deprecated and will be removed.\n %s\n @%s\n", field.name, lowerValue, handler.message, caller)
688+
if api._deprecations == "error" then
689+
return nil, "deprecation errors enabled"
690+
end
691+
end
692+
end
693+
651694
if field.aliases then
652695
canonical = field.aliases[lowerValue]
653696
end

src/tools/gcc.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
architecture = {
5757
x86 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch i386", "-m32") end,
5858
x86_64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch x86_64", "-m64") end,
59-
ARM64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch arm64", nil) end,
59+
AARCH64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch arm64", nil) end,
6060
},
6161
fatalwarnings = {
6262
All = "-Werror",
@@ -504,7 +504,7 @@
504504
architecture = {
505505
x86 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch i386", "-m32") end,
506506
x86_64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch x86_64", "-m64") end,
507-
ARM64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch arm64", nil) end,
507+
AARCH64 = function (cfg) return iif(cfg.system == p.MACOSX, "-arch arm64", nil) end,
508508
},
509509
linkerfatalwarnings = {
510510
All = "-Wl,--fatal-warnings",

tests/base/test_os.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,6 @@ function suite.targetarch()
645645
test.isequal(_TARGET_ARCH, os.targetarch())
646646

647647
-- --arch has priority over _TARGET_ARCH
648-
_OPTIONS["arch"] = "arm64"
648+
_OPTIONS["arch"] = "AARCH64"
649649
test.isequal(_OPTIONS["arch"], os.targetarch())
650650
end

tests/tools/test_clang.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,27 @@ end
364364
test.contains({ "-arch x86_64" }, clang.getldflags(cfg))
365365
end
366366

367+
function suite.cflags_macosx_onAARCH64()
368+
system "macosx"
369+
architecture "AARCH64"
370+
prepare()
371+
test.contains({ "-arch arm64" }, clang.getcflags(cfg))
372+
end
373+
367374
function suite.cflags_macosx_onarm64()
368375
system "macosx"
369376
architecture "arm64"
370377
prepare()
371378
test.contains({ "-arch arm64" }, clang.getcflags(cfg))
372379
end
373380

381+
function suite.ldflags_macosx_onAARCH64()
382+
system "macosx"
383+
architecture "AARCH64"
384+
prepare()
385+
test.contains({ "-arch arm64" }, clang.getldflags(cfg))
386+
end
387+
374388
function suite.ldflags_macosx_onarm64()
375389
system "macosx"
376390
architecture "arm64"

0 commit comments

Comments
 (0)