Hi folks,

Trying to get ready for the next stage of multiarch deployment, I ran into a
couple of problems with the packaging of multiarch support in gcc-4.4. 
Namely:

 - various bits of debian/rules* were still looking for libraries in
   /usr/lib instead of in the multiarch directories
 - the gcc-multiarch patch is overly aggressive, causing biarch paths to be
   looked up relative to /usr/lib/$(foreign_triplet) which is not guaranteed
   to exist (biarch packages need to remain independent of multiarch for as
   long as we keep them around)

The attached patch addresses both of these issues, while carefully avoiding
any changes that should cause regressions when building without multiarch
enabled.  I've successfully built gcc-4.4 both with and without multiarch
paths, on both i386 and amd64 after applying this patch.  (One further patch
is required when building for multiarch, but it's an either-or kind of thing
so I've withheld applying it until we're ready to flip the switch.)  I
haven't tried building any of the other source packages besides gcc-4.4, but
I don't see any reason this change would have regressed those.  (Indeed, I
can tell by looking that gcj isn't yet multiarch-safe.)

This change is also available as a browseable (and mergeable, with bzr-svn)
branch at:

  https://code.launchpad.net/~vorlon/gcc/multiarch-packaging/

Can this be applied to the existing package?  Happy to file a bug report for
it if this is preferred.

Please cc: me on replies as I'm not subscribed to debian-gcc.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
=== modified file 'debian/changelog'
--- debian/changelog	2010-07-23 09:37:30 +0000
+++ debian/changelog	2010-07-28 00:57:34 +0000
@@ -14,6 +14,15 @@
     LP: #609060.
   * Set Vcs attributes in control file.
 
+  [ Steve Langasek ]
+  * s,/lib/,/$(libdir)/, throughout debian/rules*; a no-op in the current
+    case, but required for us to find the libraries when building for
+    multiarch
+  * don't append multiarch paths to any multilib paths except for the default;
+    our biarch (multilib) builds need to remain independent of multiarch in
+    the near term, so we want to make sure we can find /usr/lib32 without
+    /usr/lib/i486-linux-gnu being available.
+
  -- Matthias Klose <d...@debian.org>  Fri, 23 Jul 2010 10:12:45 +0200
 
 gcc-4.4 (4.4.4-7) unstable; urgency=low

=== modified file 'debian/patches/gcc-multiarch-i686.diff'
--- debian/patches/gcc-multiarch-i686.diff	2010-05-18 08:02:10 +0000
+++ debian/patches/gcc-multiarch-i686.diff	2010-07-28 01:14:26 +0000
@@ -43,7 +43,7 @@
  TOPLEV_H = toplev.h input.h
  TARGET_H = $(TM_H) target.h insn-modes.h
  MACHMODE_H = machmode.h mode-classes.def insn-modes.h
-@@ -1835,7 +1836,7 @@
+@@ -1818,7 +1819,7 @@
  
  incpath.o: incpath.c incpath.h $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) \
  		intl.h prefix.h coretypes.h $(TM_H) cppdefault.h $(TARGET_H) \
@@ -52,7 +52,7 @@
  
  c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
      $(RTL_H) $(C_TREE_H) $(GGC_H) $(TARGET_H) $(FLAGS_H) $(FUNCTION_H) output.h \
-@@ -1976,7 +1977,7 @@
+@@ -1959,7 +1960,7 @@
  
  gcc.o: gcc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h multilib.h \
      Makefile $(lang_specs_files) specs.h prefix.h $(GCC_H) $(FLAGS_H) \
@@ -166,7 +166,7 @@
    /* Warn about any switches that no pass was interested in.  */
  
    for (i = 0; (int) i < n_switches; i++)
-@@ -7576,6 +7585,39 @@ set_multilib_dir (void)
+@@ -7576,6 +7585,27 @@ set_multilib_dir (void)
      multilib_os_dir = multilib_dir;
  }
  
@@ -182,24 +182,12 @@
 +static void
 +set_multiarch_dir (void)
 +{
-+  const char *multiarch, *path;
++  const char *path;
 +
-+  multiarch = multilib_to_multiarch (multilib_dir);
-+  if (multiarch == NULL)
-+    {
-+      fatal_ice ("\
-+Internal error: no multiarch mapping for multilib (%s)\n\
-+Please submit a full bug report.\n\
-+See %s for instructions.",
-+        multilib_dir ? multilib_dir : multilib_defaults, bug_report_url);
-+    }
-+  else if (multiarch)
-+    {
-+      path = concat (STANDARD_STARTFILE_PREFIX_2, multiarch,
-+        dir_separator_str, NULL);
-+      add_prefix (&startfile_prefixes, path, NULL,
-+        PREFIX_PRIORITY_LAST, 0, 1);
-+    }
++  path = concat (STANDARD_STARTFILE_PREFIX_2, MULTIARCH_DEFAULTS,
++    dir_separator_str, NULL);
++  add_prefix (&startfile_prefixes, path, NULL,
++    PREFIX_PRIORITY_LAST, 0, 1);
 +}
 +#endif
 +

=== modified file 'debian/patches/gcc-multiarch.diff'
--- debian/patches/gcc-multiarch.diff	2010-05-18 08:02:10 +0000
+++ debian/patches/gcc-multiarch.diff	2010-07-28 01:14:53 +0000
@@ -43,7 +43,7 @@
  TOPLEV_H = toplev.h input.h
  TARGET_H = $(TM_H) target.h insn-modes.h
  MACHMODE_H = machmode.h mode-classes.def insn-modes.h
-@@ -1835,7 +1836,7 @@
+@@ -1818,7 +1819,7 @@
  
  incpath.o: incpath.c incpath.h $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) \
  		intl.h prefix.h coretypes.h $(TM_H) cppdefault.h $(TARGET_H) \
@@ -52,7 +52,7 @@
  
  c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
      $(RTL_H) $(C_TREE_H) $(GGC_H) $(TARGET_H) $(FLAGS_H) $(FUNCTION_H) output.h \
-@@ -1976,7 +1977,7 @@
+@@ -1959,7 +1960,7 @@
  
  gcc.o: gcc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) intl.h multilib.h \
      Makefile $(lang_specs_files) specs.h prefix.h $(GCC_H) $(FLAGS_H) \
@@ -166,7 +166,7 @@
    /* Warn about any switches that no pass was interested in.  */
  
    for (i = 0; (int) i < n_switches; i++)
-@@ -7576,6 +7585,39 @@ set_multilib_dir (void)
+@@ -7576,6 +7585,27 @@ set_multilib_dir (void)
      multilib_os_dir = multilib_dir;
  }
  
@@ -182,24 +182,12 @@
 +static void
 +set_multiarch_dir (void)
 +{
-+  const char *multiarch, *path;
++  const char *path;
 +
-+  multiarch = multilib_to_multiarch (multilib_dir);
-+  if (multiarch == NULL)
-+    {
-+      fatal_ice ("\
-+Internal error: no multiarch mapping for multilib (%s)\n\
-+Please submit a full bug report.\n\
-+See %s for instructions.",
-+        multilib_dir ? multilib_dir : multilib_defaults, bug_report_url);
-+    }
-+  else if (multiarch)
-+    {
-+      path = concat (STANDARD_STARTFILE_PREFIX_2, multiarch,
-+        dir_separator_str, NULL);
-+      add_prefix (&startfile_prefixes, path, NULL,
-+        PREFIX_PRIORITY_LAST, 0, 1);
-+    }
++  path = concat (STANDARD_STARTFILE_PREFIX_2, MULTIARCH_DEFAULTS,
++    dir_separator_str, NULL);
++  add_prefix (&startfile_prefixes, path, NULL,
++    PREFIX_PRIORITY_LAST, 0, 1);
 +}
 +#endif
 +

=== modified file 'debian/rules.d/binary-fortran.mk'
--- debian/rules.d/binary-fortran.mk	2010-06-28 16:32:06 +0000
+++ debian/rules.d/binary-fortran.mk	2010-07-27 18:55:10 +0000
@@ -196,8 +196,8 @@
 
 	DH_COMPAT=2 dh_movefiles -p$(p_g95) $(files_g95)
 
-	rm -f $(d)/$(PFL)/lib/libgfortran*.so
-	mv $(d)/$(PFL)/lib/libgfortran*.a $(d_g95)/$(gcc_lib_dir)/
+	rm -f $(d)/$(PFL)/$(libdir)/libgfortran*.so
+	mv $(d)/$(PFL)/$(libdir)/libgfortran*.a $(d_g95)/$(gcc_lib_dir)/
 	dh_link -p$(p_g95) \
 	  /$(PFL)/$(libdir)/libgfortran.so.$(FORTRAN_SONAME) \
 	  /$(gcc_lib_dir)/libgfortran.so

=== modified file 'debian/rules.d/binary-gcc.mk'
--- debian/rules.d/binary-gcc.mk	2010-06-24 09:55:15 +0000
+++ debian/rules.d/binary-gcc.mk	2010-07-27 18:55:10 +0000
@@ -129,21 +129,21 @@
 endif
 
 ifeq ($(with_ssp),yes)
-	mv $(d)/$(PFL)/lib/libssp_nonshared.a $(d)/$(gcc_lib_dir)/
+	mv $(d)/$(PFL)/$(libdir)/libssp_nonshared.a $(d)/$(gcc_lib_dir)/
 endif
 ifeq ($(with_libssp),yes)
-	mv $(d)/$(PFL)/lib/libssp*.a $(d_gcc)/$(gcc_lib_dir)/
-	rm -f $(d)/$(PFL)/lib/libssp*.{la,so}
+	mv $(d)/$(PFL)/$(libdir)/libssp*.a $(d_gcc)/$(gcc_lib_dir)/
+	rm -f $(d)/$(PFL)/$(libdir)/libssp*.{la,so}
 	dh_link -p$(p_gcc) \
-	  /$(PF)/lib/libssp.so.$(SSP_SONAME) /$(gcc_lib_dir)/libssp.so
+	  /$(PF)/$(libdir)/libssp.so.$(SSP_SONAME) /$(gcc_lib_dir)/libssp.so
 	cp -p $(srcdir)/libssp/ChangeLog \
 		$(d_gcc)/$(docdir)/$(p_base)/libssp/changelog
 endif
 ifeq ($(with_gomp),yes)
-	mv $(d)/$(PFL)/lib/libgomp*.{a,spec} $(d_gcc)/$(gcc_lib_dir)/
-	rm -f $(d)/$(PF)/lib/libgomp*.{la,so}
+	mv $(d)/$(PFL)/$(libdir)/libgomp*.{a,spec} $(d_gcc)/$(gcc_lib_dir)/
+	rm -f $(d)/$(PF)/$(libdir)/libgomp*.{la,so}
 	dh_link -p$(p_gcc) \
-	  /$(PFL)/lib/libgomp.so.$(GOMP_SONAME) /$(gcc_lib_dir)/libgomp.so
+	  /$(PFL)/$(libdir)/libgomp.so.$(GOMP_SONAME) /$(gcc_lib_dir)/libgomp.so
 	cp -p $(srcdir)/libgomp/ChangeLog \
 		$(d_gcc)/$(docdir)/$(p_base)/gomp/changelog
 endif

=== modified file 'debian/rules.d/binary-libgcc.mk'
--- debian/rules.d/binary-libgcc.mk	2010-06-24 09:55:15 +0000
+++ debian/rules.d/binary-libgcc.mk	2010-07-27 18:55:10 +0000
@@ -44,7 +44,7 @@
 		$(RPF)/$(libdir)
 
 ifeq ($(with_shared_libgcc),yes)
-	mv $(d)/$(PFL)/lib/libgcc_s.so.$(GCC_SONAME) $(d_lgcc)/$(RPF)/$(libdir)/.
+	mv $(d)/$(PFL)/$(libdir)/libgcc_s.so.$(GCC_SONAME) $(d_lgcc)/$(RPF)/$(libdir)/.
 endif
 
 ifeq ($(with_standalone_gcj),yes)

=== modified file 'debian/rules2'
--- debian/rules2	2010-07-20 08:31:40 +0000
+++ debian/rules2	2010-07-27 18:55:10 +0000
@@ -63,15 +63,15 @@
   SET_LOCPATH = LOCPATH=$(PWD)/locales
 endif
 
-SET_PATH = PATH=$(PWD)/bin:/usr/lib/gcc/bin:$$PATH
+SET_PATH = PATH=$(PWD)/bin:/usr/$(libdir)/gcc/bin:$$PATH
 ifeq ($(PKGSOURCE),gnat-4.4)
   ifneq (,$(findstring arm-linux-gnueabi,$(DEB_TARGET_GNU_TYPE)))
-    SET_PATH = PATH=/usr/lib/gcc-snapshot/bin:$(PWD)/bin:/usr/lib/gcc/bin:$$PATH
+    SET_PATH = PATH=/usr/lib/gcc-snapshot/bin:$(PWD)/bin:/usr/$(libdir)/gcc/bin:$$PATH
   endif
 endif
 ifeq ($(PKGSOURCE),gcc-snapshot)
   ifneq (,$(findstring arm-linux-gnueabi,$(DEB_TARGET_GNU_TYPE)))
-    SET_PATH = PATH=/usr/lib/gcc-snapshot/bin:$(PWD)/bin:/usr/lib/gcc/bin:$$PATH
+    SET_PATH = PATH=/usr/lib/gcc-snapshot/bin:$(PWD)/bin:/usr/$(libdir)/gcc/bin:$$PATH
   endif
 endif
 
@@ -148,7 +148,8 @@
         --libexecdir=/$(libexecdir) \
         --without-included-gettext \
         --enable-threads=posix \
-	--with-gxx-include-dir=/$(cxx_inc_dir)
+	--with-gxx-include-dir=/$(cxx_inc_dir) \
+	--libdir=/$(PF)/$(libdir)
 endif
 
 ifeq ($(versioned_packages),yes)
@@ -1735,7 +1736,7 @@
 
 	: # Install directories
 	rm -rf $(d)
-	mkdir -p $(d)/$(libdir) $(d)/$(PF) $(d)/$(PF)/lib/debug
+	mkdir -p $(d)/$(libdir) $(d)/$(PF) $(d)/$(PF)/$(libdir)/debug
 ifeq ($(biarch32),yes)
 	mkdir -p $(d)/$(PF)/lib32/debug
 endif
@@ -1944,12 +1945,12 @@
 	: # remove files not needed
 	rm -rf $(d_hppa64)/$(PF)/info
 	rm -rf $(d_hppa64)/$(PF)/man
-	rm -f $(d_hppa64)/$(PF)/lib/libiberty.a
+	rm -f $(d_hppa64)/$(PF)/$(libdir)/libiberty.a
 	rm -f $(d_hppa64)/$(PF)/bin/*{protoize,gcov,gccbug,gcc}
 
 	rm -rf $(d_hppa64)/$(PF)/hppa64-linux-gnu/include
 	rm -rf $(d_hppa64)/$(PF)/hppa64-linux-gnu/lib
-	rm -rf $(d_hppa64)//$(PF)/lib/gcc/hppa64-linux-gnu/$(GCC_VERSION)/install-tools
+	rm -rf $(d_hppa64)/$(PF)/$(libdir)/gcc/hppa64-linux-gnu/$(GCC_VERSION)/install-tools
 endif
 
 	touch $(install_hppa64_stamp)

Attachment: signature.asc
Description: Digital signature

Reply via email to