Pass --as-needed to ld instead of doing ldd/patchelf crimes

This commit is contained in:
наб 2020-10-17 17:24:22 +02:00
parent 0b634d9f2d
commit d0cef4c7f6
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1
4 changed files with 2 additions and 5 deletions

View File

@ -3,7 +3,6 @@ packages:
- clang
- pkg-config
- libtss2-dev
- patchelf
- ronn
tasks:
- get-zfs: |

View File

@ -63,9 +63,8 @@ $(subst $(MANDIR),$(OUTDIR)man/,$(MANPAGE_SOURCES)) : $(MANDIR)index.txt $(MANPA
$(OUTDIR)%$(EXE) : $(subst $(SRCDIR),$(OBJDIR),$(subst .cpp,$(OBJ),$(SRCDIR)bin/%.cpp $(COMMON_SOURCES)))
@mkdir -p $(dir $@)
$(CXX) $(CXXAR) -o$@ $^ $(PIC) $(LDAR)
$(CXX) $(CXXAR) -o$@ $^ $(PIC) -Wl,--as-needed $(LDAR)
$(STRIP) $(STRIPAR) $@
$(LDD) --unused $@ | $(AWK) -F/ 'BEGIN {args = ""} /^\t/ {args = args " --remove-needed " $$NF} END { if(!args) exit; print "$(PATCHELF)" args " $@"}' | sh -x
$(OBJDIR)%$(OBJ) : $(SRCDIR)%.cpp
@mkdir -p $(dir $@)

View File

@ -14,7 +14,7 @@ Plus it's a pretty good annoyed sigh onomatopoeia.
### Building
You'll need `pkg-config`, `patchelf` (or to set `$PATCHELF=true`), `libzfslinux-dev`, `libtss2-dev`<!-- , to initialise the submodules -->, and `make` should hopefully Just Work™ if you have a C++17-capable compiler.
You'll need `pkg-config`, `libzfslinux-dev`, `libtss2-dev`<!-- , to initialise the submodules -->, and `make` should hopefully Just Work™ if you have a C++17-capable compiler.
The output binaries are trimmed of extraneous dependencies, so they're all just libc + libzfs and friends + TPM back-end.
### Installation

View File

@ -55,7 +55,6 @@ LNCMAKEAR := LDFLAGS="$(LNCXXAR)"
LDD ?= ldd
AWK ?= awk
RONN ?= ronn
PATCHELF ?= patchelf
OBJ := .o
CXXAR := -g -O3 -std=c++17 -fno-exceptions -Wall -Wextra $(CXXSPECIFIC) -pipe $(INCCXXAR) $(PIC)
STRIP ?= @echo strip