/* Wrapper for ar/ranlib/nm to pass the LTO plugin.
- Copyright (C) 2011 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012 Free Software Foundation, Inc.
Contributed by Andi Kleen.
This file is part of GCC.
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#include <stdio.h>
#include "config.h"
#include "system.h"
#include "libiberty.h"
static const char standard_libexec_prefix[] = STANDARD_LIBEXEC_PREFIX;
static const char standard_bin_prefix[] = STANDARD_BINDIR_PREFIX;
+static const char *const target_machine = TARGET_MACHINE;
static const char dir_separator[] = { DIR_SEPARATOR, 0 };
const char *err_msg;
const char **nargv;
bool is_ar = !strcmp (PERSONALITY, "ar");
+ int exit_code = FATAL_EXIT_CODE;
exe_name = PERSONALITY;
#ifdef CROSS_DIRECTORY_STRUCTURE
/* XXX implement more magic from gcc.c? */
nprefix = getenv ("GCC_EXEC_PREFIX");
if (!nprefix)
+ nprefix = av[0];
+ else
+ nprefix = concat (nprefix, "gcc-" PERSONALITY, NULL);
+
+ nprefix = make_relative_prefix (nprefix,
+ standard_bin_prefix,
+ standard_libexec_prefix);
+ if (nprefix == NULL)
nprefix = standard_libexec_prefix;
- nprefix = make_relative_prefix (av[0],
- standard_bin_prefix,
- nprefix);
plugin = concat (nprefix,
dir_separator,
DEFAULT_TARGET_MACHINE,
dir_separator,
LTOPLUGINSONAME,
NULL);
- if (access (plugin, X_OK))
+ if (access (plugin, R_OK))
{
fprintf (stderr, "%s: Cannot find plugin %s\n", av[0], plugin);
exit (1);
NULL,NULL, &status, &err);
if (err_msg)
fprintf(stderr, "Error running %s: %s\n", exe_name, err_msg);
+ else if (status)
+ {
+ if (WIFSIGNALED (status))
+ {
+ int sig = WTERMSIG (status);
+ fprintf (stderr, "%s terminated with signal %d [%s]%s\n",
+ exe_name, sig, strsignal(sig),
+ WCOREDUMP(status) ? ", core dumped" : "");
+ }
+ else if (WIFEXITED (status))
+ exit_code = WEXITSTATUS (status);
+ }
+ else
+ exit_code = SUCCESS_EXIT_CODE;
- return err;
+ return exit_code;
}