[FFmpeg-devel] PIC and YASM

Reimar Döffinger Reimar.Doeffinger
Tue Nov 10 11:04:15 CET 2009


On Tue, Nov 10, 2009 at 12:21:28AM +0000, M?ns Rullg?rd wrote:
> Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
> 
> > Ok, after all the discussion I have only one change left to suggest
> > (well, actually I had it suggested a few times, but I am not sure if
> > someone is against it or not):
> > Index: configure
> > ===================================================================
> > --- configure   (revision 20491)
> > +++ configure   (working copy)
> > @@ -1876,6 +1876,11 @@
> >
> >  enable $arch $subarch
> >  enabled spic && enable pic
> > +# This is the same check as used in libavutil/internal.h
> 
> Shouldn't that one go away?

Sooner or later I think yes. However I don't like too much doing it in
the same commit.

> > +# to enable RIP-relative addressing for x86_64 inline asm.
> > +# This also makes compilation work out-of-the-box for systems
> > +# like hardened Gentoo where the compiler generates PIC/PIE by default.
> 
> This comment seems like a roundabout way of saying
> # Check if the compiler uses PIC by default

Well, that no longer explains _why_.
Also I'd think you'd have to be a bit dense to not realize it checks for
PIC (btw. it also catches --extra-cflags=-fPIC, though people really
should be using --enable-pic).
I really like to have comments that mention the affected systems because
I have lately spent too much time search which kind of system on earth
some hack is supposed to be for.
So here's one more try, though since you'll be maintaining it in the end
I don't mind going with the one-line comment you gave above instead...

Index: configure
===================================================================
--- configure   (revision 20491)
+++ configure   (working copy)
@@ -1876,6 +1876,12 @@
 
 enable $arch $subarch
 enabled spic && enable pic
+# Check if the compiler uses PIC so that the YASM code is compiled
+# appropriately, fixing static compilation on x86_64 with PIE-enabled
+# compilers (e.g. hardened Gentoo).
+# This is the same check as used in libavutil/internal.h
+# to enable RIP-relative addressing for x86_64 inline asm.
+check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
 
 # OS specific
 case $target_os in
@@ -2236,7 +2242,6 @@
     test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
     case "$objformat" in
         elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
-        macho64)              append YASMFLAGS "-DPIC" ;;
     esac
     disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
 



More information about the ffmpeg-devel mailing list