[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Dpkg/Shlibs.pm: multiarch search paths



Hi,

On Mon, 21 Mar 2011, Steve Langasek wrote:
> Another patch for multiarch support.  The need for this was discovered when
> trying to bootstrap a cross-toolchain against a multiarchified
> eglibc-source.

Ok, the support for cross-compilation in dpkg-shlibdeps was contributed
by Emdebian so I'll ask them for their opinion.

Not knowing much about cross-compilation I had started with a sligthly
different approach than you, mimicking exactly what was done for
cross-compilation support.

Neil (or anyone else knowledgable on the topic), can you review the
patches and tell us what's really needed and most logical according to
you?

Steve's patch:
- adds the multi-arch path at the start of the search paths
- adds them only for stantard cross-compilation (host != build) but not
  for the special cases used to detect a cross-compiler build

My patch:
- adds the multi-arch path before the cross-arch patch but after the
  standard search path
- add them in all cases where the cross-compilation paths are used

Putting the multi-arch paths after the default path should not matter as
dpkg-shlibdeps skips libraries of non-matching architecture.

For the case of building a cross-compiler, Steve's experience tends to
prove that adding the multi-arch path is not needed... but I don't see why
it should be treated differently than the cross-arch paths.

Can you enlighten us?

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Follow my Debian News ▶ http://RaphaelHertzog.com (English)
                      ▶ http://RaphaelHertzog.fr (Français)
commit 980b01597405110a1769d069b5708651de1f241a
Author: Raphaël Hertzog <hertzog@debian.org>
Date:   Mon Mar 21 09:36:29 2011 +0100

    dpkg-shlibdeps: look into multi-arch paths
    
    dpkg-shlibdeps should look into multi-arch paths when cross-compiling or
    building a cross-compiler.
    
    Reported-by: Steve Langasek <steve.langasek@linaro.org>

diff --git a/debian/changelog b/debian/changelog
index 2d0883c..476b20c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -92,6 +92,8 @@ dpkg (1.16.0) UNRELEASED; urgency=low
     spotting it.
   * Use the correct mtime when installing a file with statoverrides.
     LP: #739179
+  * Improve dpkg-shlibdeps to look into multi-arch paths when
+    cross-compiling or building a cross-compiler.
 
   [ Jonathan Nieder ]
   * Remove support for use of synchronous sync(2), due to its pernicious
diff --git a/scripts/Dpkg/Shlibs.pm b/scripts/Dpkg/Shlibs.pm
index 95ef4fe..17354bb 100644
--- a/scripts/Dpkg/Shlibs.pm
+++ b/scripts/Dpkg/Shlibs.pm
@@ -29,7 +29,8 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::Shlibs::Objdump;
 use Dpkg::Path qw(resolve_symlink canonpath);
-use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch);
+use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch
+                  gnutriplet_to_multiarch debarch_to_multiarch);
 
 use constant DEFAULT_LIBRARY_PATH =>
     qw(/lib /usr/lib /lib32 /usr/lib32 /lib64 /usr/lib64
@@ -38,23 +39,27 @@ use constant DEFAULT_LIBRARY_PATH =>
 # Adjust set of directories to consider when we're in a situation of a
 # cross-build or a build of a cross-compiler
 my @crosslibrarypaths;
-my $crossprefix;
+my ($crossprefix, $multiarch);
 # Detect cross compiler builds
 if ($ENV{GCC_TARGET}) {
     $crossprefix = debarch_to_gnutriplet($ENV{GCC_TARGET});
+    $multiarch = debarch_to_multiarch($ENG{GCC_TARGET});
 }
 if ($ENV{DEB_TARGET_GNU_TYPE} and
     ($ENV{DEB_TARGET_GNU_TYPE} ne $ENV{DEB_BUILD_GNU_TYPE}))
 {
     $crossprefix = $ENV{DEB_TARGET_GNU_TYPE};
+    $multiarch = gnutriplet_to_multiarch($ENV{DEB_TARGET_GNU_TYPE});
 }
 # host for normal cross builds.
 if (get_build_arch() ne get_host_arch()) {
     $crossprefix = debarch_to_gnutriplet(get_host_arch());
+    $multiarch = debarch_to_multiarch(get_host_arch());
 }
 # Define list of directories containing crossbuilt libraries
 if ($crossprefix) {
-    push @crosslibrarypaths, "/$crossprefix/lib", "/usr/$crossprefix/lib",
+    push @crosslibrarypaths, "/lib/$multiarch", "/usr/lib/$multiarch",
+            "/$crossprefix/lib", "/usr/$crossprefix/lib",
             "/$crossprefix/lib32", "/usr/$crossprefix/lib32",
             "/$crossprefix/lib64", "/usr/$crossprefix/lib64";
 }
Hi guys,

Another patch for multiarch support.  The need for this was discovered when
trying to bootstrap a cross-toolchain against a multiarchified
eglibc-source.



We should explicitly prepend the appropriate multiarch paths to our library
search path.  These would be picked up later on anyway in the case of a
native build, but for, e.g., bootstrapping a cross-toolchain the needed
multiarch paths aren't going to be found in ld.so.conf.

---
 debian/changelog       |    5 +++++
 scripts/Dpkg/Shlibs.pm |   13 +++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2d0883c..67fbae1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -104,6 +104,11 @@ dpkg (1.16.0) UNRELEASED; urgency=low
     DEB_BUILD_MULTIARCH, that return the "ideal" GNU triplet for each
     architecture which should be used as the path component for library
     installation.
+  * Dpkg/Shlibs.pm: we should explicitly prepend the appropriate multiarch
+    paths to our library search path.  These would be picked up later on
+    anyway in the case of a native build, but for, e.g., bootstrapping a
+    cross-toolchain the needed multiarch paths aren't going to be found in
+    ld.so.conf.
 
   [ Updated programs translations ]
   * German (Sven Joachim).
diff --git a/scripts/Dpkg/Shlibs.pm b/scripts/Dpkg/Shlibs.pm
index 95ef4fe..95950e1 100644
--- a/scripts/Dpkg/Shlibs.pm
+++ b/scripts/Dpkg/Shlibs.pm
@@ -29,7 +29,8 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::Shlibs::Objdump;
 use Dpkg::Path qw(resolve_symlink canonpath);
-use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch);
+use Dpkg::Arch qw(debarch_to_gnutriplet debarch_to_multiarch
+                  get_build_arch get_host_arch);
 
 use constant DEFAULT_LIBRARY_PATH =>
     qw(/lib /usr/lib /lib32 /usr/lib32 /lib64 /usr/lib64
@@ -39,6 +40,10 @@ use constant DEFAULT_LIBRARY_PATH =>
 # cross-build or a build of a cross-compiler
 my @crosslibrarypaths;
 my $crossprefix;
+# And when we're not building a cross-compiler, be sure to pick up the
+# multiarch paths
+my @multiarchpaths;
+my $multiarch;
 # Detect cross compiler builds
 if ($ENV{GCC_TARGET}) {
     $crossprefix = debarch_to_gnutriplet($ENV{GCC_TARGET});
@@ -51,6 +56,7 @@ if ($ENV{DEB_TARGET_GNU_TYPE} and
 # host for normal cross builds.
 if (get_build_arch() ne get_host_arch()) {
     $crossprefix = debarch_to_gnutriplet(get_host_arch());
+    $multiarch = debarch_to_multiarch(get_host_arch());
 }
 # Define list of directories containing crossbuilt libraries
 if ($crossprefix) {
@@ -58,8 +64,11 @@ if ($crossprefix) {
             "/$crossprefix/lib32", "/usr/$crossprefix/lib32",
             "/$crossprefix/lib64", "/usr/$crossprefix/lib64";
 }
+if ($multiarch) {
+    push @multiarchpaths, "/lib/$multiarch", "/usr/lib/$multiarch";
+}
 
-our @librarypaths = (DEFAULT_LIBRARY_PATH, @crosslibrarypaths);
+our @librarypaths = (@multiarchpaths, DEFAULT_LIBRARY_PATH, @crosslibrarypaths);
 
 # Update library paths with LD_LIBRARY_PATH
 if ($ENV{LD_LIBRARY_PATH}) {
-- 
1.7.1


-- 
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 1300693517-11497-1-git-send-email-steve.langasek@linaro.org">http://lists.debian.org/1300693517-11497-1-git-send-email-steve.langasek@linaro.org


Reply to: