aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/vxworks-driver.cc
blob: da5f015f1de7109c1c80cb9a68c5213007542cbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Copyright (C) 2022 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "opts.h"

/* Perform early driver flags initializations that can't be achieved
   with specs.  In particular, we need to explicitly request a static
   link for rtps by default before lang_specific_driver gets control.  */

void vxworks_driver_init (unsigned int *in_decoded_options_count,
			  struct cl_decoded_option **in_decoded_options)
{
  unsigned int i;
  struct cl_decoded_option *decoded_options = *in_decoded_options;

  /* Arrange to add -static if we are going to link a rtp and there is no
     trace of any explicit request for a specific kind of link.  */
  bool wont_link = false;
  bool mrtp = false;
  bool link_kind_indication = false;

  /* The new argument list will be contained in this.  */
  struct cl_decoded_option *new_decoded_options;
  unsigned int num_options = *in_decoded_options_count;

  for (i = 1; i < num_options; i++)
    {
      if (decoded_options[i].errors & CL_ERR_MISSING_ARG)
	continue;

      switch (decoded_options[i].opt_index)
	{
	case OPT_static:
	case OPT_shared:
	case OPT_Bdynamic:
	case OPT_Bstatic:
	case OPT_non_static:
	  link_kind_indication = true;
	  break;

	case OPT_c:
	case OPT_r:
	case OPT_S:
	case OPT_E:
	case OPT_M:
	case OPT_MM:
	case OPT_fsyntax_only:
	  wont_link = true;
	  break;

	case OPT_mrtp:
	  mrtp = true;
	  break;

	default:
	  break;
      }
    }

  if (!wont_link && mrtp && !link_kind_indication)
    {
      num_options++;
      new_decoded_options = XNEWVEC(struct cl_decoded_option, num_options);

      for (i = 0; i < num_options - 1; i++)
	new_decoded_options[i] = decoded_options[i];

      generate_option(OPT_static, NULL, 1, CL_DRIVER,
		      &new_decoded_options[num_options - 1]);

      *in_decoded_options = new_decoded_options;
      *in_decoded_options_count = num_options;
    }
}