* file-find.c (remove_prefix): New function.
* file-find.h (remove_prefix): Declare the function.
* gcc-ar.c (main): Skip a folder of the wrapper if
a wrapped binary would point to the same file.
From-SVN: r238089
+2016-07-07 Martin Liska <mliska@suse.cz>
+
+ * file-find.c (remove_prefix): New function.
+ * file-find.h (remove_prefix): Declare the function.
+ * gcc-ar.c (main): Skip a folder of the wrapper if
+ a wrapped binary would point to the same file.
+
2016-07-07 Jan Hubicka <jh@suse.cz>
* tree-scalar-evolution.c (iv_can_overflow_p): export.
}
free (nstore);
}
+
+void
+remove_prefix (const char *prefix, struct path_prefix *pprefix)
+{
+ struct prefix_list *remove, **prev, **remove_prev = NULL;
+ int max_len = 0;
+
+ if (pprefix->plist)
+ {
+ prev = &pprefix->plist;
+ for (struct prefix_list *pl = pprefix->plist; pl->next; pl = pl->next)
+ {
+ if (strcmp (prefix, pl->prefix) == 0)
+ {
+ remove = pl;
+ remove_prev = prev;
+ continue;
+ }
+
+ int l = strlen (pl->prefix);
+ if (l > max_len)
+ max_len = l;
+
+ prev = &pl;
+ }
+
+ if (remove_prev)
+ {
+ *remove_prev = remove->next;
+ free (remove);
+ }
+
+ pprefix->max_len = max_len;
+ }
+}
extern char *find_a_file (struct path_prefix *, const char *, int);
extern void add_prefix (struct path_prefix *, const char *);
extern void add_prefix_begin (struct path_prefix *, const char *);
+extern void remove_prefix (const char *prefix, struct path_prefix *);
extern void prefix_from_env (const char *, struct path_prefix *);
extern void prefix_from_string (const char *, struct path_prefix *);
#ifdef CROSS_DIRECTORY_STRUCTURE
real_exe_name = concat (target_machine, "-", PERSONALITY, NULL);
#endif
+ /* Do not search original location in the same folder. */
+ char *exe_folder = lrealpath (av[0]);
+ exe_folder[strlen (exe_folder) - strlen (lbasename (exe_folder))] = '\0';
+ char *location = concat (exe_folder, PERSONALITY, NULL);
+
+ if (access (location, X_OK) == 0)
+ remove_prefix (exe_folder, &path);
+
exe_name = find_a_file (&path, real_exe_name, X_OK);
if (!exe_name)
{