Fix -flto[=full] -Wl,--as-needed not working on sid anymore(?)

This commit is contained in:
наб 2021-11-28 18:06:37 +01:00
parent 503ac72235
commit 5d7ebf3d19
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1
2 changed files with 12 additions and 10 deletions

View File

@ -23,7 +23,7 @@
include configMakefile
LDDLLS := rt tspi crypto $(OS_LD_LIBS)
LDDLLS := rt tspi crypto
PKGS := libzfs libzfs_core tss2-esys tss2-rc
LDAR := $(LNCXXAR) $(foreach l,,-L$(BLDDIR)$(l)) $(foreach dll,$(LDDLLS),-l$(dll)) $(shell pkg-config --libs $(PKGS))
INCAR := $(foreach l,$(foreach l,,$(l)/include),-isystemext/$(l)) $(foreach l,,-isystem$(BLDDIR)$(l)/include) $(shell pkg-config --cflags $(PKGS))
@ -55,7 +55,7 @@ shellcheck : i-t dracut
clean :
rm -rf $(OUTDIR)
build : $(subst $(SRCDIR)bin/,$(OUTDIR),$(subst .cpp,$(EXE),$(BINARY_SOURCES)))
build : $(subst $(SRCDIR)bin/,$(OUTDIR),$(subst .cpp,,$(BINARY_SOURCES)))
manpages : $(patsubst $(MANDIR)%.pp,$(OUTDIR)man/%,$(MANPAGE_SOURCES))
htmlpages : $(patsubst $(MANDIR)%.pp,$(OUTDIR)man/%.html,$(MANPAGE_SOURCES)) $(OUTDIR)man/style.css
i-t : $(OUTDIR)initramfs-tools/usr/share/initramfs-tools/hooks/tzpfms $(OUTDIR)initramfs-tools/usr/share/tzpfms/initramfs-tools-zfs-patch.sh
@ -90,12 +90,15 @@ $(OUTDIR)man/style.css : man/style.css
@mkdir -p $(dir $@)
cp $^ $@
$(BLDDIR)libtzpfms.a : $(subst $(SRCDIR),$(OBJDIR),$(subst .cpp,.o,$(COMMON_SOURCES)))
$(AR) crs $@ $^
$(OUTDIR)%$(EXE) : $(subst $(SRCDIR),$(OBJDIR),$(subst .cpp,$(OBJ),$(SRCDIR)bin/%.cpp $(COMMON_SOURCES)))
$(OUTDIR)% : $(OBJDIR)bin/%.o $(BLDDIR)libtzpfms.a
@mkdir -p $(dir $@)
$(CXX) $(CXXAR) -o$@ $^ -Wl,--as-needed $(LDAR)
$(CXX) $(CXXAR) -Wl,--as-needed -o$@ $^ $(LDAR)
$(OBJDIR)%$(OBJ) : $(SRCDIR)%.cpp
$(OBJDIR)%.o : $(SRCDIR)%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXAR) $(INCAR) $(VERAR) $(DEF_TPH) -c -o$@ $^

View File

@ -20,14 +20,14 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
EXE :=
DLL := .so
OS_LD_LIBS :=
CXXVER := $(shell $(CXX) --version)
ifneq "$(findstring clang,$(CXXVER))" ""
# GCC doesn't have this granularity
CXXSPECIFIC := -flto=full -pedantic -Wno-gnu-statement-expression -Wno-gnu-include-next -Wno-gnu-conditional-omitted-operand -Wno-c++20-designator
ifeq "$(AR)" "ar"
# Need this because -flto=full produces objects FSF ranlib (ar s) can't index
override AR := llvm-ar
endif
else
CXXSPECIFIC := -flto
endif
@ -55,7 +55,6 @@ AWK ?= awk
SED ?= sed
MANDOC ?= mandoc
SHELLCHECK ?= shellcheck
OBJ := .o
CXXAR := -g -O3 -std=c++17 -fno-exceptions -Wall -Wextra $(CXXSPECIFIC) -pipe $(INCCXXAR) -fPIC
OUTDIR := out/