Date: Sat, 21 Feb 2004 12:23:43 -0800 From: Peter Wemm <peter@wemm.org> To: freebsd-amd64@freebsd.org Subject: Re: CFLAGS+= -fPIC per default? Message-ID: <200402211223.43589.peter@wemm.org> In-Reply-To: <BD6DAE5F-64A6-11D8-ACAA-000A95BAD088@raisdorf.net> References: <BD6DAE5F-64A6-11D8-ACAA-000A95BAD088@raisdorf.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 21 February 2004 11:47 am, Hendrik Scholz wrote: > Adding CFLAGS= -fPIC to /etc/make.conf may be a local solution but > are there any drawbacks by adding something like > .if ${ARCH} == "amd64" > CFLAGS+= -fPIC > .endif > > to ports/Mk/bsd.port.mk? No.. please don't. Although the AMD64 platform supports PIC addressing modes directly, it is still a penalty. (Although thankfully, its nowhere near as expensive as it is on i386!) For example, in libc when built in PIC mode: #ifdef PIC movq PIC_GOT(HIDENAME(curbrk)),%rdx movq (%rdx),%rax #else movq HIDENAME(curbrk)(%rip),%rax #endif The problem is that we can't be sure that everything will be in +/- 31 bit offsets of each other. This means that PIC objects have to do indirect memory references that aren't required in no-pic mode. I386 also loses a general purpose register (%ebx) which is why -fpic is more expensive there. But even though we don't lose a register, its still a cost because of the extra global-offset-table memory references. Footnote: you just made me wonder about some of these ifdefs.. We shouldn't need them for intra-object references like this. I'll have to go and look again. -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200402211223.43589.peter>