Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / config / linux.h
blob1c4ea1c7bb0acea30da3eb36a2a94799a8dd56ce
1 /* Definitions for Linux-based GNU systems with ELF format
2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006,
3 2007, 2009, 2010 Free Software Foundation, Inc.
4 Contributed by Eric Youngdale.
5 Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
28 /* Don't assume anything about the header files. */
29 #define NO_IMPLICIT_EXTERN_C
31 #undef ASM_APP_ON
32 #define ASM_APP_ON "#APP\n"
34 #undef ASM_APP_OFF
35 #define ASM_APP_OFF "#NO_APP\n"
37 /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
38 the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
39 provides part of the support for getting C++ file-scope static
40 object constructed before entering `main'. */
42 #if defined HAVE_LD_PIE
43 #define LINUX_TARGET_STARTFILE_SPEC \
44 "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
45 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
46 #else
47 #define LINUX_TARGET_STARTFILE_SPEC \
48 "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
49 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
50 #endif
51 #undef STARTFILE_SPEC
52 #define STARTFILE_SPEC LINUX_TARGET_STARTFILE_SPEC
54 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
55 the GNU/Linux magical crtend.o file (see crtstuff.c) which
56 provides part of the support for getting C++ file-scope static
57 object constructed before entering `main', followed by a normal
58 GNU/Linux "finalizer" file, `crtn.o'. */
60 #define LINUX_TARGET_ENDFILE_SPEC \
61 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
62 #undef ENDFILE_SPEC
63 #define ENDFILE_SPEC LINUX_TARGET_ENDFILE_SPEC
65 /* This is for -profile to use -lc_p instead of -lc. */
66 #define LINUX_TARGET_CC1_SPEC "%{profile:-p}"
67 #ifndef CC1_SPEC
68 #define CC1_SPEC LINUX_TARGET_CC1_SPEC
69 #endif
71 /* The GNU C++ standard library requires that these macros be defined. */
72 #undef CPLUSPLUS_CPP_SPEC
73 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
75 #define LINUX_TARGET_LIB_SPEC \
76 "%{pthread:-lpthread} \
77 %{shared:-lc} \
78 %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
79 #undef LIB_SPEC
80 #define LIB_SPEC LINUX_TARGET_LIB_SPEC
82 /* C libraries supported on Linux. */
83 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
84 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
85 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
87 #define LINUX_TARGET_OS_CPP_BUILTINS() \
88 do { \
89 if (OPTION_GLIBC) \
90 builtin_define ("__gnu_linux__"); \
91 builtin_define_std ("linux"); \
92 builtin_define_std ("unix"); \
93 builtin_assert ("system=linux"); \
94 builtin_assert ("system=unix"); \
95 builtin_assert ("system=posix"); \
96 } while (0)
98 #if defined(HAVE_LD_EH_FRAME_HDR)
99 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
100 #endif
102 #undef LINK_GCC_C_SEQUENCE_SPEC
103 #define LINK_GCC_C_SEQUENCE_SPEC \
104 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
106 /* Use --as-needed -lgcc_s for eh support. */
107 #ifdef HAVE_LD_AS_NEEDED
108 #define USE_LD_AS_NEEDED 1
109 #endif
111 /* Determine which dynamic linker to use depending on whether GLIBC or
112 uClibc or Bionic is the default C library and whether
113 -muclibc or -mglibc or -mbionic has been passed to change the default. */
115 #define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
116 "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
118 #if DEFAULT_LIBC == LIBC_GLIBC
119 #define CHOOSE_DYNAMIC_LINKER(G, U, B) \
120 CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
121 #elif DEFAULT_LIBC == LIBC_UCLIBC
122 #define CHOOSE_DYNAMIC_LINKER(G, U, B) \
123 CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
124 #elif DEFAULT_LIBC == LIBC_BIONIC
125 #define CHOOSE_DYNAMIC_LINKER(G, U, B) \
126 CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
127 #else
128 #error "Unsupported DEFAULT_LIBC"
129 #endif /* DEFAULT_LIBC */
131 /* For most targets the following definitions suffice;
132 GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
133 GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
134 supporting both 32-bit and 64-bit compilation. */
135 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
136 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
137 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
138 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
139 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
140 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
142 #define LINUX_DYNAMIC_LINKER \
143 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
144 BIONIC_DYNAMIC_LINKER)
145 #define LINUX_DYNAMIC_LINKER32 \
146 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
147 BIONIC_DYNAMIC_LINKER32)
148 #define LINUX_DYNAMIC_LINKER64 \
149 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
150 BIONIC_DYNAMIC_LINKER64)
152 /* Determine whether the entire c99 runtime
153 is present in the runtime library. */
154 #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
156 /* Whether we have sincos that follows the GNU extension. */
157 #define TARGET_HAS_SINCOS (OPTION_GLIBC || OPTION_BIONIC)
159 #define TARGET_POSIX_IO