Skip to contentSkip to conversation

gdb-cross-canadian: Fix linking issues when python support is enabled

PATCH Applied Khem Raj 4 participants 5 messages Mar 23, 2012

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 gdb-cross-canadian: Fix linking issues when python support is enabled

gdb-cross-canadian was linking with static version of libpython and looking for build host python when run. This could be mismatch between python-nativesdk and build host provided python. So we make it consistent to always use python-nativesdk

Instead of adding bunch of -L we add -rpath and -rpath-link so that gdb finds all needed libraries in SDK and does not reach out into host

This should fix yocto PR# 2077 as well.

---
 meta/recipes-devtools/gdb/gdb-cross-canadian.inc   |    7 ++++---
 .../recipes-devtools/gdb/gdb-cross-canadian_7.4.bb |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
meta/recipes-devtools/gdb/gdb-cross-canadian.inc +4 -3
index a7cac61..59412c4 100644
@@ -1,4 +1,5 @@
 inherit cross-canadian
+inherit python-dir
 
 DESCRIPTION = "cross-canadian gdb for ${TARGET_ARCH} target - GNU debugger"
 PN = "gdb-cross-canadian-${TRANSLATED_TARGET_ARCH}"
@@ -14,9 +15,9 @@ do_configure_prepend() {
 cat > ${WORKDIR}/python << EOF
 #! /bin/sh
 case "\$2" in
-        --includes) echo "-I${STAGING_INCDIR}/python${PYTHON_BASEVERSION}/" ;;
-        --ldflags) echo "-L${STAGING_LIBDIR}/../python${PYTHON_BASEVERSION}/config -lpthread -ldl -lutil -lm -lpython${PYTHON_BASEVERSION}" ;;
-        --exec-prefix) echo "/usr" ;;
+        --includes) echo "-I${STAGING_INCDIR}/${PYTHON_DIR}/" ;;
+        --ldflags) echo "-Wl,-rpath-link,${STAGING_LIBDIR}/.. -Wl,-rpath,${libdir}/.. -lpthread -ldl -lutil -lm -lpython${PYTHON_BASEVERSION}" ;;
+        --exec-prefix) echo "${exec_prefix}/bin" ;;
         *) exit 1 ;;
 esac
 exit 0
meta/recipes-devtools/gdb/gdb-cross-canadian_7.4.bb +1 -1
index dbcffde..dfb7d81 100644
@@ -1,7 +1,7 @@
 require gdb-common.inc
 require gdb-cross-canadian.inc
 
-PR = "${INC_PR}.3"
+PR = "${INC_PR}.4"
 
 GDBPROPREFIX = "--program-prefix='${TARGET_PREFIX}'"
 EXPAT = "--with-expat"
Signature · 1 line
1.7.5.4
Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Khem Raj

gdb-cross-canadian was linking with static version of libpython and looking for build host python when run. This could be mismatch between python-nativesdk and build host provided python. So we make it consistent to always use python-nativesdk

Quoted 7 lines

Instead of adding bunch of -L we add -rpath and -rpath-link so that gdb finds all needed libraries in SDK and does not reach out into host

This should fix yocto PR# 2077 as well.

Quoted 41 lines
---
 meta/recipes-devtools/gdb/gdb-cross-canadian.inc   |    7 ++++---
 .../recipes-devtools/gdb/gdb-cross-canadian_7.4.bb |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
meta/recipes-devtools/gdb/gdb-cross-canadian.inc +4 -3
index a7cac61..59412c4 100644
@@ -1,4 +1,5 @@
 inherit cross-canadian
+inherit python-dir
 
 DESCRIPTION = "cross-canadian gdb for ${TARGET_ARCH} target - GNU debugger"
 PN = "gdb-cross-canadian-${TRANSLATED_TARGET_ARCH}"
@@ -14,9 +15,9 @@ do_configure_prepend() {
 cat > ${WORKDIR}/python << EOF
 #! /bin/sh
 case "\$2" in
-        --includes) echo "-I${STAGING_INCDIR}/python${PYTHON_BASEVERSION}/" ;;
-        --ldflags) echo "-L${STAGING_LIBDIR}/../python${PYTHON_BASEVERSION}/config -lpthread -ldl -lutil -lm -lpython${PYTHON_BASEVERSION}" ;;
-        --exec-prefix) echo "/usr" ;;
+        --includes) echo "-I${STAGING_INCDIR}/${PYTHON_DIR}/" ;;
+        --ldflags) echo "-Wl,-rpath-link,${STAGING_LIBDIR}/.. -Wl,-rpath,${libdir}/.. -lpthread -ldl -lutil -lm -lpython${PYTHON_BASEVERSION}" ;;
+        --exec-prefix) echo "${exec_prefix}/bin" ;;
         *) exit 1 ;;
 esac
 exit 0
meta/recipes-devtools/gdb/gdb-cross-canadian_7.4.bb +1 -1
index dbcffde..dfb7d81 100644
@@ -1,7 +1,7 @@
 require gdb-common.inc
 require gdb-cross-canadian.inc
 
-PR = "${INC_PR}.3"
+PR = "${INC_PR}.4"
 
 GDBPROPREFIX = "--program-prefix='${TARGET_PREFIX}'"
 EXPAT = "--with-expat"
#2 lore raw
In reply to Khem Raj
Quoted 9 lines · Khem Raj

gdb-cross-canadian was linking with static version of libpython and looking for build host python when run. This could be mismatch between python-nativesdk and build host provided python. So we make it consistent to always use python-nativesdk

Instead of adding bunch of -L we add -rpath and -rpath-link so that gdb finds all needed libraries in SDK and does not reach out into host

Quoted 7 lines

This should fix yocto PR# 2077 as well.

---
 meta/recipes-devtools/gdb/gdb-cross-canadian.inc   |    7 ++++---
 .../recipes-devtools/gdb/gdb-cross-canadian_7.4.bb |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

Merged to master, thanks!

Richard

#3 lore raw
In reply to Khem Raj
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Khem Raj

gdb-cross-canadian was linking with static version of libpython and looking for build host python when run. This could be mismatch between python-nativesdk and build host provided python. So we make it consistent to always use python-nativesdk

Khem,
In my debug effort, I did not find that gdb-cross-canadian was
linking with static version of libpython. How did you find that out ? I think I can learn a lot from you :)

Thanks,
Nitin

author
#4 lore raw
Quoted 12 lines · Nitin A
Quoted 10 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Khem Raj

gdb-cross-canadian was linking with static version of libpython and looking for build host python when run. This could be mismatch between python-nativesdk and build host provided python. So we make it consistent to always use python-nativesdk

Quoted 4 lines

Khem,
 In my debug effort, I did not find that gdb-cross-canadian was linking with static version of libpython. How did you find that out ? I think I can learn a lot from you :)

Fire up gdb and persevere there is no secret sauce :) and hope for good luck that you see something.

Quoted 4 lines

Thanks,
Nitin