aboutsummaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorAndrei Horodniceanu <a.horodniceanu@proton.me>2024-04-26 21:31:35 +0300
committerAndrei Horodniceanu <a.horodniceanu@proton.me>2024-04-26 21:34:15 +0300
commit0618e9ecab3234a0fb7f0bb2c358c37630bb1427 (patch)
tree5f36caa7aee3ec14bbc947f7201b93c7e200a565 /eclass
parentdev-util/dub: add 1.37.0 (diff)
downloaddlang-0618e9ecab3234a0fb7f0bb2c358c37630bb1427.tar.gz
dlang-0618e9ecab3234a0fb7f0bb2c358c37630bb1427.tar.bz2
dlang-0618e9ecab3234a0fb7f0bb2c358c37630bb1427.zip
dlang-utils.eclass: add dlang_get_abi_bits
Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/dlang-utils.eclass31
-rwxr-xr-xeclass/tests/dlang-utils.sh7
2 files changed, 27 insertions, 11 deletions
diff --git a/eclass/dlang-utils.eclass b/eclass/dlang-utils.eclass
index b759435..60eee53 100644
--- a/eclass/dlang-utils.eclass
+++ b/eclass/dlang-utils.eclass
@@ -699,6 +699,20 @@ dlang-filter-dflags() {
return 0
}
+# @FUNCTION: dlang_get_abi_bits
+# @USAGE: [<abi>]
+# @DESCRIPTION:
+# Echo the bits of the given abi. When unspecified take the value from
+# $ABI.
+#
+# If the abi is x86, echo 32, if amd64 echo 64, otherwise do nothing.
+dlang_get_abi_bits() {
+ case "${1:-${ABI}}" in
+ amd64*) echo 64 ;;
+ x86*) echo 32 ;;
+ esac
+}
+
# @FUNCTION: _dlang_export
# @USAGE: [<impl>] <variables>...
# @INTERNAL
@@ -816,12 +830,9 @@ _dlang_export() {
# The logic is controlled by us so the calculation
# is found in dlang.eclass. Just copy it here, mostly.
# Simplify the ABI usage a little.
- local model
- case "${ABI}" in
- x86*) model=32 ;;
- amd64*) model=64 ;;
- *) die "Unknown ABI ${ABI} for dmd implementation." ;;
- esac
+ [[ ${ABI} == @(x86|amd64) ]] ||
+ die "Unknown ABI ${ABI} for dmd implementation."
+ local model=$(dlang_get_abi_bits)
if has_multilib_profile || [[ ${model} == 64 ]]; then
libdirname=lib${model}
@@ -850,11 +861,9 @@ _dlang_export() {
DLANG_MODEL_FLAG)
if has_multilib_profile; then
# Only x86/amd64 multilib is supported
- case "${ABI}" in
- x86*) DLANG_MODEL_FLAG=-m32 ;;
- amd64*) DLANG_MODEL_FLAG=-m64 ;;
- *) die "ABI ${ABI} is not supported in a multilib configuration."
- esac
+ [[ ${ABI} == @(x86|amd64) ]] ||
+ die "ABI ${ABI} is not supported in a multilib configuration."
+ DLANG_MODEL_FLAG=-m$(dlang_get_abi_bits)
else
DLANG_MODEL_FLAG=
fi
diff --git a/eclass/tests/dlang-utils.sh b/eclass/tests/dlang-utils.sh
index 70915c3..0f4b6da 100755
--- a/eclass/tests/dlang-utils.sh
+++ b/eclass/tests/dlang-utils.sh
@@ -277,3 +277,10 @@ dlang-filter-dflags "gdc*" "-march=native"
[[ "${DCFLAGS}" == "-O2 -pipe" ]] &&
[[ "${DMDW_DCFLAGS}" == "-q,-O2 -q,-pipe" ]]
tend $?
+
+tbegin "dlang_get_abi_bits"
+assert_eq $(dlang_get_abi_bits x86) 32
+assert_eq $(dlang_get_abi_bits amd64) 64
+assert_eq $(dlang_get_abi_bits aarch64) ""
+assert_eq $(ABI=x86 dlang_get_abi_bits) 32
+tend