arm-softfloat.patch.conditional 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. #
  2. # Submitted:
  3. #
  4. # Dimitry Andric <dimitry@andric.com>, 2004-05-01
  5. #
  6. # Description:
  7. #
  8. # Nicholas Pitre released this patch for gcc soft-float support here:
  9. # http://lists.arm.linux.org.uk/pipermail/linux-arm/2003-October/006436.html
  10. #
  11. # This version has been adapted to work with gcc 3.4.0.
  12. #
  13. # The original patch doesn't distinguish between softfpa and softvfp modes
  14. # in the way Nicholas Pitre probably meant. His description is:
  15. #
  16. # "Default is to use APCS-32 mode with soft-vfp. The old Linux default for
  17. # floats can be achieved with -mhard-float or with the configure
  18. # --with-float=hard option. If -msoft-float or --with-float=soft is used then
  19. # software float support will be used just like the default but with the legacy
  20. # big endian word ordering for double float representation instead."
  21. #
  22. # Which means the following:
  23. #
  24. # * If you compile without -mhard-float or -msoft-float, you should get
  25. # software floating point, using the VFP format. The produced object file
  26. # should have these flags in its header:
  27. #
  28. # private flags = 600: [APCS-32] [VFP float format] [software FP]
  29. #
  30. # * If you compile with -mhard-float, you should get hardware floating point,
  31. # which always uses the FPA format. Object file header flags should be:
  32. #
  33. # private flags = 0: [APCS-32] [FPA float format]
  34. #
  35. # * If you compile with -msoft-float, you should get software floating point,
  36. # using the FPA format. This is done for compatibility reasons with many
  37. # existing distributions. Object file header flags should be:
  38. #
  39. # private flags = 200: [APCS-32] [FPA float format] [software FP]
  40. #
  41. # The original patch from Nicholas Pitre contained the following constructs:
  42. #
  43. # #define SUBTARGET_EXTRA_ASM_SPEC "%{!mcpu=*:-mcpu=xscale} \
  44. # %{mhard-float:-mfpu=fpa} \
  45. # %{!mhard-float: %{msoft-float:-mfpu=softfpa;:-mfpu=softvfp}}"
  46. #
  47. # However, gcc doesn't accept this ";:" notation, used in the 3rd line. This
  48. # is probably the reason Robert Schwebel modified it to:
  49. #
  50. # #define SUBTARGET_EXTRA_ASM_SPEC "%{!mcpu=*:-mcpu=xscale} \
  51. # %{mhard-float:-mfpu=fpa} \
  52. # %{!mhard-float: %{msoft-float:-mfpu=softfpa -mfpu=softvfp}}"
  53. #
  54. # But this causes the following behaviour:
  55. #
  56. # * If you compile without -mhard-float or -msoft-float, the compiler generates
  57. # software floating point instructions, but *nothing* is passed to the
  58. # assembler, which results in an object file which has flags:
  59. #
  60. # private flags = 0: [APCS-32] [FPA float format]
  61. #
  62. # This is not correct!
  63. #
  64. # * If you compile with -mhard-float, the compiler generates hardware floating
  65. # point instructions, and passes "-mfpu=fpa" to the assembler, which results
  66. # in an object file which has the same flags as in the previous item, but now
  67. # those *are* correct.
  68. #
  69. # * If you compile with -msoft-float, the compiler generates software floating
  70. # point instructions, and passes "-mfpu=softfpa -mfpu=softvfp" (in that
  71. # order) to the assembler, which results in an object file with flags:
  72. #
  73. # private flags = 600: [APCS-32] [VFP float format] [software FP]
  74. #
  75. # This is not correct, because the last "-mfpu=" option on the assembler
  76. # command line determines the actual FPU convention used (which should be FPA
  77. # in this case).
  78. #
  79. # Therefore, I modified this patch to get the desired behaviour. Every
  80. # instance of the notation:
  81. #
  82. # %{msoft-float:-mfpu=softfpa -mfpu=softvfp}
  83. #
  84. # was changed to:
  85. #
  86. # %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}
  87. #
  88. # I also did the following:
  89. #
  90. # * Modified all TARGET_DEFAULT macros I could find to include ARM_FLAG_VFP, to
  91. # be consistent with Nicholas' original patch.
  92. # * Removed any "msoft-float" or "mhard-float" from all MULTILIB_DEFAULTS
  93. # macros I could find. I think that if you compile without any options, you
  94. # would like to get the defaults. :)
  95. # * Removed the extra -lfloat option from LIBGCC_SPEC, since it isn't needed
  96. # anymore. (The required functions are now in libgcc.)
  97. diff -urNd gcc-3.4.0-orig/gcc/config/arm/coff.h gcc-3.4.0/gcc/config/arm/coff.h
  98. --- gcc-3.4.0-orig/gcc/config/arm/coff.h 2004-02-24 15:25:22.000000000 +0100
  99. +++ gcc-3.4.0/gcc/config/arm/coff.h 2004-05-01 19:07:06.059409600 +0200
  100. @@ -31,11 +31,16 @@
  101. #define TARGET_VERSION fputs (" (ARM/coff)", stderr)
  102. #undef TARGET_DEFAULT
  103. -#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
  104. +#define TARGET_DEFAULT \
  105. + ( ARM_FLAG_SOFT_FLOAT \
  106. + | ARM_FLAG_VFP \
  107. + | ARM_FLAG_APCS_32 \
  108. + | ARM_FLAG_APCS_FRAME \
  109. + | ARM_FLAG_MMU_TRAPS )
  110. #ifndef MULTILIB_DEFAULTS
  111. #define MULTILIB_DEFAULTS \
  112. - { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" }
  113. + { "marm", "mlittle-endian", "mapcs-32", "mno-thumb-interwork" }
  114. #endif
  115. /* This is COFF, but prefer stabs. */
  116. diff -urNd gcc-3.4.0-orig/gcc/config/arm/elf.h gcc-3.4.0/gcc/config/arm/elf.h
  117. --- gcc-3.4.0-orig/gcc/config/arm/elf.h 2004-02-24 15:25:22.000000000 +0100
  118. +++ gcc-3.4.0/gcc/config/arm/elf.h 2004-05-01 19:12:16.976486400 +0200
  119. @@ -46,7 +46,9 @@
  120. #ifndef SUBTARGET_ASM_FLOAT_SPEC
  121. #define SUBTARGET_ASM_FLOAT_SPEC "\
  122. -%{mapcs-float:-mfloat} %{msoft-float:-mfpu=softfpa}"
  123. +%{mapcs-float:-mfloat} \
  124. +%{mhard-float:-mfpu=fpa} \
  125. +%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
  126. #endif
  127. #ifndef ASM_SPEC
  128. @@ -106,12 +108,17 @@
  129. #endif
  130. #ifndef TARGET_DEFAULT
  131. -#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
  132. +#define TARGET_DEFAULT \
  133. + ( ARM_FLAG_SOFT_FLOAT \
  134. + | ARM_FLAG_VFP \
  135. + | ARM_FLAG_APCS_32 \
  136. + | ARM_FLAG_APCS_FRAME \
  137. + | ARM_FLAG_MMU_TRAPS )
  138. #endif
  139. #ifndef MULTILIB_DEFAULTS
  140. #define MULTILIB_DEFAULTS \
  141. - { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
  142. + { "marm", "mlittle-endian", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
  143. #endif
  144. #define TARGET_ASM_FILE_START_APP_OFF true
  145. diff -urNd gcc-3.4.0-orig/gcc/config/arm/linux-elf.h gcc-3.4.0/gcc/config/arm/linux-elf.h
  146. --- gcc-3.4.0-orig/gcc/config/arm/linux-elf.h 2004-01-31 07:18:11.000000000 +0100
  147. +++ gcc-3.4.0/gcc/config/arm/linux-elf.h 2004-05-01 19:19:06.935979200 +0200
  148. @@ -30,9 +30,27 @@
  149. /* Do not assume anything about header files. */
  150. #define NO_IMPLICIT_EXTERN_C
  151. -/* Default is to use APCS-32 mode. */
  152. +/*
  153. + * Default is to use APCS-32 mode with soft-vfp.
  154. + * The old Linux default for floats can be achieved with -mhard-float
  155. + * or with the configure --with-float=hard option.
  156. + * If -msoft-float or --with-float=soft is used then software float
  157. + * support will be used just like the default but with the legacy
  158. + * big endian word ordering for double float representation instead.
  159. + */
  160. +
  161. #undef TARGET_DEFAULT
  162. -#define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
  163. +#define TARGET_DEFAULT \
  164. + ( ARM_FLAG_APCS_32 \
  165. + | ARM_FLAG_SOFT_FLOAT \
  166. + | ARM_FLAG_VFP \
  167. + | ARM_FLAG_MMU_TRAPS )
  168. +
  169. +#undef SUBTARGET_EXTRA_ASM_SPEC
  170. +#define SUBTARGET_EXTRA_ASM_SPEC "\
  171. +%{!mcpu=*:-mcpu=xscale} \
  172. +%{mhard-float:-mfpu=fpa} \
  173. +%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
  174. #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
  175. @@ -40,7 +58,7 @@
  176. #undef MULTILIB_DEFAULTS
  177. #define MULTILIB_DEFAULTS \
  178. - { "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
  179. + { "marm", "mlittle-endian", "mapcs-32", "mno-thumb-interwork" }
  180. #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
  181. @@ -55,7 +73,7 @@
  182. %{shared:-lc} \
  183. %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
  184. -#define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
  185. +#define LIBGCC_SPEC "-lgcc"
  186. /* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
  187. the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
  188. diff -urNd gcc-3.4.0-orig/gcc/config/arm/t-linux gcc-3.4.0/gcc/config/arm/t-linux
  189. --- gcc-3.4.0-orig/gcc/config/arm/t-linux 2003-09-20 23:09:07.000000000 +0200
  190. +++ gcc-3.4.0/gcc/config/arm/t-linux 2004-05-01 20:31:59.102846400 +0200
  191. @@ -4,7 +4,10 @@
  192. LIBGCC2_DEBUG_CFLAGS = -g0
  193. LIB1ASMSRC = arm/lib1funcs.asm
  194. -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx
  195. +LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
  196. + _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
  197. + _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
  198. + _fixsfsi _fixunssfsi
  199. # MULTILIB_OPTIONS = mhard-float/msoft-float
  200. # MULTILIB_DIRNAMES = hard-float soft-float
  201. diff -urNd gcc-3.4.0-orig/gcc/config/arm/unknown-elf.h gcc-3.4.0/gcc/config/arm/unknown-elf.h
  202. --- gcc-3.4.0-orig/gcc/config/arm/unknown-elf.h 2004-02-24 15:25:22.000000000 +0100
  203. +++ gcc-3.4.0/gcc/config/arm/unknown-elf.h 2004-05-01 19:09:09.016212800 +0200
  204. @@ -30,7 +30,12 @@
  205. /* Default to using APCS-32 and software floating point. */
  206. #ifndef TARGET_DEFAULT
  207. -#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME | ARM_FLAG_MMU_TRAPS)
  208. +#define TARGET_DEFAULT \
  209. + ( ARM_FLAG_SOFT_FLOAT \
  210. + | ARM_FLAG_VFP \
  211. + | ARM_FLAG_APCS_32 \
  212. + | ARM_FLAG_APCS_FRAME \
  213. + | ARM_FLAG_MMU_TRAPS )
  214. #endif
  215. /* Now we define the strings used to build the spec file. */
  216. diff -urNd gcc-3.4.0-orig/gcc/config/arm/xscale-elf.h gcc-3.4.0/gcc/config/arm/xscale-elf.h
  217. --- gcc-3.4.0-orig/gcc/config/arm/xscale-elf.h 2003-07-02 01:26:43.000000000 +0200
  218. +++ gcc-3.4.0/gcc/config/arm/xscale-elf.h 2004-05-01 20:15:36.620105600 +0200
  219. @@ -49,11 +49,12 @@
  220. endian, regardless of the endian-ness of the memory
  221. system. */
  222. -#define SUBTARGET_EXTRA_ASM_SPEC "%{!mcpu=*:-mcpu=xscale} \
  223. - %{mhard-float:-mfpu=fpa} \
  224. - %{!mhard-float: %{msoft-float:-mfpu=softfpa;:-mfpu=softvfp}}"
  225. +#define SUBTARGET_EXTRA_ASM_SPEC "\
  226. +%{!mcpu=*:-mcpu=xscale} \
  227. +%{mhard-float:-mfpu=fpa} \
  228. +%{!mhard-float: %{msoft-float:-mfpu=softfpa} %{!msoft-float:-mfpu=softvfp}}"
  229. #ifndef MULTILIB_DEFAULTS
  230. #define MULTILIB_DEFAULTS \
  231. - { "mlittle-endian", "mno-thumb-interwork", "marm", "msoft-float" }
  232. + { "mlittle-endian", "mno-thumb-interwork", "marm" }
  233. #endif