Skip to contentSkip to conversation

using BR2 variables to find a specific header file

Buildroot Sylvain Raybaud 4 participants 6 messages Oct 13, 2014 – Oct 14, 2014

lore
Share & tools
lore
#0 lore raw

-----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-----

#1 lore raw
Quoted 12 lines · On Mon, 13 Oct 2014 19:10:13 +0200 Sylvain Raybaud…

-----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

Quoted 70 lines

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

#3 lore raw
In reply to Sylvain Raybaud

Hi Sylvain,

Quoted 9 lines · Sylvain Raybaud

-----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! :-/

Quoted 3 lines

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.

Quoted 19 lines

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)

Quoted 5 lines

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 :-/

Quoted 16 lines

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

Quoted 3 lines

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

Signature · 1 line
Samuel
#4 lore raw

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

Mike, Samuel, all,

Quoted 4 lines · Samuel Martin

Hi Sylvain,

On Mon, Oct 13, 2014 at 7:10 PM, Sylvain Raybaud
<[email protected]> wrote:

[...]

Quoted 7 lines
Quoted 3 lines

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...

Quoted 7 lines

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.

Quoted 2 lines

It seems to be possible to access this information in another way since STACK_GROWS_DOWNWARD is defined in some headers.

[...]

Quoted 9 lines

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 :-/

Quoted 6 lines
Quoted 1 line

[...]

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-----

#5 lore raw
Quoted 15 lines · Sylvain Raybaud

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

Mike, Samuel, all,

Quoted 4 lines · Samuel Martin

Hi Sylvain,

On Mon, Oct 13, 2014 at 7:10 PM, Sylvain Raybaud
<[email protected]> wrote:

[...]

Quoted 4 lines
Quoted 3 lines

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.

Quoted 7 lines
Quoted 3 lines

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).

Quoted 56 lines
Quoted 8 lines

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.

Quoted 2 lines

It seems to be possible to access this information in another way since STACK_GROWS_DOWNWARD is defined in some headers.

[...]

Quoted 9 lines

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 :-/

Quoted 6 lines
Quoted 1 line

[...]

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

Signature · 1 line
Samuel
#2 lore raw
In reply to Mike Zick
Quoted 15 lines · Mike Zick
Quoted 5 lines · On Mon, 13 Oct 2014 19:10:13 +0200 Sylvain Raybaud…
Quoted 5 lines

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

Dear all

Quoted 7 lines
Quoted 7 lines

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.

Quoted 4 lines

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

Signature · 6 lines
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