On Sun, 5 May 2024 15:39:23 +0200 Fabrice Fontaine <fontaine.fabrice@xxxxxxxxx> wrote: > Do not hardcode -pie and allow the user to drop it (e.g. PIE could be > enabled or disabled by the buildsystem such as buildroot) What about -fPIE? It is in CWFLAGS but it is configurable. Do you specify you own set of CWFLAGS? > > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@xxxxxxxxx> > --- > Makefile | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 7c221a89..a5269687 100644 > --- a/Makefile > +++ b/Makefile > @@ -137,7 +137,11 @@ LDFLAGS = -Wl,-z,now,-z,noexecstack > # If you want a static binary, you might uncomment these > # LDFLAGS += -static > # STRIP = -s > -LDLIBS = -ldl -pie > +LDLIBS = -ldl > +USE_PIE = 1 > +ifdef USE_PIE > +LDLIBS += -pie > +endif > > # To explicitly disable libudev, set -DNO_LIBUDEV in CXFLAGS > ifeq (, $(findstring -DNO_LIBUDEV, $(CXFLAGS))) AFAIK -pie is not library specifier, it is a a gcc linking setting so having it in LDLIBS seems weird to me. What about making LDFLAGS configurable? diff --git a/Makefile b/Makefile index 7c221a891181..adac7905ab57 100644 --- a/Makefile +++ b/Makefile @@ -132,12 +132,12 @@ CFLAGS += -DUSE_PTHREADS MON_LDFLAGS += -pthread endif -LDFLAGS = -Wl,-z,now,-z,noexecstack +LDFLAGS ?= -pie -Wl,-z,now,-z,noexecstack # If you want a static binary, you might uncomment these # LDFLAGS += -static # STRIP = -s -LDLIBS = -ldl -pie +LDLIBS = -ldl It works on my setup however I'm not deeply sure if it is correct. Let me know if it resolves your issue. I would prefer to give possibility to customize LDFLAGS rather than add ifdef to Makefile. Thanks, Mariusz