Flac uses assembly code to improve performance for ix86 processors. This works under Linux, BSD and Windows, but not Mac OS X, because there is no support for creating Mach-O format binaries (the native binary format for OS X systems). The attached patch provides the necessary support to create ASM-optimised Mach-O binaries.
This wasn't created by me but was sent to the audacity-devel list (I think by Matthew Sachs <[EMAIL PROTECTED]>) as a patch against 1.1.2, then tweaked to apply to the 1.2.1 release. There is also a problem with text relocation's in the assembly binary, which require an executable stack on ELF system. Gentoo has a patch to resolve the problem on their build which seems to work. I can't see anything relevant in the Sourceforge tracker on these two issues, but I may be wrong. Richard Ash
Index: lib-src/libflac/src/libFLAC/ia32/nasm.h =================================================================== RCS file: /cvsroot/audacity/lib-src/libflac/src/libFLAC/ia32/nasm.h,v retrieving revision 1.2 diff -u -r1.2 nasm.h --- lib-src/libflac/src/libFLAC/ia32/nasm.h 13 Feb 2006 11:36:45 -0000 1.2 +++ lib-src/libflac/src/libFLAC/ia32/nasm.h 12 Jan 2008 17:26:55 -0000 @@ -49,6 +49,11 @@ %idefine code_section section .text align=16 %idefine data_section section .data align=32 %idefine bss_section section .bss align=32 +%elifdef OBJ_FORMAT_macho + %define FLAC__PUBLIC_NEEDS_UNDERSCORE + %idefine code_section section .text + %idefine data_section section .data + %idefine bss_section section .bss %else %error unsupported object format! %endif
diff -urp flac-1.2.1-old/src/libFLAC/ia32/bitreader_asm.nasm flac-1.2.1/src/libFLAC/ia32/bitreader_asm.nasm --- flac-1.2.1-old/src/libFLAC/ia32/bitreader_asm.nasm 2007-03-30 02:54:53.000000000 +0200 +++ flac-1.2.1/src/libFLAC/ia32/bitreader_asm.nasm 2007-09-27 21:39:45.000000000 +0200 @@ -140,8 +140,13 @@ cident FLAC__bitreader_read_rice_signed_ %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE mov edi, _FLAC__crc16_table %else +%ifdef OBJ_FORMAT_elf + mov edi, [esp + 16] ; saved ebx (GOT base) + lea edi, [edi + FLAC__crc16_table wrt ..gotoff] +%else mov edi, FLAC__crc16_table %endif +%endif ;; eax (ax) crc a.k.a. br->read_crc ;; ebx (bl) intermediate result index into FLAC__crc16_table[] ;; ecx br->crc16_align @@ -216,8 +221,13 @@ cident FLAC__bitreader_read_rice_signed_ %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE mov edi, _FLAC__crc16_table %else +%ifdef OBJ_FORMAT_elf + mov edi, [esp + 16] ; saved ebx (GOT base) + lea edi, [edi + FLAC__crc16_table wrt ..gotoff] +%else mov edi, FLAC__crc16_table %endif +%endif ;; eax (ax) crc a.k.a. br->read_crc ;; ebx (bl) intermediate result index into FLAC__crc16_table[] ;; ecx br->crc16_align @@ -315,8 +325,13 @@ cident FLAC__bitreader_read_rice_signed_ %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE call _bitreader_read_from_client_ %else +%ifdef OBJ_FORMAT_elf + mov ebx, [esp + 20] ; saved ebx (GOT base) + call bitreader_read_from_client_ wrt ..plt +%else call bitreader_read_from_client_ %endif +%endif pop edx ; /* discard, unused */ pop ecx ; /* restore */ mov esi, [ebp + 16] ; cwords = br->consumed_words; @@ -362,13 +377,20 @@ cident FLAC__bitreader_read_rice_signed_ mov [ebp + 16], esi ; br->consumed_words = cwords; mov [ebp + 20], ecx ; br->consumed_bits = cbits; push ecx ; /* save */ + push ebx ; /* save */ push ebp ; /* push br argument */ %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE call _bitreader_read_from_client_ %else +%ifdef OBJ_FORMAT_elf + mov ebx, [esp + 24] ; saved ebx (GOT base) + call bitreader_read_from_client_ wrt ..plt +%else call bitreader_read_from_client_ %endif +%endif pop edx ; /* discard, unused */ + pop ebx ; /* restore */ pop ecx ; /* restore */ mov esi, [ebp + 16] ; cwords = br->consumed_words; ; ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits; @@ -437,8 +459,13 @@ cident FLAC__bitreader_read_rice_signed_ %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE mov edi, _FLAC__crc16_table %else +%ifdef OBJ_FORMAT_elf + mov edi, [esp + 24] ; saved ebx (GOT base) + lea edi, [edi + FLAC__crc16_table wrt ..gotoff] +%else mov edi, FLAC__crc16_table %endif +%endif ;; eax (ax) crc a.k.a. br->read_crc ;; ebx (bl) intermediate result index into FLAC__crc16_table[] ;; ecx br->crc16_align
_______________________________________________ Flac-dev mailing list Flac-dev@xiph.org http://lists.xiph.org/mailman/listinfo/flac-dev