freebsd-spec.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* Base configuration file for all FreeBSD targets.
  2. Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. GCC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. /* Common FreeBSD configuration.
  20. All FreeBSD architectures should include this file, which will specify
  21. their commonalities.
  22. Adapted from gcc/config/freebsd.h by
  23. David O'Brien <obrien@FreeBSD.org>
  24. Loren J. Rittle <ljrittle@acm.org>. */
  25. /* In case we need to know. */
  26. #define USING_CONFIG_FREEBSD_SPEC 1
  27. #define FBSD_TARGET_OS_CPP_BUILTINS() \
  28. do \
  29. { \
  30. builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR); \
  31. builtin_define_std ("unix"); \
  32. builtin_define ("__KPRINTF_ATTRIBUTE__"); \
  33. builtin_assert ("system=unix"); \
  34. builtin_assert ("system=bsd"); \
  35. builtin_assert ("system=FreeBSD"); \
  36. FBSD_TARGET_CPU_CPP_BUILTINS(); \
  37. } \
  38. while (0)
  39. /* Define the default FreeBSD-specific per-CPU hook code. */
  40. #define FBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
  41. /* Provide a CPP_SPEC appropriate for FreeBSD. We just deal with the GCC
  42. option `-posix', and PIC issues. */
  43. #define FBSD_CPP_SPEC " \
  44. %(cpp_cpu) \
  45. %(cpp_arch) \
  46. %{posix:-D_POSIX_SOURCE}"
  47. /* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add
  48. the magical crtbegin.o file (see crtstuff.c) which provides part
  49. of the support for getting C++ file-scope static object constructed
  50. before entering `main'. */
  51. #define FBSD_STARTFILE_SPEC \
  52. "%{!shared: \
  53. %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
  54. %{!p:%{profile:gcrt1.o%s} \
  55. %{!profile: \
  56. %{pie: Scrt1.o%s;:crt1.o%s}}}}} \
  57. crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
  58. /* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on
  59. the magical crtend.o file (see crtstuff.c) which provides part of
  60. the support for getting C++ file-scope static object constructed
  61. before entering `main', followed by a normal "finalizer" file,
  62. `crtn.o'. */
  63. #define FBSD_ENDFILE_SPEC \
  64. "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
  65. /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
  66. required by the user-land thread model. Before __FreeBSD_version
  67. 500016, select the appropriate libc, depending on whether we're
  68. doing profiling or need threads support. At __FreeBSD_version
  69. 500016 and later, when threads support is requested include both
  70. -lc and the threading lib instead of only -lc_r. To make matters
  71. interesting, we can't actually use __FreeBSD_version provided by
  72. <osreldate.h> directly since it breaks cross-compiling. As a final
  73. twist, make it a hard error if -pthread is provided on the command
  74. line and gcc was configured with --disable-threads (this will help
  75. avoid bug reports from users complaining about threading when they
  76. misconfigured the gcc bootstrap but are later consulting FreeBSD
  77. manual pages that refer to the mythical -pthread option). */
  78. /* Provide a LIB_SPEC appropriate for FreeBSD. Just select the appropriate
  79. libc, depending on whether we're doing profiling or need threads support.
  80. (similar to the default, except no -lg, and no -p). */
  81. #ifdef FBSD_NO_THREADS
  82. #define FBSD_LIB_SPEC " \
  83. %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
  84. is built with the --enable-threads configure-time option.} \
  85. %{!shared: \
  86. %{!pg: -lc} \
  87. %{pg: -lc_p} \
  88. }"
  89. #else
  90. #if FBSD_MAJOR < 5
  91. #define FBSD_LIB_SPEC " \
  92. %{!shared: \
  93. %{!pg: \
  94. %{!pthread:-lc} \
  95. %{pthread:-lc_r}} \
  96. %{pg: \
  97. %{!pthread:-lc_p} \
  98. %{pthread:-lc_r_p}} \
  99. }"
  100. #else
  101. #define FBSD_LIB_SPEC " \
  102. %{!shared: \
  103. %{!pg: %{pthread:-lpthread} -lc} \
  104. %{pg: %{pthread:-lpthread_p} -lc_p} \
  105. } \
  106. %{shared: \
  107. %{pthread:-lpthread} -lc \
  108. }"
  109. #endif
  110. #endif
  111. #if FBSD_MAJOR < 6
  112. #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
  113. #else
  114. #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
  115. #endif
  116. /* NOTE: The freebsd-spec.h header is included also for various
  117. non-FreeBSD powerpc targets, thus it should never define macros
  118. other than FBSD_* prefixed ones, or USING_CONFIG_FREEBSD_SPEC. */