Bug 2267690 - clang fails to link libc++ due to missing libunwind
Summary: clang fails to link libc++ due to missing libunwind
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: libcxx
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Nikita Popov
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-03-04 13:24 UTC by Jesus Checa
Modified: 2024-03-04 14:41 UTC (History)
6 users (show)

Fixed In Version: libcxx-18.1.0~rc4-2.fc41
Clone Of:
Environment:
Last Closed: 2024-03-04 14:41:19 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Jesus Checa 2024-03-04 13:24:58 UTC
Trying to link a binary against libc++ will result in a linker error due to missing libunwind:

```
# echo "int main(){return 0 ;}" | clang++ -x c++  --stdlib=libc++ -o test - 
/usr/bin/ld: cannot find -lunwind: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

However libunwind.so.1 is installed and resolved by ldd:
```
# ldd /usr/lib64/libc++.so.1
        linux-vdso64.so.1 (0x000003ffcdbfe000)
        libc++abi.so.1 => /lib64/libc++abi.so.1 (0x000003ffad280000)
        libunwind.so.1 => /lib64/libunwind.so.1 (0x000003ffad200000)
        libc.so.6 => /lib64/libc.so.6 (0x000003ffad000000)
        /lib/ld64.so.1 (0x000003ffad500000)
# rpm -qf /lib64/libunwind.so.1
llvm-libunwind-18.1.0~rc4-1.fc41.s390x
```

If installing `llvm-libunwind-devel` (not installed through deps of libcxx), and we pass the lib directory that it provides, the linkage succeeds:
```
# echo "int main(){return 0 ;}" | clang++ -L/usr/lib64/llvm-unwind -x c++  --stdlib=libc++ -o test - 
# rpm -qf /usr/lib64/llvm-unwind/libunwind.so 
llvm-libunwind-devel-18.1.0~rc4-1.fc41.s390x
```


Reproducible: Always

Steps to Reproduce:
1. dnf install clang libcxx-devel
2. echo "int main(){return 0 ;}" | clang++ -v -x c++  --stdlib=libc++ -o test -

Actual Results:  
/usr/bin/ld: cannot find -lunwind: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Expected Results:  
Link successfully

Reproduced in x86_64 and s390x, not tested in aarch64 and ppc64le.
Installed packages:
# rpm -q clang libcxx llvm-libunwind
clang-18.1.0~rc4-2.fc41.s390x
libcxx-18.1.0~rc4-1.fc41.s390x
llvm-libunwind-18.1.0~rc4-1.fc41.s390x

Comment 1 Nikita Popov 2024-03-04 13:44:49 UTC
I believe that https://src.fedoraproject.org/rpms/libcxx/pull-request/49 should fix this.

Comment 2 Fedora Update System 2024-03-04 14:37:11 UTC
FEDORA-2024-afa3476463 (libcxx-18.1.0~rc4-2.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-afa3476463

Comment 3 Fedora Update System 2024-03-04 14:41:19 UTC
FEDORA-2024-afa3476463 (libcxx-18.1.0~rc4-2.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.