<div dir="ltr"><div>Hi all,</div><div><br></div><div>I tried to build from 4.4.1 using --toolchain=gcc-asan, but I hit a problem linking libswscale. I wonder if someone here understands the problem, or has otherwise been able to build recent versions of FFmpeg with ASan enabled?</div><div><br></div><div>My system:</div><div>$ uname -mov<br>#1 SMP PREEMPT Debian 5.16.12-1~bpo11+1 (2022-03-08) x86_64 GNU/Linux<br>$ gcc --version<br>gcc (Debian 10.2.1-6) 10.2.1 20210110</div><div><br></div><div>Configured with:</div><div>$ ./configure --prefix=/some/local/path --disable-static --enable-shared --enable-rpath --disable-doc --disable-programs --toolchain=gcc-asan</div><div><br></div><div>libavutil built successfully, but libswscale failed to link:<br><br>$ make V=1<br>...<br>gcc -shared -Wl,-soname,libswscale.so.5 -Wl,-Bsymbolic -Wl,--version-script,libswscale/libswscale.ver -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -fsanitize=address  -Wl,--as-needed -Wl,-z,noexecstack -Wl,--warn-common -Wl,-rpath-link=:libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample -Wl,-rpath,/usr/local/companion-libs/ffmpeg/v1002/lib -o libswscale/libswscale.so.5 libswscale/alphablend.o libswscale/gamma.o libswscale/hscale.o libswscale/hscale_fast_bilinear.o libswscale/input.o libswscale/log2_tab.o libswscale/options.o libswscale/output.o libswscale/rgb2rgb.o libswscale/slice.o libswscale/swscale.o libswscale/swscale_unscaled.o libswscale/utils.o libswscale/vscale.o libswscale/x86/hscale_fast_bilinear_simd.o libswscale/x86/input.o libswscale/x86/output.o libswscale/x86/rgb2rgb.o libswscale/x86/rgb_2_rgb.o libswscale/x86/scale.o libswscale/x86/swscale.o libswscale/x86/yuv2rgb.o libswscale/x86/yuv2yuvX.o libswscale/x86/yuv_2_rgb.o libswscale/yuv2rgb.o -lavutil -lm -pthread -lvdpau -lX11 -lm <br>/usr/bin/ld: libswscale/x86/rgb2rgb.o: warning: relocation against `__odr_asan.mask24r' in read-only section `.text'<br>/usr/bin/ld: libswscale/x86/rgb2rgb.o: relocation R_X86_64_PC32 against undefined symbol `__odr_asan.mask24l' can not be used when making a shared object; recompile with -fPIC<br>/usr/bin/ld: final link failed: bad value<br>collect2: error: ld returned 1 exit status<br>make: *** [ffbuild/library.mak:103: libswscale/libswscale.so.5] Error 1</div><div><br></div><div>However, libswscale/x86/rgb2rgb.o was already compiled with -fPIC:<br><br>gcc -I. -I./ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -DBUILDING_swscale -fsanitize=address   -std=c11 -fomit-frame-pointer -fPIC -pthread   -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -Wno-bool-operation -Wno-char-subscripts -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized   -MMD -MF libswscale/x86/rgb2rgb.d -MT libswscale/x86/rgb2rgb.o -c -o libswscale/x86/rgb2rgb.o libswscale/x86/rgb2rgb.c</div><div><br></div><div>The object file has relocations for various __asan_* symbols, but not for any __odr_asan:<br><br>$ readelf --relocs libswscale/x86/rgb2rgb.o | egrep '(GOT|PLT|JU?MP_SLOT)' | grep asan | cut -d " " -f9 | sort | uniq -c<br>      1 __asan_init<br>      1 __asan_register_g[...]<br>    132 __asan_report_load1<br>     12 __asan_report_load2<br>     12 __asan_report_load4<br>    134 __asan_report_store1<br>     20 __asan_report_store2<br>      4 __asan_report_store4<br>     76 __asan_report_store8<br>      1 __asan_unregister[...]<br>      1 __asan_version_mi[...]</div><div><br></div><div>Thanks,</div><div>Patrick<br></div></div>