This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc -print-search-dirs prints wrong paths for 64-bit


Hi,
Perhaps there is a bug in the latest gcc-3.4.3 release: If you build the 64bit cross-compiler and run it with "-print-search-dirs", it prints out the 32-bit library paths (ie ..../usr/lib/), instead of (.../usr/lib64/). I guess it should print out the 64-bit paths unless you run with -m32.
The enclosed patch fixes this bug for gcc-3.4.3, and only for x86 target.

Thanks, Dinar.


--- gcc-3.4.3-orig/gcc/gcc.c	2005-02-16 18:48:49.000000000 +0300
+++ gcc-3.4.3/gcc/gcc.c	2005-02-16 18:52:21.873201491 +0300
@@ -1410,6 +1410,9 @@
 static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
 static const char *const standard_startfile_prefix_1 = "/lib/";
 static const char *const standard_startfile_prefix_2 = "/usr/lib/";
+static int use_lib64_path = 1;
+static const char *const standard_startfile_prefix_3 = "/lib64/";
+static const char *const standard_startfile_prefix_4 = "/usr/lib64/";
 
 static const char *const tooldir_base_prefix = TOOLDIR_BASE_PREFIX;
 static const char *tooldir_prefix;
@@ -3364,6 +3367,18 @@
 		 stdout);
 	  exit (0);
 	}
+      else if (strcmp (argv[i], "-m32") == 0)
+	{
+		use_lib64_path=0;
+	}
+      else if (strcmp (argv[i], "-machine32") == 0)
+        {
+		use_lib64_path=0;
+        }
+      else if (strcmp (argv[i], "--machine-32") == 0)
+        {
+		use_lib64_path=0;
+        }
       else if (strcmp (argv[i], "-fhelp") == 0)
 	{
 	  /* translate_options () has turned --help into -fhelp.  */
@@ -6149,10 +6164,25 @@
 		      NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
 	}
 
-      add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_1,
-			    "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
-      add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_2,
-			    "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+      if (strstr(spec_machine, "x86_64") != NULL) {
+      	if (!use_lib64_path) {
+		add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_1,
+				    "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+        	add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_2,
+				    "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+      	}
+	else {
+		add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_3,
+          	                    "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+        	add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_4,
+                	            "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+        } 
+      } else {
+	add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_1,
+                            "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+        add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_2,
+                            "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+      }
 #if 0 /* Can cause surprises, and one can use -B./ instead.  */
       add_prefix (&startfile_prefixes, "./", NULL,
 		  PREFIX_PRIORITY_LAST, 1, NULL, 0);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]