OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [gcc-ar.c] - Blame information for rev 775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 684 jeremybenn
/* Wrapper for ar/ranlib/nm to pass the LTO plugin.
2
   Copyright (C) 2011 Free Software Foundation, Inc.
3
   Contributed by Andi Kleen.
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 3, or (at your option) any later
10
version.
11
 
12
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13
WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15
for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.  */
20
 
21
#include "config.h"
22
#include "system.h"
23
#include "libiberty.h"
24
 
25
#ifndef PERSONALITY
26
#error "Please set personality"
27
#endif
28
 
29
static const char standard_libexec_prefix[] = STANDARD_LIBEXEC_PREFIX;
30
static const char standard_bin_prefix[] = STANDARD_BINDIR_PREFIX;
31
static const char *const target_machine = TARGET_MACHINE;
32
 
33
static const char dir_separator[] = { DIR_SEPARATOR, 0 };
34
 
35
int
36
main(int ac, char **av)
37
{
38
  const char *nprefix;
39
  const char *exe_name;
40
  char *plugin;
41
  int k, status, err;
42
  const char *err_msg;
43
  const char **nargv;
44
  bool is_ar = !strcmp (PERSONALITY, "ar");
45
 
46
  exe_name = PERSONALITY;
47
#ifdef CROSS_DIRECTORY_STRUCTURE
48
  exe_name = concat (target_machine, "-", exe_name, NULL);
49
#endif
50
 
51
  /* Find plugin */
52
  /* XXX implement more magic from gcc.c? */
53
  nprefix = getenv ("GCC_EXEC_PREFIX");
54
  if (!nprefix)
55
    nprefix = standard_libexec_prefix;
56
 
57
  nprefix = make_relative_prefix (av[0],
58
                                  standard_bin_prefix,
59
                                  nprefix);
60
  plugin = concat (nprefix,
61
                   dir_separator,
62
                   DEFAULT_TARGET_MACHINE,
63
                   dir_separator,
64
                   DEFAULT_TARGET_VERSION,
65
                   dir_separator,
66
                   LTOPLUGINSONAME,
67
                   NULL);
68
  if (access (plugin, X_OK))
69
    {
70
      fprintf (stderr, "%s: Cannot find plugin %s\n", av[0], plugin);
71
      exit (1);
72
    }
73
 
74
  /* Create new command line with plugin */
75
  nargv = XCNEWVEC (const char *, ac + 4);
76
  nargv[0] = exe_name;
77
  nargv[1] = "--plugin";
78
  nargv[2] = plugin;
79
  if (is_ar && av[1] && av[1][0] != '-')
80
    av[1] = concat("-", av[1], NULL);
81
  for (k = 1; k < ac; k++)
82
    nargv[2 + k] = av[k];
83
  nargv[2 + k] = NULL;
84
 
85
  /* Run utility */
86
  /* ??? the const is misplaced in pex_one's argv? */
87
  err_msg = pex_one (PEX_LAST|PEX_SEARCH,
88
                     exe_name,
89
                     CONST_CAST2 (char * const *, const char **, nargv),
90
                     concat("gcc-", exe_name, NULL),
91
                     NULL,NULL,  &status, &err);
92
  if (err_msg)
93
    fprintf(stderr, "Error running %s: %s\n", exe_name, err_msg);
94
 
95
  return err;
96
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.