llvm / llvm/llvm-project

libunwind compile error on x32 using clang/clang++

Open
#192,777 0 comments 0 reactions 0 assignees View on GitHub
build-problem libunwind
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When built with clang libunwind fails with:
```
/mnt/vmtmp/una/repo/llvm/libunwind/src/DwarfParser.hpp:480:8: error: non-constant-expression cannot be narrowed from type 'link_reg_t' (aka 'unsigned long long') to 'pint_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
480 | upToPC - fdeInfo.pcStart}};
| ^~~~~~~~~~~~~~~~~~~~~~~~
/mnt/vmtmp/una/repo/llvm/libunwind/src/DwarfInstructions.hpp:220:33: note: in instantiation of function template specialization 'libunwind::CFI_Parser::parseFDEInstructions' requested here
220 | if (CFI_Parser::template parseFDEInstructions(
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/UnwindCursor.hpp:1079:37: note: in instantiation of member function 'libunwind::DwarfInstructions::stepWithDwarf' requested here
1079 | return DwarfInstructions::stepWithDwarf(
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/UnwindCursor.hpp:3279:20: note: in instantiation of member function 'libunwind::UnwindCursor::stepWithDwarfFDE' requested here
3279 | result = this->stepWithDwarfFDE(stage2);
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/UnwindCursor.hpp:1384:21: note: in instantiation of member function 'libunwind::UnwindCursor::step' requested here
1384 | UnwindCursor::UnwindCursor(unw_context_t *context, A &as)
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor::UnwindCursor' requested here
87 | UnwindCursor(
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/DwarfParser.hpp:480:8: note: insert an explicit cast to silence this issue
480 | upToPC - fdeInfo.pcStart}};
| ^~~~~~~~~~~~~~~~~~~~~~~~
| static_cast( )
In file included from /mnt/vmtmp/una/repo/llvm/libunwind/src/libunwind.cpp:30:
/mnt/vmtmp/una/repo/llvm/libunwind/src/AddressSpace.hpp:669:46: error: non-constant-expression cannot be narrowed from type 'link_reg_t' (aka 'unsigned long long') to 'uintptr_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
669 | dl_iterate_cb_data cb_data = {this, &info, targetAddr};
| ^~~~~~~~~~
/mnt/vmtmp/una/repo/llvm/libunwind/src/UnwindCursor.hpp:2779:30: note: in instantiation of function template specialization 'libunwind::LocalAddressSpace::findUnwindSections' requested here
2779 | if (_addressSpace.template findUnwindSections(pc, sects)) {
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/UnwindCursor.hpp:1384:21: note: in instantiation of member function 'libunwind::UnwindCursor::setInfoBasedOnIPRegister' requested here
1384 | UnwindCursor::UnwindCursor(unw_context_t *context, A &as)
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/libunwind.cpp:87:7: note: in instantiation of member function 'libunwind::UnwindCursor::UnwindCursor' requested here
87 | UnwindCursor(
| ^
/mnt/vmtmp/una/repo/llvm/libunwind/src/AddressSpace.hpp:669:46: note: insert an explicit cast to silence this issue
669 | dl_iterate_cb_data cb_data = {this, &info, targetAddr};
| ^~~~~~~~~~
| static_cast( )
2 errors generated.

```
if you clone https://github.com/daunabomba/una.git and then
> git remote rename origin una
> una/una.py --int --build
will reproduce the error

Contributor guide

Open the contributing guide

Research direction

Reproduce the x32 clang/clang++ build with `una/una.py --int --build`. Start with the reported initializers in `libunwind/src/DwarfParser.hpp` and `libunwind/src/AddressSpace.hpp`, then inspect the related instantiations in `DwarfInstructions.hpp`, `UnwindCursor.hpp`, and `libunwind.cpp`. Done means libunwind builds successfully for x32 with clang without the reported narrowing errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.