On 22.1.11 13:58, Kaspar Brand wrote: > On 20.1.11 20:57, Robert Relyea wrote: >> 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.
I just realized that my message from 22 January never made it to Google Groups (most likely due to the presence of attachments), so I'm repeating some information here. [1] The patches previously attached have now been filed as https://bugzilla.mozilla.org/show_bug.cgi?id=645460 (NSS) and https://bugzilla.mozilla.org/show_bug.cgi?id=645459 (NSPR). > 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.) On 24.1.11 22:08, Wan-Teh Chang wrote: > It is also possible to build for two arches in one pass, for example, > gcc -arch i386 -arch x86_64. GCC still compiles each file twice in > this method. This method does have one limitation -- you can't define > an arch-specific macro, such as -Di386 or -DNSS_X64 on the compiler > command line. That's not completely true, as I found out in the meantime. There is a solution to this problem - the "Xarch" option (Apple-specific gcc extension): > -Xarch_arch option > Apply option to the command line for architecture arch. This is > useful for specifying an option that should only apply to one > architecture when building a "universal" binary. (APPLE ONLY) With the following make command, it's actually possible to compile 3-architecture universal binaries in a single step: > make nss_build_all CC="gcc -arch x86_64 -Xarch_x86_64 -DNSS_USE_64\ > -DNSS_X64\ -DNSS_X86_OR_X64 -arch i386 -Xarch_i386 -DNSS_X86\ > -DNSS_X86_OR_X64 -arch ppc" BUILD_OPT=1 NSS_ENABLE_ECC=1 CPU_ARCH=dummy ("CPU_ARCH=dummy" is kind of a hack, currently - it's only purpose is to prevent coreconf from applying the x86 related settings in the ifeq... CPU_ARCH block. It will add -Dppc to the CC command, but this doesn't do any harm, I think. Note that the backslashes are required to protect the following blanks.) This will give you fat binaries in the respective dist/ subtree: > $ file dist/Darwin10.7.0_OPT.OBJ/bin/certutil > dist/Darwin10.7.0_OPT.OBJ/bin/certutil: Mach-O universal binary with 3 > architectures > dist/Darwin10.7.0_OPT.OBJ/bin/certutil (for architecture x86_64): Mach-O > 64-bit executable x86_64 > dist/Darwin10.7.0_OPT.OBJ/bin/certutil (for architecture i386): Mach-O > executable i386 > dist/Darwin10.7.0_OPT.OBJ/bin/certutil (for architecture ppc7400): Mach-O > executable ppc Depending on how important support for universal build is considered, this could be added as a further option to Darwin.mk? Kaspar [1] See http://thread.gmane.org/gmane.comp.mozilla.crypto/15825/focus=15831 for an archived copy -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto