Skip to content

Build failure ("undefined reference" linker errors) on Linux if Clang's -fprofile-instr-generate flag is in CFLAGS

This bug was originally reported in https://crbug.com/oss-fuzz/38639. (https://crbug.com/oss-fuzz/38512 is libavif's version of the same bug.)

If Clang's -fprofile-instr-generate flag is in the CFLAGS environment variable, Meson's symbols_have_underscore_prefix() function returns True incorrectly and causes build failure (lots of "undefined reference" linker errors) on Linux.

Run the following commands on Linux to reproduce this bug:

$ git clone https://code.videolan.org/videolan/dav1d.git
$ cd dav1d
$ mkdir build
$ cd build
$ export CC=clang
$ export CFLAGS=-fprofile-instr-generate
$ meson ..
$ ninja

Note: An alternative way to reproduce this bug is to set GCC's -flto flag in CFLAGS:

$ git clone https://code.videolan.org/videolan/dav1d.git
$ cd dav1d
$ mkdir build
$ cd build
$ export CC=gcc
$ export CFLAGS=-flto
$ meson ..
$ ninja

A workaround for this Meson bug is to handle Linux as a special case:

diff --git a/meson.build b/meson.build
index 1bf69ab..1ab7540 100644
--- a/meson.build
+++ b/meson.build
@@ -382,7 +382,7 @@ endif
 
 cdata.set10('ARCH_PPC64LE', host_machine.cpu() == 'ppc64le')
 
-if cc.symbols_have_underscore_prefix()
+if host_machine.system() != 'linux' and cc.symbols_have_underscore_prefix()
     cdata.set10('PREFIX', true)
     cdata_asm.set10('PREFIX', true)
 endif
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information