1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

makefiles: add as-needed only for newer systems

Add some -Wl flags separatly and avoid their duplication.
Also add --as-needed only when system is using 'newer' readline
library - on these older system the usage of '--as-needed'
seems to be causing some hard to solve problem - so avoid it.
This commit is contained in:
Zdenek Kabelac 2024-04-24 11:35:05 +02:00
parent ba13ac8704
commit a8009f72bf
2 changed files with 31 additions and 7 deletions

View File

@ -232,15 +232,26 @@ WFLAGS += -Wsync-nand
endif
endif
ifneq ("@STATIC_LINK@", "yes")
ifeq (,$(findstring relro,$(LDFLAGS)))
ifeq ("@HAVE_FULL_RELRO@", "yes")
LDFLAGS += -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed
ifneq ("@STATIC_LINK@", "yes")
ifeq (,$(findstring -z\,relro,$(LDFLAGS)))
LDFLAGS += -Wl,-z,relro
endif
ifeq (,$(findstring -z\,now,$(LDFLAGS)))
LDFLAGS += -Wl,-z,now
endif
ifeq (,$(findstring -z\,pack-relative-relocs,$(LDFLAGS)))
LDFLAGS += -Wl,-z,pack-relative-relocs
endif
# For systems with old readline library that requires extra libs to link with
# we stick to default --no-as-needed and we avoid adding --as-needed flag
ifneq (2,$(words $(findstring -l,$(READLINE_LIBS))))
ifeq (,$(findstring --as-needed,$(LDFLAGS)))
LDFLAGS += -Wl,--as-needed
endif
endif
ifeq ("@HAVE_PIE@", "yes")
ifeq ("@HAVE_FULL_RELRO@", "yes")
EXTRA_EXEC_CFLAGS += -fPIE
EXTRA_EXEC_LDFLAGS += -pie -fPIE
endif

View File

@ -269,10 +269,22 @@ WFLAGS += -Wsync-nand
endif
endif
ifneq ("@STATIC_LINK@", "yes")
ifeq (,$(findstring relro,$(LDFLAGS)))
ifeq ("@HAVE_FULL_RELRO@", "yes")
LDFLAGS += -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed
ifneq ("@STATIC_LINK@", "yes")
ifeq (,$(findstring -z\,relro,$(LDFLAGS)))
LDFLAGS += -Wl,-z,relro
endif
ifeq (,$(findstring -z\,now,$(LDFLAGS)))
LDFLAGS += -Wl,-z,now
endif
ifeq (,$(findstring -z\,pack-relative-relocs,$(LDFLAGS)))
LDFLAGS += -Wl,-z,pack-relative-relocs
endif
# For systems with old readline library that requires extra libs to link with
# we stick to default --no-as-needed and we avoid adding --as-needed flag
ifneq (2,$(words $(findstring -l,$(READLINE_LIBS))))
ifeq (,$(findstring --as-needed,$(LDFLAGS)))
LDFLAGS += -Wl,--as-needed
endif
endif
@ -281,6 +293,7 @@ ifeq ("@HAVE_PIE@", "yes")
EXTRA_EXEC_LDFLAGS += -pie -fPIE
endif
endif
endif
#WFLAGS += -W -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers
#WFLAGS += -Wsign-compare -Wunused-parameter -Wmissing-field-initializers