kraj / meta-clang

Clang C/C++ cross compiler and runtime for OpenEmbedded/Yocto Project
MIT License
151 stars 192 forks source link

[Aarch64] libunwind is broken with current compiler flags #963

Closed ofacklam closed 4 days ago

ofacklam commented 6 days ago

Describe the bug Applications linked against libunwind as unwind library are failing to handle exceptions properly.

This happens on the kirkstone branch when compiling for an aarch64 target.

This issue is probably related to the following set of changes on the poky kirkstone branch:

To Reproduce

Test program:

#include <iostream>

void do_except() { throw std::runtime_error("Exception world"); }

int main() {
    try {
        do_except();
    } catch (const std::exception &e) {
        std::cout << e.what() << std::endl;
    }

    return 0;
}

Expected behavior Expected to print the exception reason when running this on the target.

Instead, we get the following error message:

libc++abi: terminating with uncaught exception of type std::runtime_error: Exception world

Additional context On our end, we managed to work around the issue by adding this to our local.conf

TUNE_CCARGS:remove:toolchain-clang = "-mbranch-protection=standard"

and this to our meta-environment.bbappend:

TARGET_CLANGCC_ARCH:remove = "-mbranch-protection=standard"
kraj commented 5 days ago

@ofacklam thanks for detailed report, I think you have found a real problem. For now we are stuck with clang-14 on kirkstone, perhaps we will do a another backport but not planned as of now. Could you try backporting

https://github.com/llvm/llvm-project/commit/c218fd3d7d3764eb123c8429bbcd33bacfe2e633

to meta-clang/kirkstone and see if it fixes the problem ?

kraj commented 4 days ago

Hmm, the issue shows up on master/clang-19 as well.