Repository: mesonbuild/meson

Issue:
Build of pulseaudio 16.1 with meson 1.3.0rc1 fails
**Describe the bug**
A clear and concise description of what the bug is. 
- Possible regression / backward compatibility issue for build of pulseaudio 16.1 with meson 1.3.0rc1 fails. I think it is something to do with SIMD (some discussion in - https://github.com/mesonbuild/meson/pull/11307)

**To Reproduce**
Please include your `meson.build` files, preferably as a minimal toy example showing the issue.
You may need to create simple source code files (don't include private/proprietary code).

build pulseaudio 16.1 using meson 1.3.0rc1. Building with 1.2.3 is fine.

**Expected behavior**
A clear and concise description of what you expected to happen. Successful build.

**system parameters**
* Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)? Cross
* what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.): Ubuntu 22.04 buildhost for LibreELEC master
* what Python version are you using: 3.11.6
* what `meson --version`: 1.3.0rc1
* what `ninja --version` if it's a Ninja build: 1.11.1

https://github.com/pulseaudio/pulseaudio/blob/stable-16.x/src/pulsecore/meson.build#L176

### logs
```
$ s/build pulseaudio
UNPACK      pulseaudio
BUILD      pulseaudio (target)
    TOOLCHAIN      meson (auto-detect)
Executing (target): meson setup --prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --localstatedir=/var --buildtype=plain -Dstrip=true --cross-file=/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/build/pulseaudio-16.1/.x86_64-libreelec-linux-gnu/meson.conf -Ddaemon=true -Ddoxygen=false -Dgcov=false -Dman=false -Dtests=false -Dsystem_user=root -Dsystem_group=root -Daccess_group=root -Ddatabase=simple -Dlegacy-database-entry-format=false -Dstream-restore-clear-old-devices=false -Drunning-from-build-tree=false -Datomic-arm-linux-helpers=true -Datomic-arm-memory-barrier=false -Dmodlibexecdir=/usr/lib/pulse -Dudevrulesdir=/usr/lib/udev/rules.d -Dalsa=enabled -Dasyncns=disabled -Davahi=enabled -Dbluez5=enabled -Dbluez5-gstreamer=disabled -Dbluez5-native-headset=false -Dbluez5-ofono-headset=false -Ddbus=enabled -Delogind=disabled -Dfftw=disabled -Dglib=enabled -Dgsettings=disabled -Dgstreamer=disabled -Dgtk=disabled -Dhal-compat=false -Dipv6=true -Djack=disabled -Dlirc=disabled -Dopenssl=enabled -Dorc=disabled -Doss-output=disabled -Dsamplerate=disabled -Dsoxr=enabled -Dspeex=enabled -Dsystemd=enabled -Dtcpwrap=disabled -Dudev=enabled -Dvalgrind=disabled -Dx11=disabled -Dadrian-aec=true -Dwebrtc-aec=disabled /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/build/pulseaudio-16.1
DEPRECATION: "pkgconfig" entry is deprecated and should be replaced by "pkg-config"
The Meson build system
Version: 1.3.0.rc1
Source dir: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/build/pulseaudio-16.1
Build dir: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/build/pulseaudio-16.1/.x86_64-libreelec-linux-gnu
Build type: cross build
Program git-version-gen found: YES (/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/build/pulseaudio-16.1/git-version-gen)
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
Project name: pulseaudio
Project version: 16.1
C compiler for the host machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc (gcc 13.2.0 "x86_64-libreelec-linux-gnu-gcc-13.2.0 (GCC) 13.2.0")
C linker for the host machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc ld.gold 2.41
C++ compiler for the host machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++ (gcc 13.2.0 "x86_64-libreelec-linux-gnu-g++-13.2.0 (GCC) 13.2.0")
C++ linker for the host machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++ ld.gold 2.41
C compiler for the build machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/host-gcc (gcc 12.1.0 "gcc (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0")
C linker for the build machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/host-gcc ld.bfd 2.38
C++ compiler for the build machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/host-g++ (gcc 12.1.0 "g++ (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0")
C++ linker for the build machine: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/host-g++ ld.bfd 2.38
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
Found pkg-config: YES (/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/pkg-config) 0.29.2
Found CMake: NO
Run-time dependency bash-completion found: NO (tried pkgconfig and cmake)
Checking for type "_Bool" : YES 
Has header "arpa/inet.h" : YES 
Has header "byteswap.h" : YES 
Has header "dlfcn.h" : YES 
Has header "execinfo.h" : YES 
Has header "grp.h" : YES 
Has header "langinfo.h" : YES 
Has header "linux/sockios.h" : YES 
Has header "locale.h" : YES 
Has header "netdb.h" : YES 
Has header "netinet/in.h" : YES 
Has header "netinet/in_systm.h" : YES 
Has header "netinet/ip.h" : YES 
Has header "netinet/tcp.h" : YES 
Has header "pcreposix.h" : YES 
Has header "poll.h" : YES 
Has header "pwd.h" : YES 
Has header "regex.h" : YES 
Has header "sched.h" : YES 
Has header "stdint.h" : YES 
Has header "sys/atomic.h" : NO 
Has header "sys/capability.h" : YES 
Has header "sys/conf.h" : NO 
Has header "sys/dl.h" : NO 
Has header "sys/eventfd.h" : YES 
Has header "sys/filio.h" : NO 
Has header "sys/ioctl.h" : YES 
Has header "sys/mman.h" : YES 
Has header "sys/prctl.h" : YES 
Has header "sys/resource.h" : YES 
Has header "sys/select.h" : YES 
Has header "sys/socket.h" : YES 
Has header "sys/syscall.h" : YES 
Has header "sys/uio.h" : YES 
Has header "sys/un.h" : YES 
Has header "sys/wait.h" : YES 
Has header "syslog.h" : YES 
Has header "xlocale.h" : NO 
Has header "valgrind/memcheck.h" skipped: feature valgrind disabled
Has header "pthread.h" : YES 
Header "pthread.h" has symbol "PTHREAD_PRIO_INHERIT" : YES 
Check usable header "cpuid.h" : YES 
Checking for function "accept4" : YES 
Checking for function "clock_gettime" : YES 
Checking for function "ctime_r" : YES 
Checking for function "fchmod" : YES 
Checking for function "fchown" : YES 
Checking for function "fork" : YES 
Checking for function "fstat" : YES 
Checking for function "getaddrinfo" : YES 
Checking for function "getgrgid_r" : YES 
Checking for function "getgrnam_r" : YES 
Checking for function "getpwnam_r" : YES 
Checking for function "getpwuid_r" : YES 
Checking for function "gettimeofday" : YES 
Checking for function "getuid" : YES 
Checking for function "lrintf" : YES 
Checking for function "lstat" : YES 
Checking for function "memfd_create" : YES 
Checking for function "mkfifo" : YES 
Checking for function "mlock" : YES 
Checking for function "nanosleep" : YES 
Checking for function "open64" : YES 
Checking for function "paccept" : NO 
Checking for function "pipe" : YES 
Checking for function "pipe2" : YES 
Checking for function "posix_fadvise" : YES 
Checking for function "posix_madvise" : YES 
Checking for function "posix_memalign" : YES 
Checking for function "ppoll" : YES 
Checking for function "readlink" : YES 
Checking for function "setegid" : YES 
Checking for function "seteuid" : YES 
Checking for function "setpgid" : YES 
Checking for function "setregid" : YES 
Checking for function "setresgid" : YES 
Checking for function "setresuid" : YES 
Checking for function "setreuid" : YES 
Checking for function "setsid" : YES 
Checking for function "sig2str" : NO 
Checking for function "sigaction" : YES 
Checking for function "strerror_r" : YES 
Checking for function "strtod_l" : YES 
Checking for function "strtof" : YES 
Checking for function "symlink" : YES 
Checking for function "sysconf" : YES 
Checking for function "uname" : YES 
Header "sys/syscall.h" has symbol "SYS_memfd_create" : YES 
Checking for function "dgettext" : YES 
Header "signal.h" has symbol "SIGXCPU" : YES 
Header "netinet/in.h" has symbol "INADDR_NONE" : YES 
Header "unistd.h" has symbol "environ" : YES 
Header "sys/soundcard.h" has symbol "SOUND_PCM_READ_RATE" : YES 
Header "sys/soundcard.h" has symbol "SOUND_PCM_READ_CHANNELS" : YES 
Header "sys/soundcard.h" has symbol "SOUND_PCM_READ_BITS" : YES 
Library m found: YES
Run-time dependency threads found: YES
Checking for function "pthread_getname_np" with dependency threads: YES 
Checking for function "pthread_setaffinity_np" with dependency threads: YES 
Checking for function "pthread_setname_np" with dependency threads: YES 
Library cap found: YES
Library rt found: YES
Checking for function "shm_open" with dependency -lrt: YES 
Library dl found: YES
Checking for function "dladdr" with dependency -ldl: YES 
Checking for function "iconv_open" : YES 
Library execinfo found: NO
Run-time dependency dbus-1 found: YES 1.15.8
Run-time dependency glib-2.0 found: YES 2.78.1
Run-time dependency sndfile found: YES 1.2.2
Run-time dependency libsystemd found: YES 254
Dependency x11-xcb skipped: feature x11 disabled
Has header "sys/soundcard.h" skipped: feature oss-output disabled
Dependency fftw3f skipped: feature fftw disabled
Dependency libasyncns skipped: feature asyncns disabled
Dependency gtk+-3.0 skipped: feature gtk disabled
Library ltdl found: YES
Run-time dependency alsa found: YES 1.2.10
Run-time dependency gio-2.0 found: YES 2.78.1
Dependency orc-0.4 skipped: feature orc disabled
Program orcc skipped: feature orc disabled
Dependency samplerate skipped: feature samplerate disabled
Run-time dependency speexdsp found: YES 1.2.1
Run-time dependency soxr found: YES 0.1.3
Dependency webrtc-audio-processing skipped: feature webrtc-aec disabled
Run-time dependency systemd found: YES 254
Dependency libelogind skipped: feature elogind disabled
Library wrap skipped: feature tcpwrap disabled
Has header "tcpd.h" : NO 
Run-time dependency avahi-client found: YES 0.8
Run-time dependency sbc found: YES 2.0
Run-time dependency bluez found: YES 5.70
Dependency jack skipped: feature jack disabled
Dependency lirc skipped: feature lirc disabled
Run-time dependency openssl found: YES 3.2.0-beta1
Run-time dependency libudev found: YES 254
Dependency gstreamer-1.0 skipped: feature gstreamer disabled
Dependency gstreamer-app-1.0 skipped: feature gstreamer disabled
Dependency gstreamer-rtp-1.0 skipped: feature gstreamer disabled
Dependency gstreamer-1.0 skipped: feature bluez5-gstreamer disabled
Dependency gstreamer-app-1.0 skipped: feature bluez5-gstreamer disabled
Run-time dependency check found: YES 0.15.2
Program msgfmt found: YES (/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/msgfmt)
Program msginit found: YES (/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/msginit)
Program msgmerge found: YES (/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/msgmerge)
Program xgettext found: YES (/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/toolchain/bin/xgettext)
Configuring version.h using configuration
Configuring client.conf using configuration
../src/pulsecore/meson.build:176: WARNING: Module SIMD has no backwards or forwards compatibility and might not exist in future releases.
Compiler supports mmx: YES
Compiler supports sse: YES
WARNING: Build target libpulsecore_simd_sse has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports sse2: YES
WARNING: Build target libpulsecore_simd_sse2 has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports sse3: YES
WARNING: Build target libpulsecore_simd_sse3 has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports ssse3: YES
WARNING: Build target libpulsecore_simd_ssse3 has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports sse41: YES
WARNING: Build target libpulsecore_simd_sse41 has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports sse42: YES
WARNING: Build target libpulsecore_simd_sse42 has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports avx: YES
WARNING: Build target libpulsecore_simd_avx has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports avx2: YES
WARNING: Build target libpulsecore_simd_avx2 has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson
Compiler supports neon: NO
Compiler supports mmx: YES
WARNING: Build target libpulsecore_simd_mmx has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson

../src/pulsecore/meson.build:198:27: ERROR: Tried to create target "libpulsecore_simd_mmx", but a target of that name already exists.

A full log can be found at /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-12.0-devel/build/pulseaudio-16.1/.x86_64-libreelec-linux-gnu/meson-logs/meson-log.txt
```


Discussion:
Thanks for testing the release candidate. This seems to be a major regression that slipped through the cracks, but I believe I understand the problem and will shortly have a fix.

Resolving patch:
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -470,7 +470,7 @@ def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, Cus
 
 BT_SOURCES_KW: KwargInfo[SourcesVarargsType] = KwargInfo(
     'sources',
-    ContainerTypeInfo(list, SOURCES_VARARGS),
+    (NoneType, ContainerTypeInfo(list, SOURCES_VARARGS)),
     listify=True,
     default=[],
 )
diff --git a/mesonbuild/modules/simd.py b/mesonbuild/modules/simd.py
--- a/mesonbuild/modules/simd.py
+++ b/mesonbuild/modules/simd.py
@@ -71,7 +71,7 @@ def __init__(self, interpreter: Interpreter):
     @typed_pos_args('simd.check', str)
     @typed_kwargs('simd.check',
                   KwargInfo('compiler', Compiler, required=True),
-                  *[BT_SOURCES_KW.evolve(name=iset) for iset in ISETS],
+                  *[BT_SOURCES_KW.evolve(name=iset, default=None) for iset in ISETS],
                   *[a for a in STATIC_LIB_KWS if a.name != 'sources'],
                   allow_unknown=True) # Because we also accept STATIC_LIB_KWS, but build targets have not been completely ported to typed_pos_args/typed_kwargs.
     @permittedKwargs({'compiler', *ISETS, *build.known_stlib_kwargs}) # Also remove this, per above comment
@@ -90,6 +90,8 @@ def check(self, state: ModuleState, args: T.Tuple[str], kwargs: CheckKw) -> T.Li
 
         for iset in ISETS:
             sources = kwargs[iset]
+            if sources is None:
+                continue
 
             compile_args = compiler.get_instruction_set_args(iset)
             if compile_args is None:


Test patch: