diff mbox

[1/4] deb-pkg: Add automatic support for armhf architecture

Message ID 834bd55c0de686780eb15f9a06b13f7fb560e9a8.1427968988.git.riku.voipio@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Riku Voipio April 2, 2015, 11:27 a.m. UTC
From: Ben Hutchings <ben@decadent.org.uk>

The Debian armhf architecture uses the ARM EABI hard-float variant,
whereas armel uses the soft-float variant.  If the compiler used
to compile the kernel uses the __ARM_PCS_VFP ABI, the compiler
targets armhf architecture.

v3 by Riku: Use gcc define instead of CONFIG_VFP

Cc: debian-arm@lists.debian.org
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 scripts/package/builddeb | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Arnaud Patard (Rtp) April 2, 2015, 12:01 p.m. UTC | #1
riku.voipio@linaro.org writes:

> From: Ben Hutchings <ben@decadent.org.uk>
>
> The Debian armhf architecture uses the ARM EABI hard-float variant,
> whereas armel uses the soft-float variant.  If the compiler used
> to compile the kernel uses the __ARM_PCS_VFP ABI, the compiler
> targets armhf architecture.
>
> v3 by Riku: Use gcc define instead of CONFIG_VFP
>
> Cc: debian-arm@lists.debian.org
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
> ---
>  scripts/package/builddeb | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/package/builddeb b/scripts/package/builddeb
> index 88dbf23..146b74f 100755
> --- a/scripts/package/builddeb
> +++ b/scripts/package/builddeb
> @@ -45,7 +45,16 @@ create_package() {
>  	arm64)
>  		debarch=arm64 ;;
>  	arm*)
> -		debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
> +		if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
> +			if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; then

Actually, I guess there's nothing preventing you building a armhf kernel
with a compiler not having __ARM_PCS_VFP defined by default, but I'm not sure
we should take care of this case. One can always use KBUILD_DEBARCH=armhf.

Arnaud
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Riku Voipio April 2, 2015, 1:14 p.m. UTC | #2
On 2 April 2015 at 15:01, Arnaud Patard <arnaud.patard@rtp-net.org> wrote:
> riku.voipio@linaro.org writes:
>> --- a/scripts/package/builddeb
>> +++ b/scripts/package/builddeb
>> @@ -45,7 +45,16 @@ create_package() {
>>       arm64)
>>               debarch=arm64 ;;
>>       arm*)
>> -             debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
>> +             if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
>> +                     if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; then
>
> Actually, I guess there's nothing preventing you building a armhf kernel
> with a compiler not having __ARM_PCS_VFP defined by default, but I'm not sure
> we should take care of this case. One can always use KBUILD_DEBARCH=armhf.

I think the common use cases would be a) native compilers or b)
cross-compiler targeting the same debian architecture as the rootfs.
This patch provides automatic detection for both cases. For corner
cases, one will have to manually specify KBUILD_DEBARCH - which one
already had to do if one was targeting armhf.

Riku
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek April 2, 2015, 2:18 p.m. UTC | #3
On 2015-04-02 15:14, Riku Voipio wrote:
> On 2 April 2015 at 15:01, Arnaud Patard <arnaud.patard@rtp-net.org> wrote:
>> riku.voipio@linaro.org writes:
>>> --- a/scripts/package/builddeb
>>> +++ b/scripts/package/builddeb
>>> @@ -45,7 +45,16 @@ create_package() {
>>>       arm64)
>>>               debarch=arm64 ;;
>>>       arm*)
>>> -             debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
>>> +             if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
>>> +                     if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; then
>>
>> Actually, I guess there's nothing preventing you building a armhf kernel
>> with a compiler not having __ARM_PCS_VFP defined by default, but I'm not sure
>> we should take care of this case. One can always use KBUILD_DEBARCH=armhf.
> 
> I think the common use cases would be a) native compilers or b)
> cross-compiler targeting the same debian architecture as the rootfs.
> This patch provides automatic detection for both cases.

$CC should be used together with $KBUILD_CFLAGS to behave the same as
when building the kernel.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Riku Voipio April 9, 2015, 7:43 a.m. UTC | #4
On 2 April 2015 at 17:18, Michal Marek <mmarek@suse.cz> wrote:
> On 2015-04-02 15:14, Riku Voipio wrote:
>> On 2 April 2015 at 15:01, Arnaud Patard <arnaud.patard@rtp-net.org> wrote:
>>> riku.voipio@linaro.org writes:
>>>> --- a/scripts/package/builddeb
>>>> +++ b/scripts/package/builddeb
>>>> @@ -45,7 +45,16 @@ create_package() {
>>>>       arm64)
>>>>               debarch=arm64 ;;
>>>>       arm*)
>>>> -             debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
>>>> +             if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
>>>> +                     if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; then
>>>
>>> Actually, I guess there's nothing preventing you building a armhf kernel
>>> with a compiler not having __ARM_PCS_VFP defined by default, but I'm not sure
>>> we should take care of this case. One can always use KBUILD_DEBARCH=armhf.
>>
>> I think the common use cases would be a) native compilers or b)
>> cross-compiler targeting the same debian architecture as the rootfs.
>> This patch provides automatic detection for both cases.

> $CC should be used together with $KBUILD_CFLAGS to behave the same as
> when building the kernel.

I just tested and it won't work. $KBUILD_CFLAGS has -msoft-float so
__ARM_PCS_VFP wont be set. Which makes sense - we wouldn't want kernel
to pass anything in float registers. Given the constraint, would you
prefer Ben's original patch that checks CONFIG_VFP[1], or my version
using CC without KBUILD_CFLAGS?

[1] https://lists.debian.org/debian-arm/2014/06/msg00016.html

Riku
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 88dbf23..146b74f 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -45,7 +45,16 @@  create_package() {
 	arm64)
 		debarch=arm64 ;;
 	arm*)
-		debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el || true) ;;
+		if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then
+			if $CC -dM -E - < /dev/null|grep -q __ARM_PCS_VFP; then
+				debarch=armhf
+			else
+				debarch=armel
+			fi
+		else
+			debarch=arm
+		fi
+		;;
 	*)
 		echo "" >&2
 		echo "** ** **  WARNING  ** ** **" >&2