Bug 7469

Summary: SDL package cannot be found on OpenSUSE 13.2
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Mihail Stanciu <stanciux.mihail>
Component: coreAssignee: Juro Bystricky <juro.bystricky>
Status: RESOLVED OBSOLETE QA Contact: Alexandru Roman <alexandru.costinx.roman>
Severity: normal    
Priority: Medium+ CC: alex.kanavin, alexandru.c.georgescu, costin.c.constantin, meta.mr.watcher, meta.watcher, richard.purdie, ross.burton
Version: unspecified   
Target Milestone: 1.6.4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: Unknown (Hard to categorize)
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
full log file
none
qemu-native configure patch
none
qemu-native configure patch (updated) none

Description Mihail Stanciu 2015-03-17 12:54:19 UTC
Created attachment 2447 [details]
full log file

Hello,

Several buildsets on OpenSUSE 13.2 AB machine are failing due to the following error:
| ERROR: User requested feature sdl
|        configure was not able to find it

Installed SDL packages include:

 libSDL-1_2-0
 libSDL-devel
 libSDL2-2_0-0
 libSDL2-devel
 libSDL-1_2-0-32bit
 libSDL-devel-32bit
 libSDL2-2_0-0-32bit
 libSDL2-devel-32bit

Buildsets are failing while at do_configure task for qemu-native.

Tested on 1.6.3_RC2: 6b8f7999c3e86d6e834af95ffe4c33d0d53db34a

See attached logfile.
Comment 1 Saul Wold 2015-03-19 21:02:35 UTC
Further details on this as found when debugging with debian8.  The issue turns 
out to be when configuring qemu-native, it does a basic link against SDL to 
test for the library.  The issue is that when we compile that simple test and 
link with libSDL, it then requires libgcrypt which in turn requires 
libgpg-error, this is where the issue arises. If we have build native version 
of libgpg-error then we will have a link problem since the API as changed 
slight between the 0.10 (from Daisy) and 0.13 version from debian8 or openSUSE 
13.2.  Since the linkage of libSDL and libgcrypt, which use libgpg-error, do 
not specifiy a version we get which evey comes first in the link order.  If we 
can some how set the link order (as RP mentioned in the Triage call) then we 
can direct the linker to use the host's libgpg-error which is the correct 
version to match the host's libSDL and libgcrypt.  We don't see this with 1.7 
and 1.8 because they have the updated version of libgpg-error.

To reproduce this, simply build libgpg-error from daisy and run the following 
script (after you fixup the sysroot variab;le)
sysroot=/home/swold/poky/daisy/tmp/sysroots/x86_64-linux

cat > /tmp/sdl_test.c << E_O_F
#include <SDL.h>
#undef main /* We don't want SDL to override our main() */
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
E_O_F

echo "FAILS"
gcc \
-o /tmp/sdl_fail /tmp/sdl_test.c \
-I/usr/include/SDL \
-Wl,-rpath-link,/usr/lib/x86_64-linux-gnu \
-Wl,-rpath-link,$sysroot/usr/lib \
-Wl,-rpath,/usr/lib/x86_64-linux-gnu \
-Wl,-rpath,$sysroot/usr/lib \
-lSDL

echo "WORKS"
gcc \
-o /tmp/sdl_work /tmp/sdl_test.c \
-I/usr/include/SDL \
-Wl,-rpath-link,/usr/lib/x86_64-linux-gnu \
-Wl,-rpath,/usr/lib/x86_64-linux-gnu \
-lSDL


I tried to reoder the rpath setting, that did not work, nor did useing -L and 
chaning the order.

The ultimate patch will need to go against qemu-native's configure script since 
that's what runs this SDL check
Comment 2 Alexandru Georgescu 2015-03-23 13:31:48 UTC
changed the regression field to unknown. This distro wasn't supported during 1.6 release development cycle, so the previous flag (regression, used to work) is invalid
Comment 3 Alexandru Georgescu 2015-03-23 13:31:48 UTC
changed the regression field to unknown. This distro wasn't supported during 1.6 release development cycle, so the previous flag (regression, used to work) is invalid
Comment 4 Juro Bystricky 2015-03-23 15:46:31 UTC
Incidentally, I could not reproduce the problem with Daisy 1.6.2 tarball on openSUSE13.2.
(The problem was detected with 1.6.3_RC2: 6b8f7999c3e86d6e834af95ffe4c33d0d53db34a)
Comment 5 Juro Bystricky 2015-03-26 18:05:34 UTC
I am testing with the patch below.
Basically, we append CFLAGS with values for linker so that /usr/lib is searched before any other path (CFLAGS are applied before LDFLAGS). This fixes the problem. I added a "verbose" flag so we can follow the linker search process in configure.log. 
Also note the fix was needed in two separate tests.

--- configure_org	2013-11-27 14:15:55.000000000 -0800
+++ configure_new	2015-03-26 10:48:31.000000000 -0700
@@ -1802,6 +1802,15 @@ if test -n "$cross_prefix" && test "$(ba
 fi
 
 sdl_too_old=no
+
+sdl_cflags_ex="
+ -Wl,--verbose
+ -L/usr/lib 
+ -L/usr/lib64
+ -Wl,-rpath-link,/usr/lib 
+ -Wl,-rpath-link,/usr/lib64 
+ "
+ 
 if test "$sdl" != "no" ; then
   cat > $TMPC << EOF
 #include <SDL.h>
@@ -1814,7 +1823,7 @@ EOF
   else
     sdl_libs=`$sdlconfig --libs 2> /dev/null`
   fi
-  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
+  if compile_prog "$sdl_cflags $sdl_cflags_ex" "$sdl_libs" ; then
     if test "$_sdlversion" -lt 121 ; then
       sdl_too_old=yes
     else
@@ -1853,7 +1862,7 @@ if test "$sdl" = "yes" ; then
 #endif
 int main(void) { return 0; }
 EOF
-  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
+  if compile_prog "$sdl_cflags $sdl_cflags_ex" "$sdl_libs" ; then
     sdl_libs="$sdl_libs -lX11"
   fi
   libs_softmmu="$sdl_libs $libs_softmmu"
Comment 6 Juro Bystricky 2015-03-26 18:06:24 UTC
Created attachment 2456 [details]
qemu-native configure patch
Comment 7 Juro Bystricky 2015-03-26 18:14:13 UTC
My previous comment "Incidentally, I could not reproduce the problem with Daisy 1.6.2 tarball on openSUSE13.2." may have been wrong. The failure relies on a particular sequence (libgpg-error needs to be built before qemu-native).
Also, the "fix" fixes the configure of qemu-native, but the actual build eventually fails.
Comment 8 Juro Bystricky 2015-03-26 21:39:17 UTC
The patch below also fixes the build of qemu-native....
Same idea, modify CFLAGS passed to Makefile to reorder linker search path.

--- configure_org	2013-11-27 14:15:55.000000000 -0800
+++ configure_new1	2015-03-26 12:46:35.000000000 -0700
@@ -1802,6 +1802,8 @@ if test -n "$cross_prefix" && test "$(ba
 fi
 
 sdl_too_old=no
+sdl_cflags_ex="-Wl,--verbose -L/usr/lib  -L/usr/lib64 -Wl,-rpath-link,/usr/lib  -Wl,-rpath-link,/usr/lib64"
+ 
 if test "$sdl" != "no" ; then
   cat > $TMPC << EOF
 #include <SDL.h>
@@ -1814,7 +1816,7 @@ EOF
   else
     sdl_libs=`$sdlconfig --libs 2> /dev/null`
   fi
-  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
+  if compile_prog "$sdl_cflags $sdl_cflags_ex" "$sdl_libs" ; then
     if test "$_sdlversion" -lt 121 ; then
       sdl_too_old=yes
     else
@@ -1853,7 +1855,7 @@ if test "$sdl" = "yes" ; then
 #endif
 int main(void) { return 0; }
 EOF
-  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
+  if compile_prog "$sdl_cflags $sdl_cflags_ex" "$sdl_libs" ; then
     sdl_libs="$sdl_libs -lX11"
   fi
   libs_softmmu="$sdl_libs $libs_softmmu"
@@ -4287,6 +4289,7 @@ echo "OBJCOPY=$objcopy" >> $config_host_
 echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "LIBTOOL=$libtool" >> $config_host_mak
+CFLAGS="$CFLAGS $sdl_cflags_ex"
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
Comment 9 Juro Bystricky 2015-03-26 21:40:45 UTC
Created attachment 2457 [details]
qemu-native configure patch (updated)
Comment 10 Ross Burton 2015-10-08 20:21:56 UTC
Is this still valid, and was that patch ever submitted to the list?
Comment 11 Juro Bystricky 2015-10-12 17:46:57 UTC
D'oh! Patch was submitted to the mailing list, but some tweaks need to be done in order for the patch to be merged. Will rebase, retest, repost ... (today)
Comment 12 Ross Burton 2015-10-12 19:02:00 UTC
Thanks Juro.  Is this specific to daisy or should a similar patch be applied for master and fido too?
Comment 13 Juro Bystricky 2015-10-12 20:59:16 UTC
(In reply to comment #12)
> Thanks Juro.  Is this specific to daisy or should a similar patch be applied
> for master and fido too?

AFAIK it's Daisy only (1.6), ABI conflict between new OS distro and old yocto distro in libcrypt/libgpg-error. To my knowledge only observed with OpenSUSE 13.2/Daisy.

The following sequence can reproduce the build error:
    
$ bitbake qemu-native -c cleanall
$ bitbake libgpg-error-native
$ bitbake qemu-native
Comment 14 Costin 2015-11-04 15:44:31 UTC
Found something similar on an Ubuntu 15.04 machine, latest master hash: fc45deac89ef63ca1c44e763c38ced7dfd72cbe1

To reproduce: 
1) add these two lines to local.conf:
DISTRO_FEATURES_remove = "x11"
DISTRO_FEATURES_append = " wayland"

2) MACHINE=qemux86 bitbake core-image-weston
...
| ERROR: User requested feature sdl
|        configure was not able to find it.
|        Install SDL devel
...

However libsdl is available on the host OS
ubnt:/media/yp_builds/2poky/build$ sudo apt-get install libsdl1.2-dev libsdl1.2debian
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libsdl1.2-dev is already the newest version.
libsdl1.2debian is already the newest version.
libsdl1.2debian set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Comment 15 Alexander Kanavin 2015-11-23 16:14:06 UTC
The last issue is probably a duplicate of bug 8553. You can check from build/config.log if that is the case.
Comment 16 Ross Burton 2016-07-13 23:54:38 UTC
Basically this was the first instance of host libSDL causing problems that was resolved in bug 8553.

We've fixed it properly back to 1.8 / Fido, which was released in April 2015.

Considering that earlier releases (1.7/Dizzy and 1.6/Daisy) are therefore two years old now, I think we should close this as obsolete.  The patches are in fido if someone wishes to backport them:

- conf/local.conf.sample: comment out ASSUME_PROVIDED=libsdl-native
- xorg-lib: allow native building without x11 DISTRO_FEATURES
- base: check for existing prefix when expanding names in PACKAGECONFIG
- libsdl: expand PACKAGECONFIG and enable native builds
Comment 17 Juro Bystricky 2016-07-20 23:38:59 UTC
Closing as obsolete, as suggested by Ross.