How can I use libunwind on `aarch64-unknown-none` targets?

Hello!

I’ve been looking at LLVM_in_a_Bare_Metal_Environment.pdf

What is the C-library that it refers to in the above picture? libc? Can I use libunwind in an environment that doesn’t support libc? How would I go about doing this?

I tried the -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_SHARED=OFF -DLIBUNWIND_IS_BAREMETAL=ON -DLIBUNWIND_ENABLE_THREADS=OFF -DLIBUNWIND_USE_COMPILER_RT=ON but it complains that pint_t is 32bit when it’s supposed to be 64bit in width which is confusing. Here’s the exact reproduction

cmake ./libunwind \
  -DCMAKE_AR=$LLVM_HOME/bin/llvm-ar \
  -DCMAKE_NM=$LLVM_HOME/bin/llvm-nm \
  -DCMAKE_RANLIB=$LLVM_HOME/bin/llvm-ranlib \
  -DCMAKE_ASM_COMPILER=$LLVM_HOME/bin/clang \
  -DCMAKE_ASM_COMPILER_TARGET="aarch64-unknown-none" \
  -DCMAKE_C_COMPILER=$LLVM_HOME/bin/clang \
  -DCMAKE_C_COMPILER_TARGET="aarch64-unknown-none" \
  -DCMAKE_CXX_COMPILER=$LLVM_HOME/bin/clang++ \
  -DCMAKE_CXX_COMPILER_TARGET="aarch64-unknown-none" \
  -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
  -DLIBUNWIND_ENABLE_SHARED=OFF \
  -DLIBUNWIND_IS_BAREMETAL=ON \
  -DLIBUNWIND_ENABLE_THREADS=OFF \
  -DLIBUNWIND_USE_COMPILER_RT=ON \
  -B build

make

This results in:

[ 14%] Building CXX object src/CMakeFiles/unwind_static_objects.dir/libunwind.cpp.o
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:30:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:23:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/EHHeaderParser.hpp:17:
/mnt/workspace/build/llvm-project/libunwind/src/DwarfParser.hpp:561:37: error: use of undeclared identifier 'alloca'; did you mean 'malloc'?
            (PrologInfoStackEntry *)_LIBUNWIND_REMEMBER_ALLOC(
                                    ^
/mnt/workspace/build/llvm-project/libunwind/src/config.h:128:42: note: expanded from macro '_LIBUNWIND_REMEMBER_ALLOC'
#define _LIBUNWIND_REMEMBER_ALLOC(_size) alloca(_size)
                                         ^
/usr/include/stdlib.h:553:14: note: 'malloc' declared here
extern void *malloc (size_t __size) __THROW __attribute_malloc__
             ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:30:
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:161:18: warning: cast to 'void *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
    memcpy(&val, (void *)addr, sizeof(val));
                 ^~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:166:18: warning: cast to 'void *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
    memcpy(&val, (void *)addr, sizeof(val));
                 ^~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:171:18: warning: cast to 'void *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
    memcpy(&val, (void *)addr, sizeof(val));
                 ^~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:176:18: warning: cast to 'void *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
    memcpy(&val, (void *)addr, sizeof(val));
                 ^~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:181:18: warning: cast to 'void *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
    memcpy(&val, (void *)addr, sizeof(val));
                 ^~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:186:18: warning: cast to 'void *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
    memcpy(&val, (void *)addr, sizeof(val));
                 ^~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:206:10: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uintptr_t' (aka 'unsigned int') [-Wshorten-64-to-32]
  return get64(addr);
  ~~~~~~ ^~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:222:22: warning: cast to 'unsigned char *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-pointer-cast]
  const uint8_t *p = (uint8_t *)addr;
                     ^~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:223:25: warning: cast to 'unsigned char *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-pointer-cast]
  const uint8_t *pend = (uint8_t *)end;
                        ^~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:241:10: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
  addr = (pint_t) p;
         ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:247:22: warning: cast to 'unsigned char *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-pointer-cast]
  const uint8_t *p = (uint8_t *)addr;
                     ^~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:248:25: warning: cast to 'unsigned char *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-pointer-cast]
  const uint8_t *pend = (uint8_t *)end;
                        ^~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:262:10: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
  addr = (pint_t) p;
         ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:270:22: warning: cast to 'unsigned char *' from smaller integer type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') [-Wint-to-pointer-cast]
  const uint8_t *p = (uint8_t *)addr;
                     ^~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:278:12: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
    addr = (pint_t) p;
           ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:286:12: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
    addr = (pint_t) p;
           ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:291:12: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
    addr = (pint_t) p;
           ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:296:12: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
    addr = (pint_t) p;
           ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:305:12: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
    addr = (pint_t) p;
           ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:311:12: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
    addr = (pint_t) p;
           ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:316:12: error: cast from pointer to smaller type 'libunwind::LocalAddressSpace::pint_t' (aka 'unsigned int') loses information
    addr = (pint_t) p;
           ^~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:504:31: error: cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information
  info.dwarf_section =        (uintptr_t)(&__eh_frame_start);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:506:30: warning: cast to 'void *' from smaller integer type 'uintptr_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
                             (void *)info.dwarf_section, (void *)info.dwarf_section_length);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/config.h:211:29: note: expanded from macro '_LIBUNWIND_TRACE_UNWINDING'
        _LIBUNWIND_LOG(msg, __VA_ARGS__);                                      \
                            ^~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/config.h:168:43: note: expanded from macro '_LIBUNWIND_LOG'
  fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
                                          ^~~~~~~~~~~
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:30:
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:508:37: error: cast from pointer to smaller type 'uintptr_t' (aka 'unsigned int') loses information
  info.dwarf_index_section =        (uintptr_t)(&__eh_frame_hdr_start);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:511:30: warning: cast to 'void *' from smaller integer type 'uintptr_t' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
                             (void *)info.dwarf_index_section, (void *)info.dwarf_index_section_length);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/config.h:211:29: note: expanded from macro '_LIBUNWIND_TRACE_UNWINDING'
        _LIBUNWIND_LOG(msg, __VA_ARGS__);                                      \
                            ^~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/config.h:168:43: note: expanded from macro '_LIBUNWIND_LOG'
  fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
                                          ^~~~~~~~~~~
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:30:
/mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:486:58: warning: unused parameter 'targetAddr' [-Wunused-parameter]
inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
                                                         ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:31:
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:1307:3: error: static assertion failed due to requirement 'check_fit<libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>, unw_cursor_t>::does_fit': UnwindCursor<> does not fit in unw_cursor_t
  static_assert((check_fit<UnwindCursor<A, R>, unw_cursor_t>::does_fit),
  ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::UnwindCursor' requested here
      UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
      ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:31:
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:1330:21: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unw_word_t' (aka 'unsigned int') [-Wshorten-64-to-32]
  return _registers.getRegister(regNum);
  ~~~~~~ ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:919:23: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::getReg' requested here
                      UnwindCursor(unw_context_t *context, A &as);
                      ^
/mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::UnwindCursor' requested here
      UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
      ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:31:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:44:
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:230:44: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
                               : [Ptr] "r"(p)
                                           ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:1003:37: note: in instantiation of member function 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::stepWithDwarf' requested here
    return DwarfInstructions<A, R>::stepWithDwarf(
                                    ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:2835:20: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::stepWithDwarfFDE' requested here
    result = this->stepWithDwarfFDE(stage2);
                   ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:919:23: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step' requested here
                      UnwindCursor(unw_context_t *context, A &as);
                      ^
/mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::UnwindCursor' requested here
      UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
      ^
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:228:37: note: use constraint modifier "w"
                               "stg %[Ptr], [%[Ptr]]\n"
                                    ^~~~~~
                                    %w[Ptr]
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:230:44: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
                               : [Ptr] "r"(p)
                                           ^
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:228:46: note: use constraint modifier "w"
                               "stg %[Ptr], [%[Ptr]]\n"
                                             ^~~~~~
                                             %w[Ptr]
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:210:31: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
        pint_t sp = registers.getSP();
               ~~   ~~~~~~~~~~^~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:277:39: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
            returnAddress = registers.getRegister(cieInfo.returnAddressRegister);
                          ~ ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:305:25: warning: implicit conversion loses integer precision: 'unsigned long long' to 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
        returnAddress = x17;
                      ~ ^~~
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:566:15: warning: cast to 'unsigned int *' from smaller integer type 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::pint_t' (aka 'unsigned int') [-Wint-to-pointer-cast]
      *sp = *((pint_t*)value);
              ^~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:71:14: note: in instantiation of member function 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::evaluateExpression' requested here
      return evaluateExpression((pint_t)prolog.cfaExpression, addressSpace, 
             ^
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:202:20: note: in instantiation of member function 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::getCFA' requested here
      pint_t cfa = getCFA(addressSpace, prolog, registers);
                   ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:1003:37: note: in instantiation of member function 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::stepWithDwarf' requested here
    return DwarfInstructions<A, R>::stepWithDwarf(
                                    ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:2835:20: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::stepWithDwarfFDE' requested here
    result = this->stepWithDwarfFDE(stage2);
                   ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:919:23: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step' requested here
                      UnwindCursor(unw_context_t *context, A &as);
                      ^
/mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::UnwindCursor' requested here
      UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
      ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:31:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:44:
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:810:27: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
      *(++sp) = registers.getRegister((int)reg);
              ~ ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:817:27: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
      *(++sp) = registers.getRegister((int)reg);
              ~ ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:111:22: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
    return registers.getRegister((int)savedReg.value);
    ~~~~~~ ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/DwarfInstructions.hpp:266:29: note: in instantiation of member function 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::getSavedRegister' requested here
            returnAddress = getSavedRegister(addressSpace, registers, cfa,
                            ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:1003:37: note: in instantiation of member function 'libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::stepWithDwarf' requested here
    return DwarfInstructions<A, R>::stepWithDwarf(
                                    ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:2835:20: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::stepWithDwarfFDE' requested here
    result = this->stepWithDwarfFDE(stage2);
                   ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:919:23: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::step' requested here
                      UnwindCursor(unw_context_t *context, A &as);
                      ^
/mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::UnwindCursor' requested here
      UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
      ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:30:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:23:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/EHHeaderParser.hpp:17:
/mnt/workspace/build/llvm-project/libunwind/src/DwarfParser.hpp:241:53: warning: implicit conversion loses integer precision: 'unsigned long' to 'const libunwind::CFI_Parser<libunwind::LocalAddressSpace>::pint_t' (aka 'const unsigned int') [-Wshorten-64-to-32]
                                  : (ehSectionStart + sectionLength);
                                     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:1644:31: note: in instantiation of member function 'libunwind::CFI_Parser<libunwind::LocalAddressSpace>::findFDE' requested here
    foundFDE = CFI_Parser<A>::findFDE(_addressSpace, pc, sects.dwarf_section,
                              ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:2579:17: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::getInfoFromDwarfSection' requested here
      if (this->getInfoFromDwarfSection(pc, sects)) {
                ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:919:23: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::setInfoBasedOnIPRegister' requested here
                      UnwindCursor(unw_context_t *context, A &as);
                      ^
/mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::UnwindCursor' requested here
      UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
      ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:30:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:23:
/mnt/workspace/build/llvm-project/libunwind/src/EHHeaderParser.hpp:121:32: warning: implicit conversion loses integer precision: 'unsigned long' to 'libunwind::EHHeaderParser<libunwind::LocalAddressSpace>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
    tableEntry = hdrInfo.table + mid * tableEntrySize;
               ~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:1651:35: note: in instantiation of member function 'libunwind::EHHeaderParser<libunwind::LocalAddressSpace>::findFDE' requested here
    foundFDE = EHHeaderParser<A>::findFDE(
                                  ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:2579:17: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::getInfoFromDwarfSection' requested here
      if (this->getInfoFromDwarfSection(pc, sects)) {
                ^
/mnt/workspace/build/llvm-project/libunwind/src/UnwindCursor.hpp:919:23: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::setInfoBasedOnIPRegister' requested here
                      UnwindCursor(unw_context_t *context, A &as);
                      ^
/mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_arm64>::UnwindCursor' requested here
      UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
      ^
In file included from /mnt/workspace/build/llvm-project/libunwind/src/libunwind.cpp:30:
In file included from /mnt/workspace/build/llvm-project/libunwind/src/AddressSpace.hpp:23:
/mnt/workspace/build/llvm-project/libunwind/src/EHHeaderParser.hpp:136:30: warning: implicit conversion loses integer precision: 'unsigned long' to 'libunwind::EHHeaderParser<libunwind::LocalAddressSpace>::pint_t' (aka 'unsigned int') [-Wshorten-64-to-32]
  tableEntry = hdrInfo.table + low * tableEntrySize;
             ~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
28 warnings and 13 errors generated.
make[2]: *** [src/CMakeFiles/unwind_static_objects.dir/build.make:76: src/CMakeFiles/unwind_static_objects.dir/libunwind.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:200: src/CMakeFiles/unwind_static_objects.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I see it mentions that it can run on bare metal ARM64 but I’m not sure if I’m understanding this right. I have an OS that can run ELF binaries but doesn’t have it’s own libc and I can customize the linker script to keep all symbols that the unwinder needs but I’m just not particularly sure how to get this up and running and what the dependencies of libunwind is.

Hi,
did you manage to solve it? I am having the same problem…