Bug 214047

Summary: libcap 2.52: Clang fails to build shared objects as runnable binaries
Product: Tools Reporter: Johan Herland (jherland)
Component: libcapAssignee: Andrew G. Morgan (morgan)
Status: RESOLVED CODE_FIX    
Severity: normal CC: morgan
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: N/A Subsystem:
Regression: No Bisected commit-id:

Description Johan Herland 2021-08-11 18:47:20 UTC
When upgrading libcap from 2.51 to 2.52, our clang build started complaining with:

```
/toolchain/host-llvm-10.0.1-x86_64-linux-1/bin/objcopy --dump-section .interp=/dev/stdout empty > loader.txt
/toolchain/host-llvm-10.0.1-x86_64-linux-1/bin/objcopy: error: 'empty': Permission denied
```

This problem seems to be fixed by changing this rule in `libcap/Makefile`:

```
loader.txt: empty
       $(OBJCOPY) --dump-section .interp=/dev/stdout $< > $@
```

to this:

```
loader.txt: empty
       $(OBJCOPY) --dump-section .interp=$@ $<
```

However, that only uncovers the next build error:

```
clang-10: error: unsupported option '--entry=__so_start'
```

which I suspect is related to this section in the same `libcap/Makefile`:

```
# The linker magic needed to build a dynamic library as independently
# executable
MAGIC=--entry=__so_start
```

Any ideas on how to fix this for clang? Or how to easily disable this feature when building with clang?
Comment 1 Andrew G. Morgan 2021-08-11 20:02:49 UTC
Thanks for this bug report.

To date, I've never actually looked into supporting clang. However, this bug suggests it was mostly working before this latest release, so I'll set up a testing environment and try to figure out how to make it work.
Comment 2 Andrew G. Morgan 2021-08-12 01:43:17 UTC
While I figure out how to set up clang builds, you might like to try replacing '--entry=__so_start' with '-Wl,-e,__so_start'.
Comment 3 Andrew G. Morgan 2021-08-12 03:30:31 UTC
Please see this commit:

https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=6dea1813f269f9c03cea226fffdd75670c70ea01

Reopen if that doesn't address your needs.
Comment 4 Johan Herland 2021-08-12 09:20:29 UTC
Can confirm that your commit resolves this issue for us as well.

Appreciate the quick turnaround, and thanks for your time!