PR c++/54038
[official-gcc.git] / gcc / ada / link.c
blob8a8e12033d74a9d699977198e6a6fc7b3b3c8b60
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * L I N K *
6 * *
7 * C Implementation File *
8 * *
9 * Copyright (C) 1992-2012, Free Software Foundation, Inc. *
10 * *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 3, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. *
17 * *
18 * As a special exception under Section 7 of GPL version 3, you are granted *
19 * additional permissions described in the GCC Runtime Library Exception, *
20 * version 3.1, as published by the Free Software Foundation. *
21 * *
22 * You should have received a copy of the GNU General Public License and *
23 * a copy of the GCC Runtime Library Exception along with this program; *
24 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see *
25 * <http://www.gnu.org/licenses/>. *
26 * *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
29 * *
30 ****************************************************************************/
32 /* This file contains host-specific parameters describing the behavior of the
33 linker. It is used by gnatlink as well as all tools that use Mlib. */
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #ifdef IN_GCC
40 #include "auto-host.h"
41 #endif
43 #include <string.h>
45 /* objlist_file_supported is set to 1 when the system linker allows */
46 /* response file, that is a file that contains the list of object files. */
47 /* This is useful on systems where the command line length is limited, */
48 /* meaning that putting all the object files on the command line can */
49 /* result in an unacceptable limit on the number of files. */
51 /* object_file_option denotes the system dependent linker option which */
52 /* allows object file names to be placed in a file and then passed to */
53 /* the linker. object_file_option must be set if objlist_file_supported */
54 /* is set to 1. */
56 /* link_max is a conservative system specific threshold (in bytes) of the */
57 /* argument length passed to the linker which will trigger a file being */
58 /* used instead of the command line directly. If the argument length is */
59 /* greater than this threshold, then an objlist_file will be generated */
60 /* and object_file_option and objlist_file_supported must be set. If */
61 /* objlist_file_supported is set to 0 (unsupported), then link_max is */
62 /* set to 2**31-1 so that the limit will never be exceeded. */
64 /* run_path_option is the system dependent linker option which specifies */
65 /* the run time path to use when loading dynamic libraries. This should */
66 /* be set to the null string if the system does not support dynamic */
67 /* loading of libraries. */
69 /* shared_libgnat_default gives the system dependent link method that */
70 /* be used by default for linking libgnat (shared or static) */
72 /* shared_libgcc_default gives the system dependent link method that */
73 /* be used by default for linking libgcc (shared or static) */
75 /* separate_run_path_options is set to 1 when separate "rpath" arguments */
76 /* must be passed to the linker for each directory in the rpath. */
78 /* default_libgcc_subdir is the subdirectory name (from the installation */
79 /* root) where we may find a shared libgcc to use by default. */
81 #define SHARED 'H'
82 #define STATIC 'T'
84 #if defined (__WIN32)
85 const char *__gnat_object_file_option = "-Wl,@";
86 const char *__gnat_run_path_option = "";
87 int __gnat_link_max = 30000;
88 unsigned char __gnat_objlist_file_supported = 1;
89 char __gnat_shared_libgnat_default = STATIC;
90 char __gnat_shared_libgcc_default = STATIC;
91 const char *__gnat_object_library_extension = ".a";
92 unsigned char __gnat_separate_run_path_options = 0;
93 const char *__gnat_default_libgcc_subdir = "lib";
95 #elif defined (__hpux__)
96 const char *__gnat_object_file_option = "-Wl,-c,";
97 const char *__gnat_run_path_option = "-Wl,+b,";
98 int __gnat_link_max = 5000;
99 unsigned char __gnat_objlist_file_supported = 1;
100 char __gnat_shared_libgnat_default = STATIC;
101 char __gnat_shared_libgcc_default = STATIC;
102 const char *__gnat_object_library_extension = ".a";
103 unsigned char __gnat_separate_run_path_options = 0;
104 const char *__gnat_default_libgcc_subdir = "lib";
106 #elif defined (__FreeBSD__)
107 const char *__gnat_object_file_option = "-Wl,@";
108 const char *__gnat_run_path_option = "-Wl,-rpath,";
109 char __gnat_shared_libgnat_default = STATIC;
110 char __gnat_shared_libgcc_default = STATIC;
111 int __gnat_link_max = 8192;
112 unsigned char __gnat_objlist_file_supported = 1;
113 const char *__gnat_object_library_extension = ".a";
114 unsigned char __gnat_separate_run_path_options = 0;
115 const char *__gnat_default_libgcc_subdir = "lib";
117 #elif defined (__APPLE__)
118 const char *__gnat_object_file_option = "-Wl,-filelist,";
119 const char *__gnat_run_path_option = "-Wl,-rpath,";
120 char __gnat_shared_libgnat_default = STATIC;
121 char __gnat_shared_libgcc_default = SHARED;
122 int __gnat_link_max = 262144;
123 unsigned char __gnat_objlist_file_supported = 1;
124 const char *__gnat_object_library_extension = ".a";
125 unsigned char __gnat_separate_run_path_options = 1;
126 const char *__gnat_default_libgcc_subdir = "lib";
128 #elif defined (linux) || defined(__GLIBC__)
129 const char *__gnat_object_file_option = "-Wl,@";
130 const char *__gnat_run_path_option = "-Wl,-rpath,";
131 char __gnat_shared_libgnat_default = STATIC;
132 char __gnat_shared_libgcc_default = STATIC;
133 int __gnat_link_max = 8192;
134 unsigned char __gnat_objlist_file_supported = 1;
135 const char *__gnat_object_library_extension = ".a";
136 unsigned char __gnat_separate_run_path_options = 0;
137 #if defined (__x86_64)
138 # if defined (__LP64__)
139 const char *__gnat_default_libgcc_subdir = "lib64";
140 # else
141 const char *__gnat_default_libgcc_subdir = "libx32";
142 # endif
143 #else
144 const char *__gnat_default_libgcc_subdir = "lib";
145 #endif
147 #elif defined (_AIX)
148 /* On AIX, even when with GNU ld we use native linker switches. This is
149 particularly important for '-f' as it should be interpreted by collect2. */
151 const char *__gnat_object_file_option = "-Wl,-f,";
152 const char *__gnat_run_path_option = "";
153 char __gnat_shared_libgnat_default = STATIC;
154 char __gnat_shared_libgcc_default = STATIC;
155 int __gnat_link_max = 15000;
156 const unsigned char __gnat_objlist_file_supported = 1;
157 const char *__gnat_object_library_extension = ".a";
158 unsigned char __gnat_separate_run_path_options = 0;
159 const char *__gnat_default_libgcc_subdir = "lib";
161 #elif (HAVE_GNU_LD)
162 /* These are the settings for all systems that use gnu ld. GNU style response
163 file is supported, the shared library default is STATIC. */
165 const char *__gnat_object_file_option = "-Wl,@";
166 const char *__gnat_run_path_option = "";
167 char __gnat_shared_libgnat_default = STATIC;
168 char __gnat_shared_libgcc_default = STATIC;
169 int __gnat_link_max = 8192;
170 unsigned char __gnat_objlist_file_supported = 1;
171 const char *__gnat_object_library_extension = ".a";
172 unsigned char __gnat_separate_run_path_options = 0;
173 const char *__gnat_default_libgcc_subdir = "lib";
175 #elif defined (VMS)
176 const char *__gnat_object_file_option = "";
177 const char *__gnat_run_path_option = "";
178 char __gnat_shared_libgnat_default = STATIC;
179 char __gnat_shared_libgcc_default = STATIC;
180 int __gnat_link_max = 2147483647;
181 unsigned char __gnat_objlist_file_supported = 0;
182 const char *__gnat_object_library_extension = ".olb";
183 unsigned char __gnat_separate_run_path_options = 0;
184 const char *__gnat_default_libgcc_subdir = "lib";
186 #elif defined (sun)
187 const char *__gnat_object_file_option = "";
188 const char *__gnat_run_path_option = "-Wl,-R";
189 char __gnat_shared_libgnat_default = STATIC;
190 char __gnat_shared_libgcc_default = STATIC;
191 int __gnat_link_max = 2147483647;
192 unsigned char __gnat_objlist_file_supported = 0;
193 const char *__gnat_object_library_extension = ".a";
194 unsigned char __gnat_separate_run_path_options = 0;
195 #if defined (__sparc_v9__) || defined (__sparcv9)
196 const char *__gnat_default_libgcc_subdir = "lib/sparcv9";
197 #elif defined (__x86_64)
198 const char *__gnat_default_libgcc_subdir = "lib/amd64";
199 #else
200 const char *__gnat_default_libgcc_subdir = "lib";
201 #endif
203 #elif defined (__svr4__) && defined (i386)
204 const char *__gnat_object_file_option = "";
205 const char *__gnat_run_path_option = "";
206 char __gnat_shared_libgnat_default = STATIC;
207 char __gnat_shared_libgcc_default = STATIC;
208 int __gnat_link_max = 2147483647;
209 unsigned char __gnat_objlist_file_supported = 0;
210 const char *__gnat_object_library_extension = ".a";
211 unsigned char __gnat_separate_run_path_options = 0;
212 const char *__gnat_default_libgcc_subdir = "lib";
214 #else
216 /* These are the default settings for all other systems. No response file
217 is supported, the shared library default is STATIC. */
218 const char *__gnat_run_path_option = "";
219 const char *__gnat_object_file_option = "";
220 char __gnat_shared_libgnat_default = STATIC;
221 char __gnat_shared_libgcc_default = STATIC;
222 int __gnat_link_max = 2147483647;
223 unsigned char __gnat_objlist_file_supported = 0;
224 const char *__gnat_object_library_extension = ".a";
225 unsigned char __gnat_separate_run_path_options = 0;
226 const char *__gnat_default_libgcc_subdir = "lib";
227 #endif
229 #ifdef __cplusplus
231 #endif