diff options
author | Paul Mundt <lethal@linux-sh.org> | 2008-10-28 04:19:35 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-10-28 04:19:35 -0400 |
commit | 8a2fd5f3ab6535035f08d7d0fda90abe73c6d282 (patch) | |
tree | 167165f7a6e27d0033787d83fbdc448d49527ad8 /arch | |
parent | 49fdf6785fd660e18a1eb4588928f47e9fa29a9a (diff) |
sh: Fix FPU tuning on toolchains with mismatched multilib targets.
Presently there is very little standing in the way of using an SH-4
toolchain for building an SH-2 kernel, and vice versa. Binutils itself
has no limitations whatsoever and supports explicit ISA hinting, which
we already use with varying degrees of success today.
This leaves GCC as the odd one out, due to a rather dubious policy
decision by the GCC folks to not include all of the CPU family variants
in the default list of multilib targets in GCC4. Despite best efforts to
the contrary, libgcc itself already contains awareness of the various CPU
types and remains generally usable, allowing it to safely be referenced
even on a mismatched target (and indeed, explicit ISA tuning by binutils
keeps us honest in terms of ensuring that we do not link incompatible
objects in).
In order to support this, a couple of changes had to be made. Firstly,
the introduction of MAYBE_DECLARE_EXPORT(), which provides a __weak
extern reference for libgcc resident routines when finer-grained
-m<cpu-family> based tuning is not supported by the toolchain. This
fixes up the __sdivsi3_i4i and __udivsi3_i4i references when dealing
with SH-2 kernels linked with an SH-4 libgcc. Secondly, in case where we
are unable to find a suitable match for CPU family tuning but still
have a toolchain that defaults to FP instruction generation, a suitable
nofpu target must be selected. This is accomplished by selecting the
first nofpu multilib target supported by the toolchain, which is
also necessary for selecting the proper libgcc to link against.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sh/Makefile | 16 | ||||
-rw-r--r-- | arch/sh/kernel/sh_ksyms_32.c | 11 |
2 files changed, 22 insertions, 5 deletions
diff --git a/arch/sh/Makefile b/arch/sh/Makefile index 1f409bf81809..3b2d8e232240 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile | |||
@@ -38,6 +38,22 @@ cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \ | |||
38 | $(call cc-option,-m4a-nofpu,) | 38 | $(call cc-option,-m4a-nofpu,) |
39 | cflags-$(CONFIG_CPU_SH5) := $(call cc-option,-m5-32media-nofpu,) | 39 | cflags-$(CONFIG_CPU_SH5) := $(call cc-option,-m5-32media-nofpu,) |
40 | 40 | ||
41 | ifeq ($(cflags-y),) | ||
42 | # | ||
43 | # In the case where we are stuck with a compiler that has been uselessly | ||
44 | # restricted to a particular ISA, a favourite default of newer GCCs when | ||
45 | # extensive multilib targets are not provided, ensure we get the best fit | ||
46 | # regarding FP generation. This is necessary to avoid references to FP | ||
47 | # variants in libgcc where integer variants exist, which otherwise result | ||
48 | # in link errors. This is intentionally stupid (albeit many orders of | ||
49 | # magnitude less than GCC's default behaviour), as anything with a large | ||
50 | # number of multilib targets better have been built correctly for | ||
51 | # the target in mind. | ||
52 | # | ||
53 | cflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \ | ||
54 | grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//') | ||
55 | endif | ||
56 | |||
41 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb | 57 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb |
42 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml | 58 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml |
43 | 59 | ||
diff --git a/arch/sh/kernel/sh_ksyms_32.c b/arch/sh/kernel/sh_ksyms_32.c index d366a7443720..d998f4c795be 100644 --- a/arch/sh/kernel/sh_ksyms_32.c +++ b/arch/sh/kernel/sh_ksyms_32.c | |||
@@ -50,7 +50,10 @@ EXPORT_SYMBOL(__udelay); | |||
50 | EXPORT_SYMBOL(__ndelay); | 50 | EXPORT_SYMBOL(__ndelay); |
51 | EXPORT_SYMBOL(__const_udelay); | 51 | EXPORT_SYMBOL(__const_udelay); |
52 | 52 | ||
53 | #define DECLARE_EXPORT(name) extern void name(void);EXPORT_SYMBOL(name) | 53 | #define DECLARE_EXPORT(name) \ |
54 | extern void name(void);EXPORT_SYMBOL(name) | ||
55 | #define MAYBE_DECLARE_EXPORT(name) \ | ||
56 | extern void name(void) __weak;EXPORT_SYMBOL(name) | ||
54 | 57 | ||
55 | /* These symbols are generated by the compiler itself */ | 58 | /* These symbols are generated by the compiler itself */ |
56 | DECLARE_EXPORT(__udivsi3); | 59 | DECLARE_EXPORT(__udivsi3); |
@@ -109,10 +112,8 @@ DECLARE_EXPORT(__movmemSI12_i4); | |||
109 | * compiler which include backported patches. | 112 | * compiler which include backported patches. |
110 | */ | 113 | */ |
111 | DECLARE_EXPORT(__udiv_qrnnd_16); | 114 | DECLARE_EXPORT(__udiv_qrnnd_16); |
112 | #if !defined(CONFIG_CPU_SH2) | 115 | MAYBE_DECLARE_EXPORT(__sdivsi3_i4i); |
113 | DECLARE_EXPORT(__sdivsi3_i4i); | 116 | MAYBE_DECLARE_EXPORT(__udivsi3_i4i); |
114 | DECLARE_EXPORT(__udivsi3_i4i); | ||
115 | #endif | ||
116 | #endif | 117 | #endif |
117 | #else /* GCC 3.x */ | 118 | #else /* GCC 3.x */ |
118 | DECLARE_EXPORT(__movstr_i4_even); | 119 | DECLARE_EXPORT(__movstr_i4_even); |