git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Makefile: set USE_PIC on Linux x86_64 for linking with Git.pm

From
Sergey Vlasov <vsu@altlinux.ru>
Date
Jun 29, 2006, 09:04 UTC
Message-ID
<20060629130400.c280de67.vsu@altlinux.ru>
In-Reply-To
<7vbqsdynvu.fsf@assigned-by-dhcp.cox.net>
On Wed, 28 Jun 2006 14:24:37 -0700 Junio C Hamano wrote:
Show 5 quoted lines
> Marco Roeland <marco.roeland@xs4all.nl> writes:
> 
> > Even for Linux someone mentioned that probably i386 is the exception in
> > _not_ needing the -fPIC linkage. It might even be specific to the Perl
> > "xs" implementation specifics?

In general, -fPIC is required when building shared libraries. On some systems (e.g., Linux/i386) you can get away without -fPIC, but with a penalty on memory use and load time: non-PIC code will need relocations, therefore its pages will no longer be shared between different processes, and relocations will be performed immediately after loading the shared library.

Show 14 quoted lines
> USE_PIC is for pleasing Perly git and nothing else right now.
> 
> > So I should have added "Works for me (TM)"! ;-)
> 
> That would have been more explicit way to tell me that this is a
> partial solution and I should solicit help from people on other
> platforms.
> 
> By the way, I had an impression that compiling things with -fPIC
> when not necessary was generally a bad idea from performance
> point of view.  If that is the case we might want to compile,
> under USE_PIC, everything with -fPIC in a separate area to
> compile and link with Git.xs, without affecting the C-only core
> code.

This is exactly what libtool does (if both static and shared libraries are compiled, each file is compiled twice - once with -fPIC -DPIC, and once without these options).

But I suspect that even libtool won't help with Perl anyway, unless we create a proper libgit.so and then link our Perl extension with it.

Show 13 quoted lines
> I suspect this would largely depend on the architecture.  I ran
> git-fsck-objects compiled with and without -fPIC (after "make
> clean" to rebuild everything) on a fully packed copy of the
> linux-2.6 repository on my x86_64 box, and did not see
> meaningful differences:
> 
> : gitster; /usr/bin/time ../git.junio/git-fsck-objects-no-pic --full
> 109.71user 5.01system 1:54.89elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (14major+1834967minor)pagefaults 0swaps
> : gitster; /usr/bin/time ../git.junio/git-fsck-objects-with-pic --full
> 109.05user 4.97system 1:54.08elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (0major+1834981minor)pagefaults 0swaps
> : gitster;

This is because most of time is spent inside SHA-1 and zlib routines, which are the same in these cases. Using mozilla-sha1 code might show some difference.

And the effect of -fPIC on x86_64 is smaller than on i386, because x86_64 has 2x more registers than i386, therefore loss of one register is less noticeable.

Previous: Junio C HamanoNext: Josef Weidendorfer
Message 12 of 13 in “Makefile: set USE_PIC on Linux x86_64 for linking with Git.pm”
  1. Makefile: set USE_PIC on Linux x86_64 for linking with Git.pmMarco Roeland, Jun 28, 2006
  2. Junio C HamanoJun 28, 2006
  3. Junio C HamanoJun 28, 2006
  4. Marco RoelandJun 28, 2006
  5. Makefile: set USE_PIC on Linux x86_64 for linking with Git.xsMarco Roeland, Jun 28, 2006
  6. Pavel RoskinJun 28, 2006
  7. Jakub NarebskiJun 29, 2006
  8. Pavel RoskinJun 30, 2006
  9. Jakub NarebskiJun 30, 2006
  10. Marco RoelandJun 28, 2006
  11. Junio C HamanoJun 28, 2006
  12. Sergey VlasovJun 29, 2006
  13. Josef WeidendorferJun 29, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.