This is an archive of the discontinued LLVM Phabricator instance.

unwind: Fix libc++abi and libgcc build.
ClosedPublic

Authored by logan on Jul 14 2015, 12:06 PM.

Details

Summary

To build libc++abi without libunwind, we should make sure that all
function calls to _Unwind_{Get,Set}{GR,IP}() are inlined as function
calls to _Unwind_VRS_{Get,Set}(). Otherwise, libc++abi.so will fail to
link since libgcc does not provide these symbol at all.

The commit reverts the changes in r228903, which breaks libc++abi/libgcc
build since then.

Diff Detail

Event Timeline

logan updated this revision to Diff 29695.Jul 14 2015, 12:06 PM
logan retitled this revision from to unwind: Fix libc++abi and libgcc build..
logan updated this object.
logan added reviewers: rengolin, joerg, danalbert, asl, compnerd.
logan added a subscriber: cfe-commits.
asl added inline comments.Jul 14 2015, 12:25 PM
include/unwind.h
224

Why can't we simply make them static functions of UnwindLevel1.c for EHABI case?

logan added inline comments.Jul 14 2015, 5:40 PM
include/unwind.h
224

They can't be static functions of UnwindLevel1.c because they will be called from the other source code (e.g. libc++abi calls these functions.) If they are declared as static functions in UnwindLevel1.c, then the other source code can't access these functions.

We can't declare these functions as extern and define these functions in UnwindLevel1.c either. If we do so, the source code including this header and using these functions will be compiled to object files with external symbols (undefined references) to these functions. This means that these symbols should be available to the linkers. However, libgcc does not provide these symbols. If we are building libc++abi with libgcc without libunwinder, then we will encounter the following link error:

libcxxabi/src/cxa_personality.cpp:(.text+0x3c): undefined reference to `_Unwind_SetGR'
(... and etc ...)

This is the reason why these functions must be inlined. AFAICT, both the unwind.h from gcc or clang (lib/Header/unwind.h) are following the same practice.

asl added inline comments.Jul 15 2015, 8:28 AM
include/unwind.h
224

I see. My biggest concern is the use of LIBCXXABI_ARM_EHABI define. We need to resolve this beforehand, because currently we're having a cyclic dependency between libunwind and libcxxabi via cxxabi_config.h. I'd simply fold it inside libwunwind (or introduce libunwind_config.h)

logan added inline comments.Jul 15 2015, 9:42 AM
include/unwind.h
224

OK. I think I will simply copy the ifdefs from __cxxabi_config.h since they are simple. Will update the patch soon.

My long term plan is to merge this unwind.h with the one in the clang repository. And then, update libc++abi so that we can use the unwind.h from the compiler (both clang and gcc) directly.

compnerd edited edge metadata.Jul 15 2015, 9:55 AM

Im not sure that this is the best way to handle this. Currently, use of the savannah unwind would provide these interfaces on ARM. I realize that the alternate implementation of unwind is not EHABI compliant, but that does make this slightly challenging. Perhaps we could just provide a macro-like function which duplicates the interfaces, but bridges to _Unwind_VRS_{G,S}et. (And, since Im sure you will ask, yes, I do have code which relies on these interfaces).

include/unwind.h
224

The long term plan sounds great. I think that is definitely the right direction.

logan updated this revision to Diff 29802.Jul 15 2015, 11:16 AM
logan edited edge metadata.

Address asl's comment.

@compnerd:

For your use case, please have a look at the upcoming D11191. I believe it should work for you. Although I am really hesitating, I have just confirmed that Savannah libunwind[1] is working on ARM. So I am not strongly oppose to the idea now.

[1] http://savannah.nongnu.org/projects/libunwind/

Yeah, I think that approach would suffice.

logan updated this revision to Diff 30299.Jul 21 2015, 4:56 PM

Stash the changes from D11191.

logan added a comment.Jul 21 2015, 4:59 PM

Hi,

Please have a look on the revised version. This should address all of the comments at the moment. I really wish to commit this change before 3.7 release. Thanks.

Logan

compnerd accepted this revision.Jul 22 2015, 8:59 AM
compnerd edited edge metadata.

I think that this allows us to be compatible with both libgcc and the Savannah libunwind. Thanks for all the revisions related to this.

This revision is now accepted and ready to land.Jul 22 2015, 8:59 AM
logan closed this revision.Jul 23 2015, 5:17 PM

Thanks for reviewing. Committed as rL243073.