Unfortunately, the port dns/void-zones-tools is not ready for the global setting WITH_PIE=YES cc binutils.o store.o hosts2zones.o -fstack-protector-strong -pie -Wl,-zrelro -o hosts2zones ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
Created attachment 246279 [details] Fix build with WITH_PIE=YES Thank you for bringing this issue to my attention. Can you test the attached patch and check if it fixes the problem? I have tested it locally and it builds and seems to work both with and without WITH_PIE.
(In reply to Vidar Karlsen from comment #1) Yes, the solution is right, but I couldn't apply your patch, so I changed only the appropriate line in Makefile and it worked. Thanks for the fix.
This patch doesn't look right as it now unconditionally adds -fpic, even if we create a position-dependent binary. I don't get why you had -fno-pic in there in the first place. If you just remove that flag, I suspect it'll just work as expected. Failing that, please change the port so -fpic is only passed if WITH_PIE is set. E.g. you can do CFLAGS+= ${WITH_PIE:D-fpic} in the port Makefile.
(In reply to Robert Clausecker from comment #3) > This patch doesn't look right as it now unconditionally adds -fpic, even if we create a position-dependent binary. That is a very good point. > I don't get why you had -fno-pic in there in the first place. If you just remove that flag, I suspect it'll just work as expected. I don't know either. It's coming from upstream, and I don't know enough about compilers and their flags to put forth any meaningful argument about it. Removing -fno-pic almost works, but the upstream Makefile does: CFLAGS = $(CDEFS) overwriting anything coming from the ports framework. Changing that to += does seem to do the trick. I'll upload a new patch.
Created attachment 246424 [details] Updated patch Does this one work as intended?
Patch looks reasonable. @Marek, does it solve your issue?
The updated patch works fine for me. Thank you!
Great, will commit next weekend until there's an objection from the maintainer.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=11a7b638a6c63425070e60ddcad9ebb27fad88c9 commit 11a7b638a6c63425070e60ddcad9ebb27fad88c9 Author: Vidar Karlsen <vidar@karlsen.tech> AuthorDate: 2023-11-13 21:21:58 +0000 Commit: Robert Clausecker <fuz@FreeBSD.org> CommitDate: 2023-11-24 06:12:30 +0000 dns/void-zones-tools: Fix build with WITH_PIE=YES Patch CFLAGS from being overridden and remove -fno-pic to facilitate building with WITH_PIE=yes PR: 275039 Reported by: Marek Zarychta dns/void-zones-tools/Makefile | 1 + dns/void-zones-tools/files/patch-Makefile | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)
A commit in branch 2023Q4 references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=690ea2e84f43fa7f8c055557c6f00238c7e4c2a8 commit 690ea2e84f43fa7f8c055557c6f00238c7e4c2a8 Author: Vidar Karlsen <vidar@karlsen.tech> AuthorDate: 2023-11-13 21:21:58 +0000 Commit: Robert Clausecker <fuz@FreeBSD.org> CommitDate: 2023-11-24 06:16:16 +0000 dns/void-zones-tools: Fix build with WITH_PIE=YES Patch CFLAGS from being overridden and remove -fno-pic to facilitate building with WITH_PIE=yes PR: 275039 Reported by: Marek Zarychta (cherry picked from commit 11a7b638a6c63425070e60ddcad9ebb27fad88c9) dns/void-zones-tools/Makefile | 1 + dns/void-zones-tools/files/patch-Makefile | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)
Thank you for your contribution.