diff options
-rw-r--r-- | eclass/dlang-utils.eclass | 31 | ||||
-rwxr-xr-x | eclass/tests/dlang-utils.sh | 7 |
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 |