[Buildroot] [PATCH v3 2/2] ext-toolchain-wrapper: fix uboot/linux with hardfp

Spenser Gilliland spenser at gillilanding.com
Fri Jul 19 23:31:58 UTC 2013


The linux kernel and uboot specify -msoft-float in order to prevent floating
point code from being generated.  This causes a conflict when -mfloat-abi=hard
or -mfloat-abi options are specified in the wrapper. This patch removes the
-mfloat-abi option from the options generated by the wrapper only when -msoft-float, -mhard-float or -mfloat-abi are specified by the user.

Signed-off-by: Spenser Gilliland <spenser at gillilanding.com>
---
 .../toolchain-external/ext-toolchain-wrapper.c     | 37 +++++++++++++++++++---
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c
index dc473be..3b70610 100644
--- a/toolchain/toolchain-external/ext-toolchain-wrapper.c
+++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c
@@ -8,6 +8,7 @@
  * (C) 2011 Peter Korsgaard <jacmet at sunsite.dk>
  * (C) 2011 Daniel Nyström <daniel.nystrom at timeterminal.se>
  * (C) 2012 Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>
+ * (C) 2013 Spenser Gilliland <spenser at gillilanding.com>
  *
  * This file is licensed under the terms of the GNU General Public License
  * version 2.  This program is licensed "as is" without any warranty of any
@@ -38,9 +39,6 @@ static char *predef_args[] = {
 #ifdef BR_ABI
 	"-mabi=" BR_ABI,
 #endif
-#ifdef BR_FLOAT_ABI
-	"-mfloat-abi=" BR_FLOAT_ABI,
-#endif
 #ifdef BR_FPU
 	"-mfpu=" BR_FPU,
 #endif
@@ -61,6 +59,25 @@ static char *predef_args[] = {
 #endif
 };
 
+/* use_default_float_abi - determine if the user is trying to override the
+ * floating point abi.
+ *  return 0 if the user is attempting to override the float abi
+ *  otherwise return 1
+ */
+int use_default_float_abi(int argc, char **argv) {
+	int arg;
+	for (arg = 1; arg < argc; arg++) {
+		if (strncmp(argv[arg],"-mfloat-abi=", sizeof("-mfloat-abi=")/sizeof(char)-1) == 0 ||
+			strcmp(argv[arg],"-msoft-float") == 0 ||
+			strcmp(argv[arg],"-mhard-float") == 0 ) {
+			printf("DETECTED FLOAT ABI\n");
+			return 0;
+		}
+	}
+	
+	return 1;
+}
+
 int main(int argc, char **argv)
 {
 	char **args, **cur;
@@ -68,6 +85,11 @@ int main(int argc, char **argv)
 	char *progpath = argv[0];
 	char *basename;
 	int ret, i, count = 0;
+	int set_float_abi = 0;
+
+#ifdef BR_FLOAT_ABI
+	set_float_abi = use_default_float_abi(argc,argv);
+#endif
 
 	/* Calculate the relative paths */
 	basename = strrchr(progpath, '/');
@@ -119,7 +141,8 @@ int main(int argc, char **argv)
 		return 3;
 	}
 
-	cur = args = malloc(sizeof(predef_args) + (sizeof(char *) * argc));
+	cur = args = malloc(sizeof(predef_args) +
+		(sizeof(char *) * (argc + set_float_abi)));
 	if (args == NULL) {
 		perror(__FILE__ ": malloc");
 		return 2;
@@ -129,6 +152,12 @@ int main(int argc, char **argv)
 	memcpy(cur, predef_args, sizeof(predef_args));
 	cur += sizeof(predef_args) / sizeof(predef_args[0]);
 
+	/* add float abi if neccessary */
+	if (set_float_abi) {
+		*cur = "-mfloat-abi=" BR_FLOAT_ABI;
+		cur++;
+	}
+
 	/* append forward args */
 	memcpy(cur, &argv[1], sizeof(char *) * (argc - 1));
 	cur += argc - 1;
-- 
1.8.1.2




More information about the buildroot mailing list