1 /* Definitions of target machine for GNU compiler, for HP PA-RISC
2    Copyright (C) 1998-2013 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10 
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.  */
19 
20 /* GCC always defines __STDC__.  HP C++ compilers don't define it.  This
21    causes trouble when sys/stdsyms.h is included.  As a work around,
22    we define __STDC_EXT__.  A similar situation exists with respect to
23    the definition of __cplusplus.  We define _INCLUDE_LONGLONG
24    to prevent nlist.h from defining __STDC_32_MODE__ (no longlong
25    support).  We define __STDCPP__ to get certain system headers
26    (notably assert.h) to assume standard preprocessor behavior in C++.  */
27 #undef TARGET_OS_CPP_BUILTINS
28 #define TARGET_OS_CPP_BUILTINS()					\
29   do									\
30     {									\
31 	builtin_assert ("system=hpux");					\
32 	builtin_assert ("system=unix");					\
33 	builtin_define ("__hp9000s800");				\
34 	builtin_define ("__hp9000s800__");				\
35 	builtin_define ("__hpux");					\
36 	builtin_define ("__hpux__");					\
37 	builtin_define ("__unix");					\
38 	builtin_define ("__unix__");					\
39 	builtin_define ("__STDC_EXT__");				\
40 	if (c_dialect_cxx ())						\
41 	  {								\
42 	    builtin_define ("_HPUX_SOURCE");				\
43 	    builtin_define ("_INCLUDE_LONGLONG");			\
44 	    builtin_define ("__STDCPP__");				\
45 	  }								\
46 	else								\
47 	  {								\
48 	    if (!flag_iso)						\
49 	      {								\
50 		builtin_define ("_HPUX_SOURCE");			\
51 		if (preprocessing_trad_p ())				\
52 		  {							\
53 		    builtin_define ("hp9000s800");			\
54 		    builtin_define ("hppa");				\
55 		    builtin_define ("hpux");				\
56 		    builtin_define ("unix");				\
57 		    builtin_define ("__CLASSIC_C__");			\
58 		    builtin_define ("_PWB");				\
59 		    builtin_define ("PWB");				\
60 		  }							\
61 	      }								\
62 	  }								\
63 	if (!TARGET_64BIT)						\
64 	  builtin_define ("_ILP32");					\
65 	if (flag_pa_unix >= 1995 && !flag_iso)				\
66 	  {								\
67 	    builtin_define ("_XOPEN_UNIX");				\
68 	    builtin_define ("_XOPEN_SOURCE_EXTENDED");			\
69 	  }								\
70 	if (TARGET_HPUX_11_11)						\
71 	  {								\
72 	    if (flag_pa_unix >= 1998)					\
73 	      {								\
74 		if (flag_isoc94 || flag_isoc99 || c_dialect_cxx()	\
75 		    || !flag_iso)					\
76 		  builtin_define ("_INCLUDE__STDC_A1_SOURCE");		\
77 		if (!flag_iso)						\
78 		  builtin_define ("_INCLUDE_XOPEN_SOURCE_500");		\
79 	      }								\
80 	    else if (flag_isoc94 || flag_isoc99 || c_dialect_cxx ())	\
81 	      warning (0, "-munix=98 option required for C89 "		\
82 		       "Amendment 1 features.\n");			\
83 	  }								\
84 	if (TARGET_SIO)							\
85 	  builtin_define ("_SIO");					\
86 	else								\
87 	  {								\
88 	    builtin_define ("__hp9000s700");				\
89 	    builtin_define ("__hp9000s700__");				\
90 	    builtin_define ("_WSIO");					\
91 	  }								\
92     }									\
93   while (0)
94 
95 #undef CPP_SPEC
96 #define CPP_SPEC \
97   "%{mt|pthread:-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L}"
98 /* aCC defines also -DRWSTD_MULTI_THREAD, -DRW_MULTI_THREAD.  These
99    affect only aCC's C++ library (Rogue Wave-derived) which we do not
100    use, and they violate the user's name space.  */
101 
102 /* We can debug dynamically linked executables on hpux11; we also
103    want dereferencing of a NULL pointer to cause a SEGV.  */
104 #undef LINK_SPEC
105 #define LINK_SPEC \
106   "%{!shared:%{p:-L/lib/libp -L/usr/lib/libp %{!static:\
107      %nwarning: consider linking with '-static' as system libraries with\n\
108      %n  profiling support are only provided in archive format}}}\
109    %{!shared:%{pg:-L/lib/libp -L/usr/lib/libp %{!static:\
110      %nwarning: consider linking with '-static' as system libraries with\n\
111      %n  profiling support are only provided in archive format}}}\
112    %{!shared:%{!static:%{rdynamic:-E}}}\
113    -z %{mlinker-opt:-O} %{!shared:-u main -u __gcc_plt_call}\
114    %{static:-a archive} %{shared:-b}"
115 
116 /* HP-UX 11 has posix threads.  HP's shared libc contains pthread stubs
117    so that non-threaded applications can be linked with a thread-safe
118    libc without a subsequent loss of performance.  For more details,
119    see <http://docs.hp.com/en/1896/pthreads.html>.  */
120 #undef LIB_SPEC
121 #define LIB_SPEC \
122   "%{!shared:\
123      %{fopenmp:%{static:-a archive_shared} -lrt %{static:-a archive}}\
124      %{mt|pthread:-lpthread} -lc\
125      %{static:%{!nolibdld:-a archive_shared -ldld -a archive -lc}\
126        %{!mt:%{!pthread:-a shared -lc -a archive}}}}\
127    %{shared:%{mt|pthread:-lpthread}}"
128 
129 /* The libgcc_stub.a library needs to come last.  */
130 #undef LINK_GCC_C_SEQUENCE_SPEC
131 #define LINK_GCC_C_SEQUENCE_SPEC \
132   "%G %L %G %{!nostdlib:%{!nodefaultlibs:%{!shared:-lgcc_stub}}}"
133 
134 #undef STARTFILE_SPEC
135 #define STARTFILE_SPEC \
136   "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}} \
137      %{!munix=93:unix95%O%s}}"
138 
139 /* Under hpux11, the normal location of the `ld' and `as' programs is the
140    /usr/ccs/bin directory.  */
141 
142 #ifndef CROSS_DIRECTORY_STRUCTURE
143 #undef MD_EXEC_PREFIX
144 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
145 #endif
146 
147 /* Under hpux11 the normal location of the various *crt*.o files is
148    the /usr/ccs/lib directory.  However, the profiling files are in
149    /opt/langtools/lib.  */
150 
151 #ifndef CROSS_DIRECTORY_STRUCTURE
152 #undef MD_STARTFILE_PREFIX
153 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/"
154 #define MD_STARTFILE_PREFIX_1 "/opt/langtools/lib/"
155 #endif
156 
157 /* hpux11 has the new HP assembler.  It's still lousy, but it's a whole lot
158    better than the assembler shipped with older versions of hpux.  */
159 #undef NEW_HP_ASSEMBLER
160 #define NEW_HP_ASSEMBLER 1
161 
162 /* Make GCC agree with types.h.  */
163 #undef SIZE_TYPE
164 #undef PTRDIFF_TYPE
165 
166 #define SIZE_TYPE "long unsigned int"
167 #define PTRDIFF_TYPE "long int"
168 
169 /* HP-UX 11.0 and above provides initialization and finalization function
170    support from linker command line.  We don't need to invoke __main to run
171    constructors.  We also don't need chatr to determine the dependencies of
172    dynamically linked executables and shared libraries.  */
173 #undef LDD_SUFFIX
174 #undef PARSE_LDD_OUTPUT
175 #undef HAS_INIT_SECTION
176 #define HAS_INIT_SECTION 1
177 #undef LD_INIT_SWITCH
178 #define LD_INIT_SWITCH "+init"
179 #undef LD_FINI_SWITCH
180 #define LD_FINI_SWITCH "+fini"
181 
182 /* The HP-UX 11.X SOM linker (ld32) can successfully link shared libraries
183    with secondary definition (weak) symbols.  */
184 #undef TARGET_SOM_SDEF
185 #define TARGET_SOM_SDEF 1
186 
187 #undef TARGET_HPUX_11
188 #define TARGET_HPUX_11 1
189