2
1

arm-softfloat.patch.conditional 10 KB

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