Cross-compilation to i386

Ruslan Ermilov ru at FreeBSD.org
Mon Mar 8 01:11:46 PST 2004


On Sun, Mar 07, 2004 at 06:58:53PM +0100, Francois Tigeot wrote:
> [copy to -current since it may be of help to other freebsd ports]
> 
> On Thu, Mar 04, 2004 at 06:51:03PM +0100, Francois Tigeot wrote:
> > 
> > I'm currently running a 5.2.1-RELEASE/amd64 system and I'm trying to
> > cross-build an i386 world with the following command :
> > 
> > time nice make buildworld TARGET_ARCH=i386 DESTDIR=/itx
> > 
> > This fails miserably with these error messages :
> > 
> > cc -Os -march=c3 -fno-strict-aliasing -pipe -I/usr/src/sbin/gbde/../../sys -DRESCUE -Wsystem -headers -Werror -Wall -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes -Wpointer -arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align  -c /usr/src/sys/crypto/sha2/sha2.c
> > {standard input}: Assembler messages:
> > {standard input}:92: Error: bignum invalid
> > {standard input}:93: Error: bignum invalid
> > [more bignum invalid lines]
> 
> I've managed to make it work.
> 
> The 'bignum invalid' error is caused by this type of gcc-generated
> assembly code :
> 
> 		.quad	8158064640168781261
> 		.quad	-5349999486874862801
> 
> For some reason, as doesn't like big negative numbers.
> 
I use the attached patch to cross-compile world for 64-bit machines.

> This is what I did :
> 
> 	- I installed a stock copy of binutils compiled with
> 	--target=i386-freebsd and --enable-64-bit-bfd
> 
> 	- I initiated a buildworld to populate /usr/obj
> 
> 	- After the first build failure, I replaced /usr/obj/i386/usr/src/amd64/usr/bin/as
> 	with the new assembler, protecting it by a chflags command
> 
> The world and kernel builds then completed succesfully. The new i386 kernel
> boots on a diskless machine.
> 
> Now, I understand a new binutils import was scheduled before 5.3-RELEASE.
> Is there any reason not to compile it with the '--enable-64-bit-bfd'
> option on 64-bit architectures ?
> 
Nice to hear there are other options that do not require patching.
David, any chance you can investigate the effect of enabling the
--enable-64-bit-bfd knob?


Cheers,
-- 
Ruslan Ermilov
FreeBSD committer
ru at FreeBSD.org
-------------- next part --------------
Index: expr.c
===================================================================
RCS file: /home/ncvs/src/contrib/binutils/gas/expr.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 expr.c
--- expr.c	11 Oct 2002 06:00:09 -0000	1.1.1.7
+++ expr.c	2 Feb 2003 03:06:50 -0000
@@ -37,6 +37,7 @@
 #ifdef BFD64
 static valueT generic_bignum_to_int64 PARAMS ((void));
 #endif
+static void bignum_negate PARAMS ((expressionS *));
 static void integer_constant PARAMS ((int radix, expressionS * expressionP));
 static void mri_char_constant PARAMS ((expressionS *));
 static void current_location PARAMS ((expressionS *));
@@ -756,6 +757,40 @@
     }
 }
 
+/* In:	An expressionP for a bignum to negate.
+
+   Out:	A negated expressionP.
+      && exp->X_add_number == 0
+      && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big
+*/
+
+static void
+bignum_negate (exp)
+     expressionS *exp;
+{
+    int i;
+    unsigned long carry;
+
+    /* Negate the bignum: one's complement each digit and add 1.  */
+    carry = 1;
+    for (i = 0; i < exp->X_add_number; i++)
+    {
+	unsigned long next;
+
+	next = (((~(generic_bignum[i] & LITTLENUM_MASK))
+		 & LITTLENUM_MASK)
+		  + carry);
+	generic_bignum[i] = next & LITTLENUM_MASK;
+	carry = next >> LITTLENUM_NUMBER_OF_BITS;
+    }
+
+    if (carry > 0)
+    {
+	generic_bignum[exp->X_add_number] = carry;
+	exp->X_add_number ++;
+    }
+}
+
 /* In:	Input_line_pointer points to 1st char of operand, which may
 	be a space.
 
@@ -1082,14 +1117,24 @@
 	else if (expressionP->X_op != O_illegal
 		 && expressionP->X_op != O_absent)
 	  {
-	    expressionP->X_add_symbol = make_expr_symbol (expressionP);
 	    if (c == '-')
-	      expressionP->X_op = O_uminus;
+	    {
+		if (expressionP->X_op == O_big
+		    && expressionP->X_add_number > 0)
+		  bignum_negate(expressionP);
+		else
+		  expressionP->X_op = O_uminus;
+	    }
 	    else if (c == '~' || c == '"')
 	      expressionP->X_op = O_bit_not;
 	    else
 	      expressionP->X_op = O_logical_not;
-	    expressionP->X_add_number = 0;
+
+	    if (expressionP->X_op != O_big)
+	    {
+	      expressionP->X_add_number = 0;
+	      expressionP->X_add_symbol = make_expr_symbol (expressionP);
+	    }
 	  }
 	else
 	  as_warn (_("Unary operator %c ignored because bad operand follows"),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20040308/ba4350c2/attachment.bin


More information about the freebsd-amd64 mailing list