[opus] Building Opus (git master) ARM assembly for iOS

Martin Storsjö martin at martin.st
Tue Mar 11 04:56:21 PDT 2014


On Mon, 10 Mar 2014, Justin Ruggles wrote:

> On 03/10/2014 06:56 PM, Ralph Giles wrote:
>> On 2014-03-10 2:47 PM, Jonathan Lennox wrote:
>>> If I add --disable-asm to the build, it builds correctly.
>>>
>>> Does anyone have experience with Apple assembler directives to know
>>> what’s the best way to fix this?  I assume the Perl script to generate
>>> the assembler file is going to need to be modified somehow.
>>
>> Yep, https://git.xiph.org/?p=opus.git;a=blob;f=celt/arm/arm2gnu.pl will
>> need modifying to output something Apple's ancient gas fork understands,
>> or perhaps more portably yasm syntax.
>>
>> I just found https://github.com/mansr/gas-preprocessor. Does that work
>> on the opus code?
>
> This one is maintained.
>
> https://git.libav.org/?p=gas-preprocessor.git;a=summary

The latest upstream gas-preprocessor doesn't have everything that is 
needed for building opus.

The main thing that needs to be fixed is adding underscore prefixes to 
public symbols. This is relatively easy to handle if all such symbols are 
wrapped up in assembler macros, but as far as I know, the opus arm 
assembly doesn't really use any assembler macros.

The second detail is skipping a few assembler directives that the apple 
assembler doesn't know or care about - this is pretty simple to handle.

I actually looked into this a few weeks ago but I haven't finished 
upstreaming the effort yet - mainly because I've found two different ways 
of achieving this and haven't decided on which solution is the best.

gas-preprocessor can take care of most of the assembler directives that 
apple doesn't support (it can also handle evaluating gas macros and a 
whole lot of other things that the opus arm assembly doesn't require). It 
doesn't support automatically adding the underscore prefix to public 
symbols though (doing that in the generic case requires a bit of 
heuristics), and additionally lacks support for the .include directives.

I did try hacking all of this together though, it's available in 
https://github.com/mstorsjo/gas-preprocessor/commits/addprefix if anyone 
wants to try it, but it's a pile of hacks^Wheuristics.

To build using this script, I've set CCAS="gas-preprocessor.pl -add-prefix 
-- xcrun clang -c" before running configure.

The other approach, as was suggested in the original post, would be to 
modify arm2gnu.pl to support converting to the format required by apple's 
tools. To try out this approach, have a look at 
https://github.com/mstorsjo/opus/commit/arm2gnu-apple. When building with 
this solution, you don't need to set CCAS separately at all.

This solution still needs to have some subset of the hacks, to identify 
branch instructions that refer to public symbols and add prefixes there. A 
third solution is to avoid doing jumps to labels that are public symbols 
(by adding a separate label for the start of functions) - then the 
modifications to arm2gnu.pl are quite minimal: 
https://github.com/mstorsjo/opus/commit/arm2gnu-apple2^ 
https://github.com/mstorsjo/opus/commit/arm2gnu-apple2

I think this last approach probably is the most acceptable of them - what 
do others think?

// Martin


More information about the opus mailing list