[MPlayer-users] Compiling svn head on 10.8.3 with Xcode 4.6.1 + command line tools

Stephen J. Butler stephen.butler at gmail.com
Sun Mar 17 23:32:27 CET 2013


Setup is $SUBJECT. Some config.mak file URLs at the end. I was doing:

me$ export
PKG_CONFIG_PATH=/sw/lib/freetype219/lib/pkgconfig/:/sw/lib/fontconfig2/lib/pkgconfig/

me$ ./configure --cc=clang --prefix=/sw --mandir=/sw/share/man --disable-tv
--extra-cflags='-I/sw/include' --extra-ldflags='-L/sw/lib' --language=all
--disable-sdl --disable-esd --disable-x11 --disable-xv --disable-openal
--disable-qtx --with-freetype-config=/sw/lib/freetype219/bin/freetype-config

First error I got was:

YASM libavcodec/x86/ac3dsp.o

libavcodec/x86/ac3dsp.asm:215: error: macho: sorry, cannot apply 32 bit
absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem
access, "qword" and "dq _foo" for pointers.

[snip more of the same]


Googling suggests that YASMFLAGS needs "-DPIC" on Darwin. Sure enough, in
config.mak that was not present. I added it, continued compile, and then
get at the end:

clang: warning: argument unused during compilation: '-pie'

ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic)
not allowed in code signed PIE, but used in _filter from
libmpcodecs/vf_fspp.o. To fix this warning, don't compile with
-mdynamic-no-pic or link with -Wl,-no_pie

final section layout:

    __TEXT/__text addr=0x100002000, size=0x0074CC67, fileOffset=0x00002000,
type=1

    __TEXT/__stubs addr=0x10074EC68, size=0x00001068,
fileOffset=0x0074EC68, type=27

    __TEXT/__stub_helper addr=0x10074FCD0, size=0x00001B68,
fileOffset=0x0074FCD0, type=31

    __TEXT/__const addr=0x100751840, size=0x0013190B,
fileOffset=0x00751840, type=0

    __TEXT/__cstring addr=0x100883150, size=0x0007BBD3,
fileOffset=0x00883150, type=12

    __TEXT/__objc_methname addr=0x1008FED23, size=0x00000E64,
fileOffset=0x008FED23, type=13

    __TEXT/__objc_classname addr=0x1008FFB87, size=0x00000051,
fileOffset=0x008FFB87, type=13

    __TEXT/__objc_methtype addr=0x1008FFBD8, size=0x00000602,
fileOffset=0x008FFBD8, type=13

    __TEXT/__ustring addr=0x1009001E0, size=0x00000120,
fileOffset=0x009001E0, type=15

    __TEXT/__unwind_info addr=0x100900300, size=0x00006BF0,
fileOffset=0x00900300, type=21

    __TEXT/__eh_frame addr=0x100906EF0, size=0x000810B8,
fileOffset=0x00906EF0, type=18

    __DATA/__got addr=0x100988000, size=0x00000768, fileOffset=0x00988000,
type=28

    __DATA/__nl_symbol_ptr addr=0x100988768, size=0x00000010,
fileOffset=0x00988768, type=28

    __DATA/__la_symbol_ptr addr=0x100988778, size=0x000015E0,
fileOffset=0x00988778, type=26

    __DATA/__objc_classlist addr=0x100989D58, size=0x00000010,
fileOffset=0x00989D58, type=0

    __DATA/__objc_protolist addr=0x100989D68, size=0x00000018,
fileOffset=0x00989D68, type=0

    __DATA/__objc_imageinfo addr=0x100989D80, size=0x00000008,
fileOffset=0x00989D80, type=0

    __DATA/__objc_const addr=0x100989D88, size=0x00001140,
fileOffset=0x00989D88, type=0

    __DATA/__objc_selrefs addr=0x10098AEC8, size=0x000002C8,
fileOffset=0x0098AEC8, type=14

    __DATA/__objc_msgrefs addr=0x10098B190, size=0x00000050,
fileOffset=0x0098B190, type=0

    __DATA/__objc_protorefs addr=0x10098B1E0, size=0x00000008,
fileOffset=0x0098B1E0, type=0

    __DATA/__objc_classrefs addr=0x10098B1E8, size=0x00000068,
fileOffset=0x0098B1E8, type=22

    __DATA/__objc_superrefs addr=0x10098B250, size=0x00000010,
fileOffset=0x0098B250, type=0

    __DATA/__objc_data addr=0x10098B260, size=0x000000A0,
fileOffset=0x0098B260, type=0

    __DATA/__const addr=0x10098B300, size=0x000E8250,
fileOffset=0x0098B300, type=0

    __DATA/__data addr=0x100A73560, size=0x00028478, fileOffset=0x00A73560,
type=0

    __DATA/__cfstring addr=0x100A9B9D8, size=0x00000300,
fileOffset=0x00A9B9D8, type=16

    __DATA/__objc_ivar addr=0x100A9BCD8, size=0x000000C0,
fileOffset=0x00A9BCD8, type=0

    __DATA/__bss addr=0x100A9BDA0, size=0x004FFE1C, fileOffset=0x00000000,
type=24

    __DATA/__common addr=0x100F9BBC0, size=0x000BD568,
fileOffset=0x00000000, type=24

ld: 32-bit absolute address out of range (0x10075C520 max is 4GB): from
_filter + 0x000023C8 (0x10011D920) to _MM_DESCALE_RND (0x10075C520) in
'_filter' from libmpcodecs/vf_fspp.o for architecture x86_64

Took a lot of head scratching to figure out what exactly the solution here
was. I finally read the man page for ld and see:

     -pie        This makes a special kind of main executable that is
position independent (PIE).  On Mac OS X 10.5 and later, the OS the OS will
                 load a PIE at a random address each time it is executed.
 You cannot create a PIE from .o files compiled with -mdynamic-no-pic.
                 That means the codegen is less optimal, but the address
randomization adds some security. When targeting Mac OS X 10.7 or later PIE
                 is the default for main executables.

Sure enough, in configure there is this line:

if darwin; then
  extra_cflags="-mdynamic-no-pic $extra_cflags"
  _timer=timer-darwin.c
fi

That does't seem right on a post 10.6 system, so I commented the
-mdynamic-no-pic line out. Then I looked at the warning about "clang:
warning: argument unused during compilation: '-pie'". For this version of
clang it should be "-Wl,-pie".

# try to create a relocatable binary by default
echocheck "relocatable binary"
if test $relocatable = "auto" ; then
  if test -n "$ld_static" ; then
    relocatable=no
    res_comment="PIE + static assumed to be broken"
  elif x86_32 && cflag_check -pie ; then
    extra_ldflags="$extra_ldflags -pie"
    relocatable=yes
    res_comment="non-PIC"
  elif x86_64 && cflag_check -fpie -Wl,-pie; then
    extra_ldflags="$extra_ldflags -fpie -Wl,-pie"
    extra_cflags="$extra_cflags -fpie"
    relocatable=yes
    res_comment="fast PIC"

Finally, I don't know why YASMFLAGS et al. didn't get -DPIC. It's because
of this check:

echocheck "PIC"
def_pic='#define CONFIG_PIC 0'
pic=no
cpp_condition_check '' 'defined(__PIC__) || defined(__pic__) ||
defined(PIC)' &&
  pic=yes && extra_cflags="$extra_cflags -DPIC" && def_pic='#define
CONFIG_PIC 1'
echores $pic

It's failing to find PIC support on the Xcode 4.6.1 clang. I commended out
the cpp_condition_check and forced PIC. I did Google some, but couldn't
figure out what the right define is.

Now mplayer compiles and works. Hopefully someone on this list who is
better at configure can generalize what I did to make things work.

config.mak.svn:
config.mak.mine:
configure.patch:

https://uofi.box.com/s/wp7bcew2d5o3yyonzzgi


More information about the MPlayer-users mailing list