Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Mar 2004 11:11:37 +0200
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        Francois Tigeot <ftigeot@wolfpond.org>
Cc:        David O'Brien <obrien@FreeBSD.org>
Subject:   Re: Cross-compilation to i386
Message-ID:  <20040308091137.GC28067@ip.net.ua>
In-Reply-To: <20040307175852.GD40161@ares.wolfpond.org>
References:  <20040304175103.GA36195@ares.wolfpond.org> <20040307175852.GD40161@ares.wolfpond.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--IDYEmSnFhs3mNXr+
Content-Type: multipart/mixed; boundary="JgQwtEuHJzHdouWu"
Content-Disposition: inline


--JgQwtEuHJzHdouWu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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]
>=20
> On Thu, Mar 04, 2004 at 06:51:03PM +0100, Francois Tigeot wrote:
> >=20
> > 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 :
> >=20
> > time nice make buildworld TARGET_ARCH=3Di386 DESTDIR=3D/itx
> >=20
> > This fails miserably with these error messages :
> >=20
> > cc -Os -march=3Dc3 -fno-strict-aliasing -pipe -I/usr/src/sbin/gbde/../.=
=2E/sys -DRESCUE -Wsystem -headers -Werror -Wall -Wno-format-y2k -W -Wstric=
t-prototypes -Wmissing-prototypes -Wpointer -arith -Wreturn-type -Wcast-qua=
l -Wwrite-strings -Wswitch -Wshadow -Wcast-align  -c /usr/src/sys/crypto/sh=
a2/sha2.c
> > {standard input}: Assembler messages:
> > {standard input}:92: Error: bignum invalid
> > {standard input}:93: Error: bignum invalid
> > [more bignum invalid lines]
>=20
> I've managed to make it work.
>=20
> The 'bignum invalid' error is caused by this type of gcc-generated
> assembly code :
>=20
> 		.quad	8158064640168781261
> 		.quad	-5349999486874862801
>=20
> For some reason, as doesn't like big negative numbers.
>=20
I use the attached patch to cross-compile world for 64-bit machines.

> This is what I did :
>=20
> 	- I installed a stock copy of binutils compiled with
> 	--target=3Di386-freebsd and --enable-64-bit-bfd
>=20
> 	- I initiated a buildworld to populate /usr/obj
>=20
> 	- 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
>=20
> The world and kernel builds then completed succesfully. The new i386 kern=
el
> boots on a diskless machine.
>=20
> 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 ?
>=20
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,
--=20
Ruslan Ermilov
FreeBSD committer
ru@FreeBSD.org

--JgQwtEuHJzHdouWu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="gas.diff"
Content-Transfer-Encoding: quoted-printable

Index: expr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 @@
     }
 }
=20
+/* In:	An expressionP for a bignum to negate.
+
+   Out:	A negated expressionP.
+      && exp->X_add_number =3D=3D 0
+      && symbol_get_value_expression (exp->X_add_symbol)->X_op =3D=3D 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 =3D 1;
+    for (i =3D 0; i < exp->X_add_number; i++)
+    {
+	unsigned long next;
+
+	next =3D (((~(generic_bignum[i] & LITTLENUM_MASK))
+		 & LITTLENUM_MASK)
+		  + carry);
+	generic_bignum[i] =3D next & LITTLENUM_MASK;
+	carry =3D next >> LITTLENUM_NUMBER_OF_BITS;
+    }
+
+    if (carry > 0)
+    {
+	generic_bignum[exp->X_add_number] =3D carry;
+	exp->X_add_number ++;
+    }
+}
+
 /* In:	Input_line_pointer points to 1st char of operand, which may
 	be a space.
=20
@@ -1082,14 +1117,24 @@
 	else if (expressionP->X_op !=3D O_illegal
 		 && expressionP->X_op !=3D O_absent)
 	  {
-	    expressionP->X_add_symbol =3D make_expr_symbol (expressionP);
 	    if (c =3D=3D '-')
-	      expressionP->X_op =3D O_uminus;
+	    {
+		if (expressionP->X_op =3D=3D O_big
+		    && expressionP->X_add_number > 0)
+		  bignum_negate(expressionP);
+		else
+		  expressionP->X_op =3D O_uminus;
+	    }
 	    else if (c =3D=3D '~' || c =3D=3D '"')
 	      expressionP->X_op =3D O_bit_not;
 	    else
 	      expressionP->X_op =3D O_logical_not;
-	    expressionP->X_add_number =3D 0;
+
+	    if (expressionP->X_op !=3D O_big)
+	    {
+	      expressionP->X_add_number =3D 0;
+	      expressionP->X_add_symbol =3D make_expr_symbol (expressionP);
+	    }
 	  }
 	else
 	  as_warn (_("Unary operator %c ignored because bad operand follows"),

--JgQwtEuHJzHdouWu--

--IDYEmSnFhs3mNXr+
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFATDjJUkv4P6juNwoRAts4AKCIiGbzI1Vu7WFJjmPVj2ujE4NvxACfRALH
laKiWJr4hbpPn3+2Uiszskc=
=zeuK
-----END PGP SIGNATURE-----

--IDYEmSnFhs3mNXr+--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040308091137.GC28067>