mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH 4/9 v2] [x86_64, multilib] Make packages install their libraries at the right place
Date: Sat, 24 Mar 2012 12:04:13 +0100	[thread overview]
Message-ID: <20120324110413.GG24724@pengutronix.de> (raw)
In-Reply-To: <1332191692-20833-4-git-send-email-linux@bohmer.net>

On Mon, Mar 19, 2012 at 10:14:47PM +0100, Remy Bohmer wrote:
> While cross-compiling for x86_64 in a multilib configuration we need to
> install the libraries conform the Filesystem Hierarchy Standard (FHS).
> Summarised this will be for multilib:
> * All libraries compiled for and used in 64-bit applications need to be
>   installed in /lib64 or /usr/lib64.
> * All libraries compiled for and used in 32-bit applications need to be
>   installed in /lib or /usr/lib.
> * All executables will still find its way in the regular /bin and /sbin
>   paths.
> * The Operating System itself and all its libraries should only be compiled
>   in 64 bit mode. It should not be a mix between 32 and 64 bit libraries.
>   32 bit support will only contain the libraries that are required by
>   32-bit-applications to link against.
> 
> This is also conform what many distros derived from Redhat have in their
> setup. Note that Debian based distros follow a somewhat different setup.
> 
> Note that we use the compiler toolchain to tell us at which paths we
> need to install the libraries. This means that if you build for a x86_64
> target _without_ multilib support the libraries will likely end up in the
> classical /lib and /usr/lib directories, but that is completely steered
> by the compiler toolchain configuration. (it follows the location where
> the corresponding dynamic linker is expected to be installed)
> 
> So, this change makes ptxdist follow the sysroot of the compiler toolchain
> more such that preliminary multilib support can be achieved. Preliminary
> in the sense that only still one C-library is being installed.
> In another changeset the support for a 2nd C-library installation will be
> added. At least after this change (and a few subsequent ptxdist makefile
> fixes) the /lib and /usr/lib area will only contain the contents that belong
> there in multilib environment.
> 
> Signed-off-by: Remy Bohmer <linux@bohmer.net>
> ---
>  v2: Fixed uClibc dynamic linker name resolving
>      Reworked review remarks from Michael Olbrich:
>      - Do not add fix paths to lib64, but get them from ptxd_get_lib_dir
>      - Call ptxd_get_lib_dir from the shell script in the make files
> 
>  rules/pre/Rules.make              |    4 +++-
>  scripts/lib/ptxd_make_00-init.sh  |   31 +++++++++++++++++++++++++++----
>  scripts/lib/ptxd_make_xpkg_pkg.sh |    7 +++++--
>  3 files changed, 35 insertions(+), 7 deletions(-)
> 
> diff --git a/rules/pre/Rules.make b/rules/pre/Rules.make
> index 1d6da52..018c815 100644
> --- a/rules/pre/Rules.make
> +++ b/rules/pre/Rules.make
> @@ -174,6 +174,8 @@ CROSS_ENV_PROGS := \
>  	$(CROSS_ENV_CPP_FOR_BUILD) \
>  	$(CROSS_ENV_LINK_FOR_BUILD)
>  
> +CROSS_LIB_DIR   := $(shell ptxd_get_lib_dir)
> +
>  #
>  # prepare to use pkg-config with wrapper which takes care of
>  # $(PTXDIST_SYSROOT_TARGET). The wrapper's magic doesn't work when
> @@ -266,7 +268,7 @@ CROSS_ENV := \
>  #
>  
>  CROSS_AUTOCONF_SYSROOT_USR := \
> -	--prefix=/usr --sysconfdir=/etc --localstatedir=/var
> +	--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/$(CROSS_LIB_DIR)
>  
>  CROSS_AUTOCONF_SYSROOT_ROOT := \
>  	--prefix=
> diff --git a/scripts/lib/ptxd_make_00-init.sh b/scripts/lib/ptxd_make_00-init.sh
> index da72d29..a13369c 100644
> --- a/scripts/lib/ptxd_make_00-init.sh
> +++ b/scripts/lib/ptxd_make_00-init.sh
> @@ -63,7 +63,10 @@ ptxd_init_arch() {
>  # out:	PTXDIST_SYSROOT_TOOLCHAIN
>  #
>  ptxd_init_sysroot_toolchain() {
> -    local compiler_prefix="$(ptxd_get_ptxconf PTXCONF_COMPILER_PREFIX)"
> +    local compiler_prefix extra_cppflags extra_cflags
> +    compiler_prefix="$(ptxd_get_ptxconf PTXCONF_COMPILER_PREFIX)"
> +    extra_cppflags="$(ptxd_get_ptxconf PTXCONF_TARGET_EXTRA_CPPFLAGS)"
> +    extra_cflags="$(ptxd_get_ptxconf PTXCONF_TARGET_EXTRA_CFLAGS)"
>  
>      #
>      # no compiler prefix specified means using plain "gcc"
> @@ -75,7 +78,7 @@ ptxd_init_sysroot_toolchain() {
>  	local sysroot
>  
>  	sysroot="$(echo 'int main(void){return 0;}' | \
> -	${compiler_prefix}gcc -x c -o /dev/null -v - 2>&1 | \
> +	${compiler_prefix}gcc ${extra_cppflags} ${extra_cflags} -x c -o /dev/null -v - 2>&1 | \

I've pushed a change, that cleans up calling gcc here and in
install_copy_toolchain.sh. Please rebase.

Michael

>  	sed -ne "/.*collect2.*/s,.*--sysroot=\([^[:space:]]*\).*,\1,p" && \
>  	check_pipe_status)"
>  
> @@ -119,6 +122,23 @@ ptxd_init_collectionconfig() {
>  
>  
>  #
> +# out: 'lib' or 'lib64', derived from the ld-{linux,uClibc}.so.? from the compiler toolchain
> +#
> +ptxd_get_lib_dir() {
> +    local dl lib_dir extra_cppflags extra_cflags
> +    compiler_prefix="$(ptxd_get_ptxconf PTXCONF_COMPILER_PREFIX)"
> +    extra_cppflags="$(ptxd_get_ptxconf PTXCONF_TARGET_EXTRA_CPPFLAGS)"
> +    extra_cflags="$(ptxd_get_ptxconf PTXCONF_TARGET_EXTRA_CFLAGS)"
> +
> +    dl="$(echo 'int main(void){return 0;}' | \
> +	${compiler_prefix}gcc ${extra_cppflags} ${extra_cflags} -x c -o /dev/null -v - 2>&1 | \
> +	sed -n -e 's/.* -dynamic-linker \([^ ]*\).*/\1/p')"
> +    lib_dir="${dl%%/ld-*.so.*}"
> +    echo "${lib_dir#/}"

this is /lib or /lib64 etc. right? The way you use it later, you should
remove the leading '/'. Otherwise you'll get /usr//lib, and while that is
valid as path, some scripts may not match it correctly.

Michael

> +}
> +export -f ptxd_get_lib_dir
> +
> +#
>  # setup compiler and pkgconfig environment
>  #
>  # in:
> @@ -140,6 +160,9 @@ ptxd_init_cross_env() {
>      prefix=( ${PTXDIST_PATH_SYSROOT_PREFIX} )
>      IFS="${orig_IFS}"
>  
> +    local -a lib_dir
> +    lib_dir=$(ptxd_get_lib_dir)
> +
>      # add "-isystem <DIR>/include"
>      local -a cppflags
>      cppflags=( "${prefix[@]/%//include}" )
> @@ -147,7 +170,7 @@ ptxd_init_cross_env() {
>  
>      # add "-L<DIR>/lib -Wl,-rpath-link -Wl,<DIR>"
>      local -a ldflags
> -    ldflags=( "${prefix[@]/%//lib}" )
> +    ldflags=( "${prefix[@]/%//${lib_dir}}" )
>      ldflags=( "${ldflags[@]/#/-L}" "${ldflags[@]/#/-Wl,-rpath-link -Wl,}" )
>  
>      export \
> @@ -166,7 +189,7 @@ ptxd_init_cross_env() {
>  
>      # add <DIR>/lib/pkgconfig and <DIR>/share/pkgconfig
>      local -a pkg_libdir
> -    pkg_libdir=( "${prefix[@]/%//lib/pkgconfig}" "${prefix[@]/%//share/pkgconfig}" )
> +    pkg_libdir=( "${prefix[@]/%//${lib_dir}/pkgconfig}" "${prefix[@]/%//share/pkgconfig}" )
>  
>      #
>      # PKG_CONFIG_PATH contains additional pkg-config search
> diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh
> index c03f19e..73ff2c2 100644
> --- a/scripts/lib/ptxd_make_xpkg_pkg.sh
> +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
> @@ -597,6 +597,8 @@ ptxd_install_spec() {
>  export -f ptxd_install_spec
>  
>  ptxd_install_package() {
> +    local lib_dir=$(ptxd_get_lib_dir)
> +
>      for dir in "${pkg_pkg_dir}/"{,usr/}{bin,sbin,libexec}; do
>  	find "${dir}" \( -type f -o -type l \) \
>  		    -perm /111 2>/dev/null | while read file; do
> @@ -605,7 +607,7 @@ ptxd_install_package() {
>  	done
>      done
>  
> -    for dir in "${pkg_pkg_dir}/"{,usr/}lib; do
> +    for dir in "${pkg_pkg_dir}/"{,usr/}${lib_dir}; do
>  	find "${dir}" \( -type f -o -type l \) \
>  		    -a -name "*.so*" 2>/dev/null | while read file; do
>  	    ptxd_install_generic - "${file#${pkg_pkg_dir}}" ||
> @@ -635,10 +637,11 @@ ptxd_install_shared() {
>  export -f ptxd_install_shared
>  
>  ptxd_install_lib() {
> +    local lib_dir=$(ptxd_get_lib_dir)
>      local lib="$1"
>      shift
>  
> -    local file="$(for dir in "${pkg_pkg_dir}/"{,usr/}lib; do
> +    local file="$(for dir in "${pkg_pkg_dir}/"{,usr/}${lib_dir}; do
>  	    find "${dir}" -type f -path "${dir}/${lib}.so*"; done 2>/dev/null)"
>  
>      if [ ! -f "${file}" ]; then
> -- 
> 1.7.5.4
> 
> 
> -- 
> ptxdist mailing list
> ptxdist@pengutronix.de
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

  reply	other threads:[~2012-03-24 11:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 21:14 [ptxdist] [PATCH 1/9 v2] [x86_64] Add x86_64 architecture strings Remy Bohmer
2012-03-19 21:14 ` [ptxdist] [PATCH 2/9 v2] [x86_64] libgcc need to be install in /lib64 instead of /lib Remy Bohmer
2012-03-19 21:14 ` [ptxdist] [PATCH 3/9 v2] [x86_64, multilib] Remove all hardcoded paths from glibc.make Remy Bohmer
2012-03-23  7:42   ` Michael Olbrich
2012-03-24 18:24     ` Remy Bohmer
2012-03-25 11:29       ` Michael Olbrich
2012-03-19 21:14 ` [ptxdist] [PATCH 4/9 v2] [x86_64, multilib] Make packages install their libraries at the right place Remy Bohmer
2012-03-24 11:04   ` Michael Olbrich [this message]
2012-03-24 11:06     ` Michael Olbrich
2012-03-19 21:14 ` [ptxdist] [PATCH 5/9 v2] [x86_64, multilib] Install Zlib " Remy Bohmer
2012-03-19 21:14 ` [ptxdist] [PATCH 6/9 v2] [x86_64, multilib] Install Ncurses " Remy Bohmer
2012-03-19 21:14 ` [ptxdist] [PATCH 7/9 v2] [x86_64, multilib] Install Util-linux-ng " Remy Bohmer
2012-03-19 21:14 ` [ptxdist] [PATCH 8/9 v2] [x86_64, multilib] Install Readline " Remy Bohmer
2012-03-19 21:14 ` [ptxdist] [PATCH 9/9 v2] [x86_64, multilib] Install Procps " Remy Bohmer
2012-03-23  7:53 ` [ptxdist] [PATCH 1/9 v2] [x86_64] Add x86_64 architecture strings Michael Olbrich
2012-03-24 18:29   ` Remy Bohmer
2012-03-26  8:50     ` Michael Olbrich

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=20120324110413.GG24724@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox