All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] libpthsem: fix setjmp/longjmp detection
@ 2015-08-19 11:08 Thomas Petazzoni
  2015-08-19 12:21 ` Yann E. MORIN
  2015-08-19 15:46 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2015-08-19 11:08 UTC (permalink / raw)
  To: buildroot

libpthsem has been affected since quite a while by build issues, but
occuring only on Nathaniel Roach's autobuilder. The failure message
is:

  error: #error "Unsupported Linux (g)libc version and/or platform"

This message comes from pth_mctx.c file, which implements five methods
for machine context initialization:

  VARIANT 1: THE STANDARDIZED SVR4/SUSv2 APPROACH
  VARIANT 2: THE SIGNAL STACK TRICK
  VARIANT 3: LINUX SPECIFIC JMP_BUF FIDDLING
  VARIANT 4: INTERACTIVE SPECIFIC JMP_BUF FIDDLING
  VARIANT 5: WIN32 SPECIFIC JMP_BUF FIDDLING

The "Unsupported (g)libc version and/or platform" only appears when
"VARIANT 4" is used, since VARIANT 4 only supports a very limited
number of platforms. So when building with Nathaniel's autobuilder,
VARIANT 4 is chosen.

However, when you build libpthsem on some other machine than
Nathaniel's autobuilder, VARIANT 2 is chosen, and works regardless of
the glibc version or architecture.

VARIANT 2 is chosen when:

      !PTH_MCTX_DSP(sjljlx)  &&\
      !PTH_MCTX_DSP(sjljisc) &&\
      !PTH_MCTX_DSP(sjljw32)

On both Nathaniel's autobuilder, and on a different machine, the
PTH_MCTX_MTH macro gives sjlj:

  #define PTH_MCTX_MTH_use PTH_MCTX_MTH_sjlj

However, on a "normal" machine, the PTH_MCTX_DSP macro gives ssjlj:

  #define PTH_MCTX_DSP_use PTH_MCTX_DSP_ssjlj

While on Nathaniel's autobuilder, it gives:

  #define PTH_MCTX_DSP_use PTH_MCTX_DSP_sjljlx

This explains why VARIANT 4 is being used on Nathaniel's autobuilder,
while VARIANT 2 is used when building on other platforms.

The decision of the value for PTH_MCTX_DSP is derived as follows in
configure.ac:

 AC_CHECK_SJLJ(sjlj=yes, sjlj=no, sjlj_type)
 [...]
 elif test ".$sjlj" = .yes; then
    mctx_mth=sjlj
    mctx_dsp=$sjlj_type
 [...]
 AC_DEFINE_UNQUOTED(PTH_MCTX_DSP_use, [PTH_MCTX_DSP_$mctx_dsp], [define for machine context dispatching])

So basically, the value of PTH_MCTX_DSP is $sjlj_type, as returned by
the AC_CHECK_SJLJ autoconf macro, implemented in
acinclude.m4. However, reading this macro is quite informative: it
does a number of tests that are not cross-compile
friendly. Especially, it looks at the kernel version with 'uname -r'
to decide whether the Linux system is braindead or not. If the system
runs a 2.2.x kernel or newer 2.x, or a 3.x kernel, everything is fine,
the system is not braindead, and sjlj_type is set to ssjlj. However,
if the build system runs a 4.x kernel, then it is considered as
braindead, and sjlj_type is set to sjljlx.

And indeed, Nathaniel's autobuilder is running a 4.x kernel, while all
other autobuilders run 2.x or 3.x kernels.

Since for all sane Linux systems, this AC_CHECK_SJLJ macro concludes
that the setjmp/longtmp type is ssjlj, this commit takes the simplest
route of forcing this value, skipping the broken detection.

Note that we're overriding ac_cv_check_sjlj instead of using the
--with-mctx-* options, since the latter do not work properly in the
context of Nathaniel's autobuilder, as the broken cross-compilation
tests continue to cause problems.

Fixes:

  http://autobuild.buildroot.org/results/3dd/3dd66d70c2e36f2d9fb0a0fe01bbdec009d55067/
  and many similar build failures

This patch has been tested by Nathaniel Roach in the context of his
autobuilder instance which was causing the original problem.

Tested-by: Nathaniel Roach <nroach44@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/libpthsem/libpthsem.mk | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/package/libpthsem/libpthsem.mk b/package/libpthsem/libpthsem.mk
index f9f6f71..b8a3d7d 100644
--- a/package/libpthsem/libpthsem.mk
+++ b/package/libpthsem/libpthsem.mk
@@ -13,6 +13,20 @@ LIBPTHSEM_AUTORECONF = YES
 LIBPTHSEM_INSTALL_STAGING = YES
 LIBPTHSEM_CONFIG_SCRIPTS = pthsem-config
 
+# Force the setjmp/longjmp detection, because the test being done in
+# the AC_CHECK_SJLJ macro is not cross-compilation safe: it checks the
+# running kernel with 'uname -r', and checks the C library version by
+# looking at /usr/include/features.h. In terms of kernel version, it
+# assumes any version later than 2.2.x is fine, except that it doesn't
+# recognize 4.x as a valid kernel version, recognizing such systems as
+# "braindead" and therefore falling back to the 'sjljlx' value for
+# ac_cv_check_sjlj. In terms of C library version, it wants
+# __GLIBC_MINOR to be at least 1. Since both conditions are true for
+# all Buildroot systems, we can simply force the setjmp/longjmp
+# detection to ssjlj.
+LIBPTHSEM_CONF_ENV += \
+	ac_cv_check_sjlj=ssjlj
+
 ifeq ($(BR2_PACKAGE_LIBPTHSEM_COMPAT),y)
 LIBPTHSEM_CONF_OPTS += --enable-compat
 LIBPTHSEM_CONFIG_SCRIPTS += pth-config
-- 
2.5.0

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

* [Buildroot] [PATCH] libpthsem: fix setjmp/longjmp detection
  2015-08-19 11:08 [Buildroot] [PATCH] libpthsem: fix setjmp/longjmp detection Thomas Petazzoni
@ 2015-08-19 12:21 ` Yann E. MORIN
  2015-08-19 15:46 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2015-08-19 12:21 UTC (permalink / raw)
  To: buildroot

Thomas, All,

On 2015-08-19 13:08 +0200, Thomas Petazzoni spake thusly:
> libpthsem has been affected since quite a while by build issues, but
> occuring only on Nathaniel Roach's autobuilder. The failure message
> is:
> 
>   error: #error "Unsupported Linux (g)libc version and/or platform"
[--SNIP--]
> Fixes:
> 
>   http://autobuild.buildroot.org/results/3dd/3dd66d70c2e36f2d9fb0a0fe01bbdec009d55067/
>   and many similar build failures

Impressive work! :-)

> This patch has been tested by Nathaniel Roach in the context of his
> autobuilder instance which was causing the original problem.
> 
> Tested-by: Nathaniel Roach <nroach44@gmail.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

So I've made a little uname wrapper that fakes a 4.1.2 kernel version,
and I was able to reproduce the build failure, now.

Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Here are the tests I've done (4.1.2 was with the uname wrapper first in
the PATH):

                  |                 uname -r
                  | 3.13.0-62-generic       4.1.2
    --------------+-----------------------------------
    master        | builds                  broken
    this patch    | builds                  builds

For reference, here's the uname wrapper:

    #!/bin/bash
    real_uname="/bin/uname"
    real_version="$( "${real_uname}" -r )"
    "${real_uname}" "${@}" |sed -r -e "s/${real_version//./\\.}/4.1.2/;"

Regards,
Yann E. MORIN.

> ---
>  package/libpthsem/libpthsem.mk | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/package/libpthsem/libpthsem.mk b/package/libpthsem/libpthsem.mk
> index f9f6f71..b8a3d7d 100644
> --- a/package/libpthsem/libpthsem.mk
> +++ b/package/libpthsem/libpthsem.mk
> @@ -13,6 +13,20 @@ LIBPTHSEM_AUTORECONF = YES
>  LIBPTHSEM_INSTALL_STAGING = YES
>  LIBPTHSEM_CONFIG_SCRIPTS = pthsem-config
>  
> +# Force the setjmp/longjmp detection, because the test being done in
> +# the AC_CHECK_SJLJ macro is not cross-compilation safe: it checks the
> +# running kernel with 'uname -r', and checks the C library version by
> +# looking at /usr/include/features.h. In terms of kernel version, it
> +# assumes any version later than 2.2.x is fine, except that it doesn't
> +# recognize 4.x as a valid kernel version, recognizing such systems as
> +# "braindead" and therefore falling back to the 'sjljlx' value for
> +# ac_cv_check_sjlj. In terms of C library version, it wants
> +# __GLIBC_MINOR to be at least 1. Since both conditions are true for
> +# all Buildroot systems, we can simply force the setjmp/longjmp
> +# detection to ssjlj.
> +LIBPTHSEM_CONF_ENV += \
> +	ac_cv_check_sjlj=ssjlj
> +
>  ifeq ($(BR2_PACKAGE_LIBPTHSEM_COMPAT),y)
>  LIBPTHSEM_CONF_OPTS += --enable-compat
>  LIBPTHSEM_CONFIG_SCRIPTS += pth-config
> -- 
> 2.5.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

* [Buildroot] [PATCH] libpthsem: fix setjmp/longjmp detection
  2015-08-19 11:08 [Buildroot] [PATCH] libpthsem: fix setjmp/longjmp detection Thomas Petazzoni
  2015-08-19 12:21 ` Yann E. MORIN
@ 2015-08-19 15:46 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2015-08-19 15:46 UTC (permalink / raw)
  To: buildroot

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > libpthsem has been affected since quite a while by build issues, but
 > occuring only on Nathaniel Roach's autobuilder. The failure message
 > is:

 >   error: #error "Unsupported Linux (g)libc version and/or platform"

 > This message comes from pth_mctx.c file, which implements five methods
 > for machine context initialization:

[Lots of funky stuff snipped]

Thanks a lot for debugging this - Committed, thanks!

-- 
Bye, Peter Korsgaard

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

end of thread, other threads:[~2015-08-19 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-19 11:08 [Buildroot] [PATCH] libpthsem: fix setjmp/longjmp detection Thomas Petazzoni
2015-08-19 12:21 ` Yann E. MORIN
2015-08-19 15:46 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.