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

[MiNT] [PATCH] gcc, disable no-multilib directory if multilib switch given



Hello,

Here is an example patch I created to temporarily fix a problematic
issue: linking fpu libraries with non fpu libraries (the ABI is
different between them and thus must be considered incompatible).

gcc always adds the default library path ($prefix/lib) whenever a
multilib switch is given (mshort, m68020, m68020-60, mcpu=5475), and
thus can produce non working binaries if libraries with incompatible
ABI are used at the link stage.

For example:
$ m68k-atari-mint-gcc -print-search-dirs -m68020-60
prints the m68020-60 lib/m68020-60 dirs, and then the default lib/
directories.

With my patch, only directories in the form lib/m68020-60 are now
listed and will be used.

Of course this is the kind of patch that would never be accepted
upstream. However there were some recent discussions about multilib on
gcc ml: http://gcc.gnu.org/ml/gcc/2010-01/msg00063.html

There is a similar, but different issue when using the -L switch, used
by the various $RANDOM_PACKAGE-config scripts or pkg-config scripts. I
would like -m68020-60 -L/usr/local/lib to automatically
generate /usr/local/lib/m68020-60 for example.

-- 
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Spécialité: Développement, jeux

"who writes the code, decides"
--- gcc-4.4.2/gcc/gcc.c	2009-03-17 22:25:59.000000000 +0100
+++ gcc-4.4.2-mint/gcc/gcc.c	2010-05-15 23:03:33.000000000 +0200
@@ -2443,6 +2443,7 @@
 {
   struct prefix_list *pl;
   const char *multi_dir = NULL;
+  bool multi_dir_start = false;
   const char *multi_os_dir = NULL;
   const char *multi_suffix;
   const char *just_multi_suffix;
@@ -2462,6 +2463,8 @@
   if (do_multi && multilib_os_dir && strcmp (multilib_os_dir, ".") != 0)
     multi_os_dir = concat (multilib_os_dir, dir_separator_str, NULL);
 
+  multi_dir_start = (multi_dir != NULL);
+
   while (1)
     {
       size_t multi_dir_len = 0;
@@ -2543,7 +2546,7 @@
       if (pl)
 	break;
 
-      if (multi_dir == NULL && multi_os_dir == NULL)
+      if (multi_dir_start || (multi_dir == NULL && multi_os_dir == NULL))
 	break;
 
       /* Run through the paths again, this time without multilibs.