This is an archive of the discontinued LLVM Phabricator instance.

[Headers][ARM] Allow `struct _Unwind_Exception` in unwind.h
ClosedPublic

Authored by rprichard on Dec 6 2022, 8:39 PM.

Details

Summary

Use the same approach as used in libunwind/include/unwind_arm_ehabi.h
(D89570) and GCC's unwind-arm-common.h, so that _Unwind_Exception can be
used both with and without the struct tag.

Fixes a build failure in libcxxabi/test/forced_unwind1.pass.cpp.

Diff Detail

Event Timeline

rprichard created this revision.Dec 6 2022, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 8:39 PM
rprichard requested review of this revision.Dec 6 2022, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 8:39 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rprichard added a subscriber: danalbert.

As an aside, it seems interesting that libcxxabi/test/forced_unwind[12].pass.cpp don't compile for ARM EHABI when used with Clang's unwind.h. AFAICT it's been that way for a long time?

$ /x/clang14/bin/clang -target arm-linux-gnueabi /x/llvm-upstream/llvm-project/libcxxabi/test/forced_unwind1.pass.cpp -c -I /x/llvm-upstream/llvm-project/libcxxabi/include
/x/llvm-upstream/llvm-project/libcxxabi/test/forced_unwind1.pass.cpp:42:42: error: typedef '_Unwind_Exception' cannot be referenced with a struct specifier
                                  struct _Unwind_Exception*,
                                         ^
/x/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/14.0.0/include/unwind.h:67:38: note: declared here
typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
                                     ^
/x/llvm-upstream/llvm-project/libcxxabi/test/forced_unwind1.pass.cpp:50:49: error: typedef '_Unwind_Exception' cannot be referenced with a struct specifier
static void cleanup(_Unwind_Reason_Code, struct _Unwind_Exception* exc) {
                                                ^
/x/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/14.0.0/include/unwind.h:67:38: note: declared here
typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
                                     ^
2 errors generated.

Clang uses its own unwind.h rather than libunwind's unwind.h:

$ /x/clang14/bin/clang -target arm-linux-gnueabi /x/llvm-upstream/llvm-project/libcxxabi/test/forced_unwind1.pass.cpp -c -I /x/llvm-upstream/llvm-project/libcxxabi/include -H 2>&1 | grep unwind.h$
. /x/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/14.0.0/include/unwind.h
$ head -15 /x/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/14.0.0/include/unwind.h
/*===---- unwind.h - Stack unwinding ----------------------------------------===
 *
 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 * See https://llvm.org/LICENSE.txt for license information.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 *
 *===-----------------------------------------------------------------------===
 */

/* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/

#ifndef __CLANG_UNWIND_H
#define __CLANG_UNWIND_H

#if defined(__APPLE__) && __has_include_next(<unwind.h>)
danielkiss accepted this revision.Dec 7 2022, 7:54 AM

Wondering if we could deduplicate the headers?

This revision is now accepted and ready to land.Dec 7 2022, 7:54 AM