[Bug 275018] ports-mgmt/pkg: building with PIE and RELRO is broken when CFLAGS are set

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 10 Nov 2023 21:13:54 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275018

            Bug ID: 275018
           Summary: ports-mgmt/pkg: building with PIE and RELRO is broken
                    when CFLAGS are set
           Product: Ports & Packages
           Version: Latest
          Hardware: arm64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: pkg@FreeBSD.org
          Reporter: zarychtam@plan-b.pwste.edu.pl
          Assignee: pkg@FreeBSD.org
             Flags: maintainer-feedback?(pkg@FreeBSD.org)

Since WITH_PIE and WITH_RELRO were introduced to ports, it was impossible to
build ports-mgmt/pkg when CFLAGS were also set. To reproduce try to build
ports-mgmt/pkg with these settings in make.conf:

CFLAGS=-O2 -pipe -fno-strict-aliasing 
WITH_PIE=YES 
WITH_RELRO=YES

it looks like setting CFLAGS is killing -fPIC at some point which results in:

ld: error: relocation R_X86_64_32 cannot be used against local symbol;
recompile with -fPIC

I initially believed it was only a flaw, but I was encouraged to submit a PR
about it.

-- 
You are receiving this mail because:
You are the assignee for the bug.