[PATCH][cxxabi] ARM EHABI zero-cost exception handling for libc++abi

Jonathan Roelofs jonathan at codesourcery.com
Wed Apr 16 10:05:41 PDT 2014


Logan,

I've been building it for bare-metal ARM using clang (with patches that haven't 
been upstreamed yet), but the process should be similar for an arm-linux-gnu 
target, assuming you want to make a static library out of it:

Compile all the *.cpp files with:
clang++ -target $TRIPLE --sysroot=/path/to/your/targets/sysroot -funwind-tables 
-std=c++11 -stdlib=libc++ -fstrict-aliasing -Wstrict-aliasing=2 
-Wsign-conversion -Wshadow -Wconversion -Wunused-variable 
-Wmissing-field-initializers -Wchar-subscripts -Wmismatched-tags 
-Wmissing-braces -Wshorten-64-to-32 -Wsign-compare -Wstrict-aliasing=2 
-Wstrict-overflow=4 -Wunused-parameter -Wnewline-eof

And similarly, all the *.c files with:
clang -target $TRIPLE --sysroot=/path/to/your/targets/sysroot -funwind-tables 
-std=c11 -fstrict-aliasing -Wstrict-aliasing=2 -Wsign-conversion -Wshadow 
-Wconversion -Wunused-variable -Wmissing-field-initializers -Wchar-subscripts 
-Wmismatched-tags -Wmissing-braces -Wshorten-64-to-32 -Wsign-compare 
-Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wnewline-eof

On bare-metal, I also build the unwinder's *.c,*.cpp, and *.S files, but on 
linux you'll want to skip that step.

Finally, archive all the *.o files into a static libarary with ar, and ranlib. 
At link time, you'll need to pull in -lgcc_s (which is for the unwinder).

I can share my modifications to the buildit & testit scripts if you think they 
would be useful to you.


As for __USING_SJLJ_EXCEPTIONS__, I checked and it is indeed a compiler builtin 
for both clang and gcc. __ARM_EABI_UNWINDER__ does not seem to be, and I don't 
see anything nearby to where I found the SJLJ one that would indicate what we 
want.  I think the right thing to check for here is:
   #if __arm__ && !defined(__USING_SJLJ_EXCEPTIONS__)


Cheers,
Jon

On 4/16/14, 5:11 AM, Logan Chien wrote:
> Hi all,
>
> Sorry for the typo.
>
> I was trying to build and test libc++abi from [1] but failed.  I have tried to
> build the library by compiling all the *.cpp and *.c, but it seems not working.
> May you provide some instructions to build it?
>
> BTW, I agree with Jonathan.  It seems that __ARM_EABI_UNWINDER__ is not
> pre-defined.
> I am not sure for __USING_SJLJ_EXCEPTIONS__ at the moment.  I will check out ASAP.
>
> Logan
>
> [1]:
> https://github.com/awong-dev/ndk/tree/use-libc%2B%2Babi/sources/cxx-stl/llvm-libc%2B%2Babi/libcxxabi
> [2] http://www.sourceware.org/ml/libc-alpha/2004-02/msg00138.html
>
>
> On Wed, Apr 16, 2014 at 7:58 PM, Logan Chien <tzuhsiang.chien at gmail.com
> <mailto:tzuhsiang.chien at gmail.com>> wrote:
>
>     Hi Jonathan and Nick,
>
>     I was trying to build libc++abi from repository but failed.  May you provide
>     some instruction to cross compile libc++abi for ARM Linux?  Thanks.
>
>     Logan
>
>
>     On Tue, Apr 15, 2014 at 5:23 AM, Jonathan Roelofs <jonathan at codesourcery.com
>     <mailto:jonathan at codesourcery.com>> wrote:
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-commits mailing list