110d565efSmrg /* Base configuration file for all FreeBSD targets.
2*ec02198aSmrg    Copyright (C) 1999-2020 Free Software Foundation, Inc.
310d565efSmrg 
410d565efSmrg This file is part of GCC.
510d565efSmrg 
610d565efSmrg GCC is free software; you can redistribute it and/or modify
710d565efSmrg it under the terms of the GNU General Public License as published by
810d565efSmrg the Free Software Foundation; either version 3, or (at your option)
910d565efSmrg any later version.
1010d565efSmrg 
1110d565efSmrg GCC is distributed in the hope that it will be useful,
1210d565efSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
1310d565efSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1410d565efSmrg GNU General Public License for more details.
1510d565efSmrg 
1610d565efSmrg Under Section 7 of GPL version 3, you are granted additional
1710d565efSmrg permissions described in the GCC Runtime Library Exception, version
1810d565efSmrg 3.1, as published by the Free Software Foundation.
1910d565efSmrg 
2010d565efSmrg You should have received a copy of the GNU General Public License and
2110d565efSmrg a copy of the GCC Runtime Library Exception along with this program;
2210d565efSmrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
2310d565efSmrg <http://www.gnu.org/licenses/>.  */
2410d565efSmrg 
2510d565efSmrg /* Common FreeBSD configuration.
2610d565efSmrg    All FreeBSD architectures should include this file, which will specify
2710d565efSmrg    their commonalities.
2810d565efSmrg    Adapted from gcc/config/freebsd.h by
2910d565efSmrg    David O'Brien <obrien@FreeBSD.org>
3010d565efSmrg    Loren J. Rittle <ljrittle@acm.org>.  */
3110d565efSmrg 
3210d565efSmrg 
3310d565efSmrg /* In case we need to know.  */
3410d565efSmrg #define USING_CONFIG_FREEBSD_SPEC 1
3510d565efSmrg 
3610d565efSmrg #define FBSD_TARGET_OS_CPP_BUILTINS()					\
3710d565efSmrg   do									\
3810d565efSmrg     {									\
3910d565efSmrg 	builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR);	\
4010d565efSmrg 	builtin_define_std ("unix");					\
4110d565efSmrg 	builtin_define ("__KPRINTF_ATTRIBUTE__");		       	\
4210d565efSmrg 	builtin_assert ("system=unix");					\
4310d565efSmrg 	builtin_assert ("system=bsd");					\
4410d565efSmrg 	builtin_assert ("system=FreeBSD");				\
4510d565efSmrg 	FBSD_TARGET_CPU_CPP_BUILTINS();					\
4610d565efSmrg     }									\
4710d565efSmrg   while (0)
4810d565efSmrg 
4910d565efSmrg /* Define the default FreeBSD-specific per-CPU hook code.  */
5010d565efSmrg #define FBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
5110d565efSmrg 
5210d565efSmrg /* Provide a CPP_SPEC appropriate for FreeBSD.  We just deal with the GCC
5310d565efSmrg    option `-posix', and PIC issues.  */
5410d565efSmrg 
5510d565efSmrg #define FBSD_CPP_SPEC "							\
5610d565efSmrg   %(cpp_cpu)								\
5710d565efSmrg   %(cpp_arch)								\
5810d565efSmrg   %{posix:-D_POSIX_SOURCE}"
5910d565efSmrg 
6010d565efSmrg /* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add
6110d565efSmrg    the magical crtbegin.o file (see crtstuff.c) which provides part
6210d565efSmrg 	of the support for getting C++ file-scope static object constructed
6310d565efSmrg 	before entering `main'.  */
6410d565efSmrg 
6510d565efSmrg #define FBSD_STARTFILE_SPEC \
6610d565efSmrg   "%{!shared: \
6710d565efSmrg      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
6810d565efSmrg 		       %{!p:%{profile:gcrt1.o%s} \
6910d565efSmrg 			 %{!profile: \
7010d565efSmrg                             %{pie: Scrt1.o%s;:crt1.o%s}}}}} \
7110d565efSmrg    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
7210d565efSmrg 
7310d565efSmrg /* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
7410d565efSmrg    the magical crtend.o file (see crtstuff.c) which provides part of
7510d565efSmrg 	the support for getting C++ file-scope static object constructed
7610d565efSmrg 	before entering `main', followed by a normal "finalizer" file,
7710d565efSmrg 	`crtn.o'.  */
7810d565efSmrg 
7910d565efSmrg #define FBSD_ENDFILE_SPEC \
8010d565efSmrg   "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
8110d565efSmrg 
820fc04c29Smrg /* When threads support is requested include both -lc and the threading
830fc04c29Smrg    library (which assumes FreeBSD 5.x or later, __FreeBSD_version 500016
840fc04c29Smrg    to be precise).
850fc04c29Smrg    And make it a hard error if -pthread is provided on the command
8610d565efSmrg    line and gcc was configured with --disable-threads (this will help
8710d565efSmrg    avoid bug reports from users complaining about threading when they
8810d565efSmrg    misconfigured the gcc bootstrap but are later consulting FreeBSD
8910d565efSmrg    manual pages that refer to the mythical -pthread option).  */
9010d565efSmrg 
9110d565efSmrg /* Provide a LIB_SPEC appropriate for FreeBSD.  Just select the appropriate
9210d565efSmrg    libc, depending on whether we're doing profiling or need threads support.
9310d565efSmrg    (similar to the default, except no -lg, and no -p).  */
9410d565efSmrg 
9510d565efSmrg #ifdef FBSD_NO_THREADS
9610d565efSmrg #define FBSD_LIB_SPEC "							\
9710d565efSmrg   %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
9810d565efSmrg is built with the --enable-threads configure-time option.}		\
9910d565efSmrg   %{!shared:								\
10010d565efSmrg     %{!pg: -lc}								\
10110d565efSmrg     %{pg:  -lc_p}							\
10210d565efSmrg   }"
10310d565efSmrg #else
10410d565efSmrg #define FBSD_LIB_SPEC "							\
10510d565efSmrg   %{!shared:								\
10610d565efSmrg     %{!pg: %{pthread:-lpthread} -lc}					\
10710d565efSmrg     %{pg:  %{pthread:-lpthread_p} -lc_p}				\
10810d565efSmrg   }									\
10910d565efSmrg   %{shared:								\
11010d565efSmrg     %{pthread:-lpthread} -lc						\
11110d565efSmrg   }"
11210d565efSmrg #endif
1130fc04c29Smrg 
1140fc04c29Smrg /* To make matters interesting, we can't actually use __FreeBSD_version
1150fc04c29Smrg    provided by <osreldate.h> directly since it breaks cross-compiling.  */
11610d565efSmrg 
11710d565efSmrg #if FBSD_MAJOR < 6
11810d565efSmrg #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
11910d565efSmrg #else
12010d565efSmrg #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
12110d565efSmrg #endif
12210d565efSmrg 
12310d565efSmrg /* NOTE: The freebsd-spec.h header is included also for various
12410d565efSmrg    non-FreeBSD powerpc targets, thus it should never define macros
12510d565efSmrg    other than FBSD_* prefixed ones, or USING_CONFIG_FREEBSD_SPEC.  */
126