All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Busch <morphis@gravedo.de>
To: openembedded-devel@lists.openembedded.org
Subject: Re: [PATCH] cmake.bbclass: set the rpath for native binaries build with cmake
Date: Wed, 04 May 2011 22:46:29 +0200	[thread overview]
Message-ID: <4DC1BB25.1070808@gravedo.de> (raw)
In-Reply-To: <1304528108-5217-1-git-send-email-morphis@gravedo.de>

On 04.05.2011 18:55, Simon Busch wrote:
> In the default configuration cmake does not set a rpath for its builded binaries. This
> leads to errors at runtime when the binaries not find their needed runtime libraries.
> Please note that this is only done for recipes inheriting the native class!
> 
> Signed-off-by: Simon Busch <morphis@gravedo.de>
> ---
>  classes/cmake.bbclass |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/classes/cmake.bbclass b/classes/cmake.bbclass
> index 40fadea..e8e485a 100644
> --- a/classes/cmake.bbclass
> +++ b/classes/cmake.bbclass
> @@ -24,6 +24,13 @@ OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${TARGET_CPPFLAGS} -f
>  OECMAKE_C_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
>  OECMAKE_CXX_FLAGS_RELEASE ?= "${SELECTED_OPTIMIZATION} -DNDEBUG"
>  
> +OECMAKE_RPATH ?= ""
> +python __anonymous() {
> +    # Only set OECMAKE_RPATH if we build a native recipe
> +    if bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
> +        bb.data.setVar('OECMAKE_RPATH', '${libdir}', d)
> +}
> +
>  cmake_do_generate_toolchain_file() {
>  # CMake system name must be something like "Linux".
>  # This is important for cross-compiling.
> @@ -44,6 +51,10 @@ cmake_do_generate_toolchain_file() {
>    echo "set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )" >> ${WORKDIR}/toolchain.cmake
>  # Use qt.conf settings
>    echo "set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )" >> ${WORKDIR}/toolchain.cmake
> +
> +# We need to set the rpath to the correct directory as cmake does not provide any
> +# directory as rpath by default
> +  echo "set( CMAKE_INSTALL_RPATH ${OECMAKE_RPATH} )" >> ${WORKDIR}/toolchain.cmake
>  }
>  
>  addtask generate_toolchain_file after do_patch before do_configure


To proof this: I tested it with native and non-native recipes (all
builded with cmake.bbclass) and grep'ed through the resulting binaries
afterwards to be sure there is a rpath in the native ones (and the
correct one) and no one in the non native recipes:

morphis@nirvana ...root/tmp/sysroots/x86_64-linux/usr/bin % objdump -x
generatorrunner | grep RPATH
  RPATH                $ORIGIN/../lib:$ORIGIN/../lib

morphis@nirvana ...libshiboken-1.0.2-r0.0/package/usr/lib % pwd
/home/morphis/oe/buildroot/tmp/work/armv7a-oe-linux-gnueabi/libshiboken-1.0.2-r0.0/package/usr/lib
morphis@nirvana ...libshiboken-1.0.2-r0.0/package/usr/lib % objdump -x
libshiboken-python2.6.so.1.0.2 | grep RPATH
1 morphis@nirvana ...libshiboken-1.0.2-r0.0/package/usr/lib %

[...]

regards,
Simon



      reply	other threads:[~2011-05-04 20:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-04 15:50 [PATCH] cmake.bbclass: set the rpath for binaries build with cmake to ${libdir} Simon Busch
2011-05-04 16:09 ` Phil Blundell
2011-05-04 16:19   ` Simon Busch
2011-05-04 16:54     ` Phil Blundell
2011-05-04 17:00       ` Simon Busch
2011-05-05  9:50         ` Phil Blundell
2011-05-05 11:21           ` Simon Busch
2011-05-05 11:34             ` Phil Blundell
2011-05-05 11:44               ` Simon Busch
2011-05-04 16:55     ` [PATCH] cmake.bbclass: set the rpath for native binaries build with cmake Simon Busch
2011-05-04 20:46       ` Simon Busch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DC1BB25.1070808@gravedo.de \
    --to=morphis@gravedo.de \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.