mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.6k stars 1.63k forks source link

Meson passes incorrect rpath to linker on macOS #4339

Open ePirat opened 6 years ago

ePirat commented 6 years ago

On macOS, when building dav1d with meson 0.47.2, with gcc-mp-8 as compiler, it passes the wrong rpath to the linker:

[77/78] gcc-mp-8  -o tools/dav1d 'tools/tools@@dav1d@exe/dav1d.c.o' 'tools/tools@@dav1d@exe/dav1d_cli_parse.c.o' 'tools/tools@@dav1d@exe/input_input.c.o' 'tools/tools@@dav1d@exe/input_ivf.c.o' 'tools/tools@@dav1d@exe/output_md5.c.o' 'tools/tools@@dav1d@exe/output_output.c.o' 'tools/tools@@dav1d@exe/output_y4m2.c.o' 'tools/tools@@dav1d@exe/output_yuv.c.o' -I/opt/local/include -L/opt/local/lib -Wl,-dead_strip_dylibs src/libdav1d.0.dylib -pthread '-Wl,-rpath,$ORIGIN/../src'  
[78/78] gcc-mp-8  -o tests/checkasm 'tests/tests@@checkasm@exe/checkasm.obj' 'tests/tests@@checkasm@exe/cpuid.obj' 'tests/tests@@checkasm@exe/itx.obj' 'tests/tests@@checkasm@exe/loopfilter.obj' 'tests/tests@@checkasm@exe/mc.obj' 'tests/tests@@checkasm@exe/checkasm_checkasm.c.o' 'tests/tests@@checkasm_bitdepth_8@sta/checkasm_itx.c.o' 'tests/tests@@checkasm_bitdepth_8@sta/checkasm_loopfilter.c.o' 'tests/tests@@checkasm_bitdepth_8@sta/checkasm_mc.c.o' 'tests/tests@@checkasm_bitdepth_10@sta/checkasm_itx.c.o' 'tests/tests@@checkasm_bitdepth_10@sta/checkasm_loopfilter.c.o' 'tests/tests@@checkasm_bitdepth_10@sta/checkasm_mc.c.o' 'src/src@@dav1d_bitdepth_8@sta/ipred.c.o' 'src/src@@dav1d_bitdepth_8@sta/itx.c.o' 'src/src@@dav1d_bitdepth_8@sta/ipred_prepare.c.o' 'src/src@@dav1d_bitdepth_8@sta/lf_apply.c.o' 'src/src@@dav1d_bitdepth_8@sta/loopfilter.c.o' 'src/src@@dav1d_bitdepth_8@sta/mc.c.o' 'src/src@@dav1d_bitdepth_8@sta/cdef_apply.c.o' 'src/src@@dav1d_bitdepth_8@sta/cdef.c.o' 'src/src@@dav1d_bitdepth_8@sta/lr_apply.c.o' 'src/src@@dav1d_bitdepth_8@sta/looprestoration.c.o' 'src/src@@dav1d_bitdepth_8@sta/recon.c.o' 'src/src@@dav1d_bitdepth_8@sta/x86_itx_init.c.o' 'src/src@@dav1d_bitdepth_8@sta/x86_loopfilter_init.c.o' 'src/src@@dav1d_bitdepth_8@sta/x86_mc_init.c.o' 'src/src@@dav1d_bitdepth_10@sta/ipred.c.o' 'src/src@@dav1d_bitdepth_10@sta/itx.c.o' 'src/src@@dav1d_bitdepth_10@sta/ipred_prepare.c.o' 'src/src@@dav1d_bitdepth_10@sta/lf_apply.c.o' 'src/src@@dav1d_bitdepth_10@sta/loopfilter.c.o' 'src/src@@dav1d_bitdepth_10@sta/mc.c.o' 'src/src@@dav1d_bitdepth_10@sta/cdef_apply.c.o' 'src/src@@dav1d_bitdepth_10@sta/cdef.c.o' 'src/src@@dav1d_bitdepth_10@sta/lr_apply.c.o' 'src/src@@dav1d_bitdepth_10@sta/looprestoration.c.o' 'src/src@@dav1d_bitdepth_10@sta/recon.c.o' 'src/src@@dav1d_bitdepth_10@sta/x86_itx_init.c.o' 'src/src@@dav1d_bitdepth_10@sta/x86_loopfilter_init.c.o' 'src/src@@dav1d_bitdepth_10@sta/x86_mc_init.c.o' 'src/src@@dav1d_entrypoint@sta/lib.c.o' 'src/src@@dav1d_entrypoint@sta/thread_task.c.o' 'src/src@@dav1d@sha/picture.c.o' 'src/src@@dav1d@sha/cpu.c.o' 'src/src@@dav1d@sha/data.c.o' 'src/src@@dav1d@sha/ref.c.o' 'src/src@@dav1d@sha/getbits.c.o' 'src/src@@dav1d@sha/obu.c.o' 'src/src@@dav1d@sha/decode.c.o' 'src/src@@dav1d@sha/cdf.c.o' 'src/src@@dav1d@sha/msac.c.o' 'src/src@@dav1d@sha/tables.c.o' 'src/src@@dav1d@sha/scan.c.o' 'src/src@@dav1d@sha/dequant_tables.c.o' 'src/src@@dav1d@sha/intra_edge.c.o' 'src/src@@dav1d@sha/lf_mask.c.o' 'src/src@@dav1d@sha/ref_mvs.c.o' 'src/src@@dav1d@sha/warpmv.c.o' 'src/src@@dav1d@sha/wedge.c.o' 'src/src@@dav1d@sha/qm.c.o' 'src/src@@dav1d@sha/x86_cpu.c.o' -I/opt/local/include -L/opt/local/lib -Wl,-dead_strip_dylibs -lm -pthread  

Important part from the above is '-Wl,-rpath,$ORIGIN/../src' which is not a valid rpath.

jpakkane commented 6 years ago

This is probably because the part that chooses which form of rpaths to use detects the macosness correctly with Clang but not with GCC. This is probably because no-one has used this combination. This should be fairly easy to test by grepping the compiler source files for rpath and CLANG_OSX, seeing where the choice is done and extending the detection logic to handle GCC_OSX too.

ePirat commented 6 years ago

I've checked and in the current master at least this is done by:

    def is_osx_compiler(self):
        return self.name in ('GCC_OSX', 'CLANG_OSX', 'ICC_OSX')

so it should work unless meson somehow fails to detect the compiler as gcc…

SoapGentoo commented 6 years ago

Please test again, I specifically recall fixing GCC and ICC for the 0.48 release.