I was looking at how this might be rolled in as something like a 
pseudo-architecture (e.g. darwin-universal-x86+x64+ppc64) to roll in the 
various flags for different universal targets, and I think there may be some 
significant side-effects. I haven't dug in to compare how it changes the 
operations under Makefile control, but eyeballing it tells me it breaks 
subsequent references to CPU_ARCH outside of coreconf, mostly the stuff in the 
freebl Makefile that decide when to use assembler code, which I assume to exist 
for things like on-chip crypto support such as AES-NI. These branches look to 
be OS_TARGET-specific at the top level and currently absent any provision for 
Darwin, but what I'd ask is, if you wanted to be able to extend these 
optimisations to the platform, how would you do it with a non-iterative build?

As for how to roll the below into Darwin.mk, I haven't tested it, but I'd 
suggest adding pseudo-platform support to Darwin.mk before or after the block 
that current starts at line 52:

ifneq (,$(findstring darwin-universal,${CPU_ARCH}))
$(warning "${CPU_ARCH} is a universal target with experimental support. 
Cross-check settings against new Makefiles, and do not use with a non-Apple 
gcc. Some architectures may no longer be supported by later Apple releases of 
gcc.")
UNIVERSAL_ARCHES = x64 x86 ppc64
ARCHES = $(subst +, ,$(patsubst darwin-universal-%,%,${CPU_ARCH}))
UNKNOWN_ARCHES = $(filter-out ${UNIV_ARCHES},${ARCHES})
ifneq (,${UNKNOWN_ARCHES})
$(error "Do not know how to make universal arches ${UNKNOWN_ARCHES}")
ifneq (,$(filter x86,${ARCHES}))
CC += -arch i386
OS_REL_CFLAGS += -Xarch_i386 -DNSS_X86 \
        -Xarch_i386 -DNSS_X86_OR_X64
endif
ifneq (,$(filter x64,${ARCHES}))
CC += -arch x86_64
OS_REL_CFLAGS += -Xarch_x86_64 -DNSS_USE_64 \
        -Xarch_x86_64 -DNSS_X64 \
        -Xarch_X86_OR_X64 -DNSS_X86_OR_X64
endif
ifneq (,$(filter ppc64,${ARCHES}))
CC += -arch ppc64
OS_REL_CFLAGS += -Xarch_ppc64 -Dppc
endif
endif

On 27 Mar 2011, at 09:11, Kaspar Brand wrote:

> 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

Attachment: PGP.sig
Description: This is a digitally signed message part

-- 
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to