From e12ef8929c33284a20db64fd4f2b6569ae01cea4 Mon Sep 17 00:00:00 2001 From: Redbeanw44602 Date: Sat, 31 Aug 2024 00:11:08 +0800 Subject: [PATCH 1/4] make autoconf tool to use is_cross to determine whether it is cross-compile. --- xmake/modules/package/tools/autoconf.lua | 15 ++------------- .../modules/private/action/trybuild/autoconf.lua | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index b84ac87e4c2..5cfb1d28d78 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -77,17 +77,6 @@ function _get_msvc_runenvs(package) return os.joinenvs(_get_msvc(package):runenvs()) end --- is cross compilation? -function _is_cross_compilation(package) - if not package:is_plat(os.subhost()) then - return true - end - if package:is_plat("macosx") and not package:is_arch(os.subarch()) then - return true - end - return false -end - -- get memcache function _memcache() return memcache.cache("package.tools.autoconf") @@ -115,7 +104,7 @@ function _get_configs(package, configs) table.insert(configs, "--prefix=" .. _translate_paths(package:installdir())) -- add host for cross-complation - if not configs.host and _is_cross_compilation(package) then + if not configs.host and package:is_cross() then if package:is_plat("iphoneos", "macosx") then local triples = { @@ -240,7 +229,7 @@ function buildenvs(package, opt) local envs = {} local cross = false local cflags, cxxflags, cppflags, asflags, ldflags, shflags, arflags - if not _is_cross_compilation(package) and not package:config("toolchains") then + if not package:is_cross() and not package:config("toolchains") then cppflags = {} cflags = table.join(table.wrap(package:config("cxflags")), package:config("cflags")) cxxflags = table.join(table.wrap(package:config("cxflags")), package:config("cxxflags")) diff --git a/xmake/modules/private/action/trybuild/autoconf.lua b/xmake/modules/private/action/trybuild/autoconf.lua index 9b5ac71f84a..0eba27bf2cd 100644 --- a/xmake/modules/private/action/trybuild/autoconf.lua +++ b/xmake/modules/private/action/trybuild/autoconf.lua @@ -68,7 +68,7 @@ end function _get_buildenvs() local envs = {} local cross = false - if not _is_cross_compilation() then + if not is_cross() then local cflags = table.join(table.wrap(_get_buildenv("cxflags")), _get_buildenv("cflags")) local cxxflags = table.join(table.wrap(_get_buildenv("cxflags")), _get_buildenv("cxxflags")) local asflags = table.copy(table.wrap(_get_buildenv("asflags"))) @@ -174,17 +174,6 @@ function _get_buildenvs() return envs end --- is cross compilation? -function _is_cross_compilation() - if not is_plat(os.subhost()) then - return true - end - if is_plat("macosx") and not is_arch(os.subarch()) then - return true - end - return false -end - -- get configs function _get_configs(artifacts_dir) @@ -201,7 +190,7 @@ function _get_configs(artifacts_dir) end -- add host for cross-complation - if _is_cross_compilation() then + if is_cross() then if is_plat("iphoneos", "macosx") then local triples = { From 71d380e44438615d1cce4bc8b0603f03e5c93e80 Mon Sep 17 00:00:00 2001 From: Redbeanw44602 Date: Sat, 31 Aug 2024 00:11:24 +0800 Subject: [PATCH 2/4] add missing linux platform triples. --- xmake/modules/package/tools/autoconf.lua | 14 ++++++++++++++ xmake/modules/private/action/trybuild/autoconf.lua | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index 5cfb1d28d78..4346b12ab41 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -139,6 +139,20 @@ function _get_configs(package, configs) x86_64 = "x86_64-w64-mingw32" } table.insert(configs, "--host=" .. (triples[package:arch()] or triples.i386)) + elseif package:is_plat("linux") then + local triples = + { + ["arm64-v8a"] = "aarch64-linux-gnu", + i386 = "i686-linux-gnu", + x86_64 = "x86_64-linux-gnu", + armv7 = "arm-linux-gnueabihf", + mips = "mips-linux-gnu", + mips64 = "mips64-linux-gnu", + mipsel = "mipsel-linux-gnu", + mips64el = "mips64el-linux-gnu", + loong64 = "loongarch64-linux-gnu" + } + table.insert(configs, "--host=" .. (triples[package:arch()] or triples.i386)) elseif package:is_plat("cross") and package:targetos() then local host = package:arch() if package:is_arch("arm64") then diff --git a/xmake/modules/private/action/trybuild/autoconf.lua b/xmake/modules/private/action/trybuild/autoconf.lua index 0eba27bf2cd..da34d7bc987 100644 --- a/xmake/modules/private/action/trybuild/autoconf.lua +++ b/xmake/modules/private/action/trybuild/autoconf.lua @@ -225,6 +225,20 @@ function _get_configs(artifacts_dir) x86_64 = "x86_64-w64-mingw32" } table.insert(configs, "--host=" .. (triples[config.arch()] or triples.i386)) + elseif is_plat("linux") then + local triples = + { + ["arm64-v8a"] = "aarch64-linux-gnu", + i386 = "i686-linux-gnu", + x86_64 = "x86_64-linux-gnu", + armv7 = "arm-linux-gnueabihf", + mips = "mips-linux-gnu", + mips64 = "mips64-linux-gnu", + mipsel = "mipsel-linux-gnu", + mips64el = "mips64el-linux-gnu", + loong64 = "loongarch64-linux-gnu" + } + table.insert(configs, "--host=" .. (triples[config.arch()] or triples.i386)) elseif is_plat("cross") then local host = config.arch() if is_arch("arm64") then From ea1eccb6f2e551bad54cfd363a64f07aff1dde08 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 31 Aug 2024 22:23:54 +0800 Subject: [PATCH 3/4] Update autoconf.lua --- xmake/modules/package/tools/autoconf.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index 4346b12ab41..af50784fbc3 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -143,6 +143,7 @@ function _get_configs(package, configs) local triples = { ["arm64-v8a"] = "aarch64-linux-gnu", + arm64 = "aarch64-linux-gnu", i386 = "i686-linux-gnu", x86_64 = "x86_64-linux-gnu", armv7 = "arm-linux-gnueabihf", From a81b8dcf3aee2e2710aeb56a169496788afb1e00 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 31 Aug 2024 22:24:40 +0800 Subject: [PATCH 4/4] Update autoconf.lua --- xmake/modules/private/action/trybuild/autoconf.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/modules/private/action/trybuild/autoconf.lua b/xmake/modules/private/action/trybuild/autoconf.lua index da34d7bc987..d2f96801815 100644 --- a/xmake/modules/private/action/trybuild/autoconf.lua +++ b/xmake/modules/private/action/trybuild/autoconf.lua @@ -229,6 +229,7 @@ function _get_configs(artifacts_dir) local triples = { ["arm64-v8a"] = "aarch64-linux-gnu", + arm64 = "aarch64-linux-gnu", i386 = "i686-linux-gnu", x86_64 = "x86_64-linux-gnu", armv7 = "arm-linux-gnueabihf",