Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] using BR2 variables to find a specific header file
@ 2014-10-13 17:10 Sylvain Raybaud
  2014-10-13 17:30 ` Mike Zick
  2014-10-13 19:42 ` Samuel Martin
  0 siblings, 2 replies; 6+ messages in thread
From: Sylvain Raybaud @ 2014-10-13 17:10 UTC (permalink / raw)
  To: buildroot

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear all

I'm trying to integrate a cmake based package wich is not very
cross-compiling friendly (MariaDB galera cluster). During normal
compile this package runs some tests in order to determine if stacks
grows downward or upward. During cross-compile these tests cannot be
run therefore the package expects -DSTACK_DIRECTION=+/-1 to be passed
to cmake. Of course you cannot do it in buildroot.

It seems to be possible to access this information in another way
since STACK_GROWS_DOWNWARD is defined in some headers. In my case they
are:

output/build/host-gcc-final-4.8.3/gcc/config/arm/arm.h
(option a)

or

output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.3/plugin/include/config/arm/arm.h
(option b)

or

output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.3/plugin/include/tm.h
which in turns includes config/arm/arm.h  but seems more generic
(option c)

using these files I could automatically determine the correct value
for STACK_DIRECTION (either searching them for STACK_GROWS_DOWNWARD or
calling C preprocessor on an ad-hoc source file that would include them).

The question is: how to determine inside buildroot which file to use?

I was thinking of using a combination of the following variables to
determine the position of these headers. I'll list them with the value
they have in my case. Do you think it's a good idea? Do you think it's
portable?

BR2_ARCH="arm"
BR2_GCC_VERSION=4.8.3
BR2_GCC_TARGET_MODE=arm
BR2_TOOLCHAIN=y
BR2_TOOLCHAIN_BUILDROOT=y
BR2_TOOLCHAIN_BUILDROOT_VENDOR=buildroot
BR_TOOLCHAIN_USES_UCLIBC=y
BR2_TOOLCHAIN_BUILDROOT_UCLIBC=y
BR2_ARM_EABI=y

Using these variables it seems I can find the correct file but I'm not
sure it's the correct way to do things. What do you think? Do you have
suggestions?

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIbBAEBAgAGBQJUPAd1AAoJEEkkwl4JtJ9yPNUP+Pz/MHto4uVjnxLnA6eXT0aG
DA1RT5np6a3CGdtA3Yf3oVABmGTgLBwDvDDq1cyBqs6qs1y1oLV7rvbt3GpvCcOo
YcmsDNg+cdkIqQgJb/FLgFcZaiCmttlET6bFsg5ltM25W+dMCIVacDegtMxCpUrw
0RnUHOOBmvutdxfAI+QO+GKQtoukssmHehfywLmfzCEwaLpUjsLOSllqKXw5VqPM
EHIZhHl4j+cW2WbSB3ZBuO2vCFViK7tQuJ0pp15bidP4IyDutyw12wT/n2oofh76
EyRrUqPzuQfqNBI2Waslwg5ycgL2bzLAOQck5CA6khcI4HUucfCslA+V3xGNQDN4
oVUwo1Ji7ylE5PaTISWlhYZIsDAAjM8f/kQuhzueo3VDolFg89MQzfd2ifaWEuBh
HHuKMuSOuEI2aqvh74XVK5xeAoB0d27LgJq0Mw8q1ZcExF9IaH3c+ggnOWjXfLdw
TX9DaFabzaXG87P75WmTRua6JKeADkxcpqfn2sqiT2a8xzhtiehK0MtTCBeHg0AW
/Mic6UQtEC/GRgRkloHK1edtfioIHucMY+0sFlqvvbL2GpsS5eEio+hybMmBRUyI
VksZsRqlc0mH77ALMlv4ksGgLqYvVQP7RkPd9+XORoNaJgMMvdeK7n9QiEU8B5Yd
A40g/rR9voOF4Frsazs=
=ydRq
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] using BR2 variables to find a specific header file
  2014-10-13 17:10 [Buildroot] using BR2 variables to find a specific header file Sylvain Raybaud
@ 2014-10-13 17:30 ` Mike Zick
  2014-10-14 20:58   ` Arnout Vandecappelle
  2014-10-13 19:42 ` Samuel Martin
  1 sibling, 1 reply; 6+ messages in thread
From: Mike Zick @ 2014-10-13 17:30 UTC (permalink / raw)
  To: buildroot

On Mon, 13 Oct 2014 19:10:13 +0200
Sylvain Raybaud <sylvain.raybaud@green-communications.fr> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Dear all
> 
> I'm trying to integrate a cmake based package wich is not very
> cross-compiling friendly (MariaDB galera cluster). During normal
> compile this package runs some tests in order to determine if stacks
> grows downward or upward. During cross-compile these tests cannot be
> run therefore the package expects -DSTACK_DIRECTION=+/-1 to be passed
> to cmake. Of course you cannot do it in buildroot.
>

I think that the only processor where the stack grows up is PA-RISC.
Which is not one of the Buildroot supported processors.

So just hard code it (by patching if required) to down.

At least that would be my (non-BR developer) solution.

Mike 
> It seems to be possible to access this information in another way
> since STACK_GROWS_DOWNWARD is defined in some headers. In my case they
> are:
> 
> output/build/host-gcc-final-4.8.3/gcc/config/arm/arm.h
> (option a)
> 
> or
> 
> output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.3/plugin/include/config/arm/arm.h
> (option b)
> 
> or
> 
> output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.3/plugin/include/tm.h
> which in turns includes config/arm/arm.h  but seems more generic
> (option c)
> 
> using these files I could automatically determine the correct value
> for STACK_DIRECTION (either searching them for STACK_GROWS_DOWNWARD or
> calling C preprocessor on an ad-hoc source file that would include
> them).
> 
> The question is: how to determine inside buildroot which file to use?
> 
> I was thinking of using a combination of the following variables to
> determine the position of these headers. I'll list them with the value
> they have in my case. Do you think it's a good idea? Do you think it's
> portable?
> 
> BR2_ARCH="arm"
> BR2_GCC_VERSION=4.8.3
> BR2_GCC_TARGET_MODE=arm
> BR2_TOOLCHAIN=y
> BR2_TOOLCHAIN_BUILDROOT=y
> BR2_TOOLCHAIN_BUILDROOT_VENDOR=buildroot
> BR_TOOLCHAIN_USES_UCLIBC=y
> BR2_TOOLCHAIN_BUILDROOT_UCLIBC=y
> BR2_ARM_EABI=y
> 
> Using these variables it seems I can find the correct file but I'm not
> sure it's the correct way to do things. What do you think? Do you have
> suggestions?
> 
> Cheers,
> 
> - -- 
> Sylvain Raybaud
> www.green-communications.fr
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> 
> iQIbBAEBAgAGBQJUPAd1AAoJEEkkwl4JtJ9yPNUP+Pz/MHto4uVjnxLnA6eXT0aG
> DA1RT5np6a3CGdtA3Yf3oVABmGTgLBwDvDDq1cyBqs6qs1y1oLV7rvbt3GpvCcOo
> YcmsDNg+cdkIqQgJb/FLgFcZaiCmttlET6bFsg5ltM25W+dMCIVacDegtMxCpUrw
> 0RnUHOOBmvutdxfAI+QO+GKQtoukssmHehfywLmfzCEwaLpUjsLOSllqKXw5VqPM
> EHIZhHl4j+cW2WbSB3ZBuO2vCFViK7tQuJ0pp15bidP4IyDutyw12wT/n2oofh76
> EyRrUqPzuQfqNBI2Waslwg5ycgL2bzLAOQck5CA6khcI4HUucfCslA+V3xGNQDN4
> oVUwo1Ji7ylE5PaTISWlhYZIsDAAjM8f/kQuhzueo3VDolFg89MQzfd2ifaWEuBh
> HHuKMuSOuEI2aqvh74XVK5xeAoB0d27LgJq0Mw8q1ZcExF9IaH3c+ggnOWjXfLdw
> TX9DaFabzaXG87P75WmTRua6JKeADkxcpqfn2sqiT2a8xzhtiehK0MtTCBeHg0AW
> /Mic6UQtEC/GRgRkloHK1edtfioIHucMY+0sFlqvvbL2GpsS5eEio+hybMmBRUyI
> VksZsRqlc0mH77ALMlv4ksGgLqYvVQP7RkPd9+XORoNaJgMMvdeK7n9QiEU8B5Yd
> A40g/rR9voOF4Frsazs=
> =ydRq
> -----END PGP SIGNATURE-----
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] using BR2 variables to find a specific header file
  2014-10-13 17:10 [Buildroot] using BR2 variables to find a specific header file Sylvain Raybaud
  2014-10-13 17:30 ` Mike Zick
@ 2014-10-13 19:42 ` Samuel Martin
  2014-10-14 10:58   ` Sylvain Raybaud
  1 sibling, 1 reply; 6+ messages in thread
From: Samuel Martin @ 2014-10-13 19:42 UTC (permalink / raw)
  To: buildroot

Hi Sylvain,

On Mon, Oct 13, 2014 at 7:10 PM, Sylvain Raybaud
<sylvain.raybaud@green-communications.fr> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Dear all
>
> I'm trying to integrate a cmake based package wich is not very
> cross-compiling friendly (MariaDB galera cluster). During normal
> compile this package runs some tests in order to determine if stacks
> grows downward or upward.

Common mistake done by project not having cross-compilation in mind! :-/

> During cross-compile these tests cannot be
> run therefore the package expects -DSTACK_DIRECTION=+/-1 to be passed
> to cmake. Of course you cannot do it in buildroot.

Why do you say that?
Of course, Buildroot does support adding cmake configure options [1].
You can also check some cmake-based packages already integrated (e.g.:
[2]).

If you know beforehand how grow the stack, I would suggest to set it
in the *_CONF_OPTS variables.
This may depends on the target architecture.

>
> It seems to be possible to access this information in another way
> since STACK_GROWS_DOWNWARD is defined in some headers. In my case they
> are:
>
> output/build/host-gcc-final-4.8.3/gcc/config/arm/arm.h
> (option a)
>
> or
>
> output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.3/plugin/include/config/arm/arm.h
> (option b)
>
> or
>
> output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.8.3/plugin/include/tm.h
> which in turns includes config/arm/arm.h  but seems more generic
> (option c)
>
> using these files I could automatically determine the correct value
> for STACK_DIRECTION (either searching them for STACK_GROWS_DOWNWARD or
> calling C preprocessor on an ad-hoc source file that would include them).
>
> The question is: how to determine inside buildroot which file to use?

This does not look right :-/ because:
- it search in something not in the sysroot;
- it is only valid when using the buildroot-toolchain backend.

Indeed, it seems the STACK_GROWS_DOWNWARD definition is only available
in the compiler sources, not in the preprocessor output for the target
:-/

>
> I was thinking of using a combination of the following variables to
> determine the position of these headers. I'll list them with the value
> they have in my case. Do you think it's a good idea? Do you think it's
> portable?
>
> BR2_ARCH="arm"
> BR2_GCC_VERSION=4.8.3
> BR2_GCC_TARGET_MODE=arm
> BR2_TOOLCHAIN=y
> BR2_TOOLCHAIN_BUILDROOT=y
> BR2_TOOLCHAIN_BUILDROOT_VENDOR=buildroot
> BR_TOOLCHAIN_USES_UCLIBC=y
> BR2_TOOLCHAIN_BUILDROOT_UCLIBC=y
> BR2_ARM_EABI=y
>
> Using these variables it seems I can find the correct file but I'm not
> sure it's the correct way to do things. What do you think? Do you have
> suggestions?

Instead of checking the compiler sources, I prefer you set the stack
growing direction through the CMake args.

Regards,


[1] http://buildroot.org/downloads/manual/manual.html#_infrastructure_for_cmake_based_packages
[2] http://git.buildroot.net/buildroot/tree/package/libwebsockets/libwebsockets.mk


-- 
Samuel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] using BR2 variables to find a specific header file
  2014-10-13 19:42 ` Samuel Martin
@ 2014-10-14 10:58   ` Sylvain Raybaud
  2014-10-14 12:18     ` Samuel Martin
  0 siblings, 1 reply; 6+ messages in thread
From: Sylvain Raybaud @ 2014-10-14 10:58 UTC (permalink / raw)
  To: buildroot

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike, Samuel, all,

On 13/10/2014 21:42, Samuel Martin wrote:
> Hi Sylvain,
> 
> On Mon, Oct 13, 2014 at 7:10 PM, Sylvain Raybaud 
> <sylvain.raybaud@green-communications.fr> wrote:
[...]
>> During cross-compile these tests cannot be run therefore the
>> package expects -DSTACK_DIRECTION=+/-1 to be passed to cmake. Of
>> course you cannot do it in buildroot.
> 
> Why do you say that? Of course, Buildroot does support adding cmake
> configure options [1]. You can also check some cmake-based packages
> already integrated (e.g.: [2]).

I mean I can pass arguments to cmake but if I hardcode a value I break
compatibility with any platform that would require the other value.
However...

> 
> If you know beforehand how grow the stack, I would suggest to set
> it in the *_CONF_OPTS variables. This may depends on the target
> architecture.
> 
>> It seems to be possible to access this information in another
>> way since STACK_GROWS_DOWNWARD is defined in some headers.
[...]
> 
> This does not look right :-/ because: - it search in something not
> in the sysroot; - it is only valid when using the
> buildroot-toolchain backend.
> 
> Indeed, it seems the STACK_GROWS_DOWNWARD definition is only
> available in the compiler sources, not in the preprocessor output
> for the target :-/
> 
>> [...]
> 
> Instead of checking the compiler sources, I prefer you set the
> stack growing direction through the CMake args.
> 
> Regards,

Mark's reply and yours strongly suggest that it's a better idea to
hardcode the correct value. I shall do so!

Thanks a lot!

Cheers,

- -- 
Sylvain Raybaud
www.green-communications.fr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUPQHnAAoJEEkkwl4JtJ9y8SEQAKFGepXykyQ/IdW5Y4oyOC1P
C1Qxjkve4/JlGQlhn14zeUFSbBoNGoZrpEwaER/ygfiTUZtITdRwvW6SyZhdXGPs
m4DkznR1+/ZCOCQdEglyON54VHGQU4l5caC0vbXENhjcMyLivCv1Ue8tGNO0yP4y
HfxXqPBQHe79cHeIJwpiYn6wFlDxLTZmhOs9BxfxTCVCQr1nWPW7SqOKnHfaj5Us
SdHZ2OPVI9M7IuNWDHdHayQoXcbiOHveb7Bh1FJY8GpK8F3CbVXZ/E/l+yxWU8mc
CoZhQy3sJG0IAUZ+JerkTN1h15RsSyHJb6lKhE7zQ+LIhiuhj2dJNntwQ0eJCRRV
G3h2NQti0T6ez8IuNmNJ58UEUQ72y26Ys1oU8LQfX2ZkJNmMeQlzlFGcESWkvW5B
4E059eSSHIhBH5j2slpYDe/622dIy8s/Wd5E6ww55lCwxFJJ4RmHKwC3u1YcXZO+
z/nB4I9Qmukfq1IXrUxCPgM4v95Z6eCjROFIb/n7/OSCJ5J2f0vi6WBczfonzoyK
tG0sOsub9ZQjUzAI1C8iqUn+W8eEeed7V1jVuLswP3Zvx2yByaNidcjHB2CM6UUk
j6GcXOTqMAS5L7Bv/95akn8EJ1w0nyZnmuy1gBU0sGekNWE/uooTHPfoFAgivKnE
CetDbXUvZLStUnYcL3yw
=dO+1
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] using BR2 variables to find a specific header file
  2014-10-14 10:58   ` Sylvain Raybaud
@ 2014-10-14 12:18     ` Samuel Martin
  0 siblings, 0 replies; 6+ messages in thread
From: Samuel Martin @ 2014-10-14 12:18 UTC (permalink / raw)
  To: buildroot

On Tue, Oct 14, 2014 at 12:58 PM, Sylvain Raybaud
<sylvain.raybaud@green-communications.fr> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Mike, Samuel, all,
>
> On 13/10/2014 21:42, Samuel Martin wrote:
>> Hi Sylvain,
>>
>> On Mon, Oct 13, 2014 at 7:10 PM, Sylvain Raybaud
>> <sylvain.raybaud@green-communications.fr> wrote:
> [...]
>>> During cross-compile these tests cannot be run therefore the
>>> package expects -DSTACK_DIRECTION=+/-1 to be passed to cmake. Of
>>> course you cannot do it in buildroot.
>>
>> Why do you say that? Of course, Buildroot does support adding cmake
>> configure options [1]. You can also check some cmake-based packages
>> already integrated (e.g.: [2]).
>
> I mean I can pass arguments to cmake but if I hardcode a value I break
> compatibility with any platform that would require the other value.
> However...

What I mean is something like this:
in the *.mk:
---
ifeq ($(BR2_arm)$(BR2_some_arch_with_stack_growing_downward),y)
FOO_CONF_OPTS += -DSTACK_DIRECTION=-1
endif
ifeq ($(BR2_some_other_arch_with_stack_growing_upward),y)
FOO_CONF_OPTS += -DSTACK_DIRECTION=+1
endif
---

This way you'll support all architectures (at least the one you know
how the stack grows).

>
>>
>> If you know beforehand how grow the stack, I would suggest to set
>> it in the *_CONF_OPTS variables. This may depends on the target
>> architecture.
>>
>>> It seems to be possible to access this information in another
>>> way since STACK_GROWS_DOWNWARD is defined in some headers.
> [...]
>>
>> This does not look right :-/ because: - it search in something not
>> in the sysroot; - it is only valid when using the
>> buildroot-toolchain backend.
>>
>> Indeed, it seems the STACK_GROWS_DOWNWARD definition is only
>> available in the compiler sources, not in the preprocessor output
>> for the target :-/
>>
>>> [...]
>>
>> Instead of checking the compiler sources, I prefer you set the
>> stack growing direction through the CMake args.
>>
>> Regards,
>
> Mark's reply and yours strongly suggest that it's a better idea to
> hardcode the correct value. I shall do so!
>
> Thanks a lot!
>
> Cheers,
>
> - --
> Sylvain Raybaud
> www.green-communications.fr
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
>
> iQIcBAEBAgAGBQJUPQHnAAoJEEkkwl4JtJ9y8SEQAKFGepXykyQ/IdW5Y4oyOC1P
> C1Qxjkve4/JlGQlhn14zeUFSbBoNGoZrpEwaER/ygfiTUZtITdRwvW6SyZhdXGPs
> m4DkznR1+/ZCOCQdEglyON54VHGQU4l5caC0vbXENhjcMyLivCv1Ue8tGNO0yP4y
> HfxXqPBQHe79cHeIJwpiYn6wFlDxLTZmhOs9BxfxTCVCQr1nWPW7SqOKnHfaj5Us
> SdHZ2OPVI9M7IuNWDHdHayQoXcbiOHveb7Bh1FJY8GpK8F3CbVXZ/E/l+yxWU8mc
> CoZhQy3sJG0IAUZ+JerkTN1h15RsSyHJb6lKhE7zQ+LIhiuhj2dJNntwQ0eJCRRV
> G3h2NQti0T6ez8IuNmNJ58UEUQ72y26Ys1oU8LQfX2ZkJNmMeQlzlFGcESWkvW5B
> 4E059eSSHIhBH5j2slpYDe/622dIy8s/Wd5E6ww55lCwxFJJ4RmHKwC3u1YcXZO+
> z/nB4I9Qmukfq1IXrUxCPgM4v95Z6eCjROFIb/n7/OSCJ5J2f0vi6WBczfonzoyK
> tG0sOsub9ZQjUzAI1C8iqUn+W8eEeed7V1jVuLswP3Zvx2yByaNidcjHB2CM6UUk
> j6GcXOTqMAS5L7Bv/95akn8EJ1w0nyZnmuy1gBU0sGekNWE/uooTHPfoFAgivKnE
> CetDbXUvZLStUnYcL3yw
> =dO+1
> -----END PGP SIGNATURE-----
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot



-- 
Samuel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] using BR2 variables to find a specific header file
  2014-10-13 17:30 ` Mike Zick
@ 2014-10-14 20:58   ` Arnout Vandecappelle
  0 siblings, 0 replies; 6+ messages in thread
From: Arnout Vandecappelle @ 2014-10-14 20:58 UTC (permalink / raw)
  To: buildroot

On 13/10/14 19:30, Mike Zick wrote:
> On Mon, 13 Oct 2014 19:10:13 +0200
> Sylvain Raybaud <sylvain.raybaud@green-communications.fr> wrote:
> 
>> > -----BEGIN PGP SIGNED MESSAGE-----
>> > Hash: SHA1
>> > 
>> > Dear all
>> > 
>> > I'm trying to integrate a cmake based package wich is not very
>> > cross-compiling friendly (MariaDB galera cluster). During normal
>> > compile this package runs some tests in order to determine if stacks
>> > grows downward or upward. During cross-compile these tests cannot be
>> > run therefore the package expects -DSTACK_DIRECTION=+/-1 to be passed
>> > to cmake. Of course you cannot do it in buildroot.
>> >
> I think that the only processor where the stack grows up is PA-RISC.
> Which is not one of the Buildroot supported processors.
> 
> So just hard code it (by patching if required) to down.

 I did a quick check in the gcc 4.9.1 sources, and indeed it seems that the only
architectures that don't have it downward are PA-RISC, Xstormy16 and VMS. So
you're safe with hardcoding it.

 Regards,
 Arnout

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-10-14 20:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-13 17:10 [Buildroot] using BR2 variables to find a specific header file Sylvain Raybaud
2014-10-13 17:30 ` Mike Zick
2014-10-14 20:58   ` Arnout Vandecappelle
2014-10-13 19:42 ` Samuel Martin
2014-10-14 10:58   ` Sylvain Raybaud
2014-10-14 12:18     ` Samuel Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox