`RPATH` uselessly set for statically linked packages
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
Cabal generates RPATH entries for statically linked packages when it shouldn't (similarly to #2625).
For instance, packages not installed in system directories (e.g. in `.cabal-sandbox/lib/x86_64-ghc-7.10.1/xyz_hash` directories) are statically linked but their paths are added to RPATH (not even RUNPATH, which would do less harm).
Example with cabal itself:
```
$ readelf --dynamic `which cabal` | grep rpath
0x000000000000000f (RPATH) Bibliothèque rpath: [/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/Cabal-1.23.0.0-0nYvFmXNshuF4JG4oVlJX6:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/HTTP_2Vqq1ompyRO48NbqBYbd6V:/usr/lib/ghc-7.10.1/array_FaHmcBFfuRM8kmZLEY8D5S:/usr/lib/ghc-7.10.1/base_I5BErHzyOm07EBNpKBEeUv:/usr/lib/ghc-7.10.1/binar_EKE3c9Lmxb3DQpU0fPtru6:/usr/lib/ghc-7.10.1/rts:/usr/lib/ghc-7.10.1/bytes_6vj5EoliHgNHISHCVCb069:/usr/lib/ghc-7.10.1/conta_47ajk3tbda43DFWyeF3oHQ:/usr/lib/ghc-7.10.1/deeps_FpR4obOZALU1lutWnrBldi:/usr/lib/ghc-7.10.1/direc_3TcTyYedch32o1zTH2MR00:/usr/lib/ghc-7.10.1/filep_5HhyRonfEZoDO205Wm9E4h:/usr/lib/ghc-7.10.1/ghcpr_8TmvWUcS1U1IKHT0levwg3:/usr/lib/ghc-7.10.1/integ_2aU3IZNMF9a7mQ0OzsZ0dS:/usr/lib/ghc-7.10.1/site-local/mtl-2.2.1:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/netwo_J41UakcAramENqV1PkXQbp:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/netwo_FwKTIuhRSlXBREfDVMNjfm:/usr/lib/ghc-7.10.1/site-local/old-locale-1.0.0.7:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/oldti_GlWEECeXM2QL4HzHiJM31r:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/parse_7CJEHg5ypvCA0lkQ15UY12:/usr/lib/ghc-7.10.1/prett_7jIfj8VCGFf1WS0tIQ1XSZ:/usr/lib/ghc-7.10.1/proce_0hwN3CTKynhHQqQkChnSdH:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/rando_K0S3f1CZIHiBD3BpVQI8yp:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/stm_6RCmYQcR4fSBJrWsje2iu7:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/text_8rMotiVS8ISBkxP7UzusGU:/usr/lib/ghc-7.10.1/time_Hh2clZW6in4HpYHx5bLtb7:/usr/lib/ghc-7.10.1/trans_ALYlebOVzVI4kxbFX5SGhm:/usr/lib/ghc-7.10.1/unix_G4Yo1pNtYrk8nCq1cx8P9d:/home/hsyl20/.cabal/lib/x86_64-linux-ghc-7.10.1/zlib_60fGkWmfSXJC27YfiVoFdq]
$ ldd `which cabal`
linux-vdso.so.1 (0x00007ffe10778000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f8f01f42000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007f8f01d3a000)
libutil.so.1 => /usr/lib/libutil.so.1 (0x00007f8f01b37000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f8f01933000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f8f01716000)
libgmp.so.10 => /usr/lib/libgmp.so.10 (0x00007f8f01484000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f8f01180000)
libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f8f00f77000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f8f00bd5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8f02158000)
```
Contributor guide
Research direction
Start by reproducing the issue with cabal and inspect the generated executable using readelf and ldd, as shown in the report. Trace how Cabal constructs linker paths for statically linked packages; done means those packages no longer produce unnecessary RPATH entries while required dynamic libraries still resolve correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100