On 20.1.11 20:57, Robert Relyea wrote:
> On 01/19/2011 10:36 PM, Kaspar Brand wrote:
>> That's certainly doable, but I don't think the NSS build system has
>> support for building universal binaries (you'd have to fiddle with lipo
>> yourself).
> I think it depends on what the Mac compiler kicks out. On Windows or
> Linux, the non-64 bit builds automatically set the compiler to produce
> 32-bit binaries unless the USE_64 is set.

By default, GCC on OS X does not create universal binaries. Starting
with 10.6 (Snow Leopard), the default changed from 32 to 64 bit, though.

> My guess is that no one has set the compiler flags correct for building
> 32-bit binaries on Mac 64.

That's a perfect guess, yes:

> If you have the proper changes to coreconf  to produce 32 bits on a Mac
> 64 bit system, we would certainly be interested.

I think something like the attached patches (not only for NSS, but also
for NSPR) should do the trick. Adding "-arch" options shouldn't hurt for
older OS X versions.

Building universal binaries for NSS in a single step, on the other hand,
is something which doesn't work properly yet. In theory, this could be
achieved by setting CC="gcc -arch x86_64 -arch i386" with the make
command (which instructs GCC to compile separate versions and assemble
them with lipo afterwards), but this will currently fail at drbg.c:

> gcc -arch x86_64 -arch i386 -o 
> Darwin10.6.0_OPT.OBJ/Darwin_SINGLE_SHLIB/drbg.o -c -O2 -fPIC -Di386 -Wall 
> -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK  -DXP_UNIX 
> -DSHLIB_SUFFIX=\"dylib\" -DSHLIB_PREFIX=\"lib\" -DSHLIB_VERSION=\"3\" 
> -DSOFTOKEN_SHLIB_VERSION=\"3\" -DRIJNDAEL_INCLUDE_TABLES -UDEBUG -DNDEBUG 
> -DNSS_ENABLE_ECC -DUSE_UTIL_DIRECTLY -DMP_API_COMPATIBLE 
> -I../../../../dist/Darwin10.6.0_OPT.OBJ/include -I../../../../dist/public/nss 
> -I../../../../dist/private/nss -Impi -Iecl  drbg.c
> drbg.c: In function 'RNG_RandomUpdate':
> drbg.c:516: error: size of array 'arg' is negative

Looking at the current logic in drgb.c

> #if defined(NS_PTR_GT_32) || (defined(NSS_USE_64) && !defined(NS_PTR_LE_32))
>     PR_STATIC_ASSERT(sizeof(size_t) > 4);
> #else
>     PR_STATIC_ASSERT(sizeof(size_t) <= 4);
> #endif

this is due to GCC trying to compile for x86_64, but without NSS_USE_64
being set. Maybe this could be addressed by modifications to drbg.c?
(Adding USE_64=1 to the make command won't help, because that makes the
i386 part fail.)

Kaspar
Index: coreconf/Darwin.mk
===================================================================
RCS file: /cvsroot/mozilla/security/coreconf/Darwin.mk,v
retrieving revision 1.26
diff -u -r1.26 Darwin.mk
--- coreconf/Darwin.mk  29 Jul 2010 00:49:06 -0000      1.26
+++ coreconf/Darwin.mk  22 Jan 2011 11:26:49 -0000
@@ -54,9 +54,11 @@
 CC              += -arch x86_64
 else
 OS_REL_CFLAGS  = -Di386
+CC              += -arch i386
 endif
 else
 OS_REL_CFLAGS  = -Dppc
+CC              += -arch ppc
 endif
 
 ifneq (,$(MACOS_SDK_DIR))
Index: configure.in
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/configure.in,v
retrieving revision 1.295
diff -u -r1.295 configure.in
--- configure.in        21 Jan 2011 23:43:59 -0000      1.295
+++ configure.in        22 Jan 2011 11:25:27 -0000
@@ -1144,10 +1144,12 @@
                 CC="$CC -arch x86_64"
             else        
                 CPU_ARCH=i386
+                CC="$CC -arch i386"
             fi
             ;;
         *)
             CPU_ARCH=ppc
+            CC="$CC -arch ppc"
             ;;
     esac
     DSO_CFLAGS=-fPIC
-- 
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to