Skip to content

MSVC: /release linker flag leaks into cl.exe command line in has_function() tests (regression in 1.11) #16086

Description

@StormBytePP

Describe the bug

Starting with Meson 1.11, the linker-only flag /release is incorrectly passed to cl.exe (before /link) during has_function() / dependency checks when using MSVC + static libraries.

This causes the configure step to fail with:

cl : Command line error D8043 : unknown option '/release'

The same project configures and builds correctly with Meson 1.10.0.

To Reproduce

This comes from a check similar to:

check_pkg_config = [
  ...
  ['libvmaf', ['libvmaf.h'], ['vmaf_init'], {'version': '>= 2.0.0'}],
  ...
]

The failure happens during the subsequent has_function("vmaf_init") check with a static libvmaf dependency on Windows/MSVC.

Failing command generated by Meson 1.11.2:

cl -IC:/install/include -IC:/install/include/libvmaf ... /utf-8 /release /nologo ... /MD ... /release /nologo /Od /Oi- /std:c17 ... /link C:/install/lib/vmaf.lib C:/install/lib/pthreadVC3.lib

Note that /release appears twice before /link.

Expected behavior (worked in 1.10.0)

-----------
Command line: `cl -IC:/Test/install/include/libvmaf C:\Test\build\ffmpeg\meson-private\tmpb1uyfuq7\testfile.c /nologo /showIncludes /utf-8 /EP -DPTW32_CLEANUP_C -DPTW32_STATIC_LIB -DHAVE_BUILTIN_CLZ_COMPAT /nologo /showIncludes /utf-8 /EP /Od /Oi- /std:c17` -> 0
stderr:
testfile.c
-----------
Has header "libvmaf.h" with dependency libvmaf: YES 
Running compile:
Working directory:  C:\Test\build\ffmpeg\meson-private\tmp1otsiina
Code:
#include <libvmaf.h>

#include <limits.h>

        #if defined __stub_vmaf_init || defined __stub___vmaf_init
        fail fail fail this function is not going to work
        #endif
        
int main(void) {
            void *a = (void*) &vmaf_init;
            long long b = (long long) a;
            return (int) b;
        }
-----------
Command line: `cl -IC:/Test/install/include/libvmaf C:\Test\build\ffmpeg\meson-private\tmp1otsiina\testfile.c /FeC:\Test\build\ffmpeg\meson-private\tmp1otsiina\output.exe /nologo /showIncludes /utf-8 -DPTW32_CLEANUP_C -DPTW32_STATIC_LIB -DHAVE_BUILTIN_CLZ_COMPAT /MD /nologo /showIncludes /utf-8 /Od /Oi- /std:c17 kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -D_ISOC11_SOURCE -D_GNU_SOURCE -D_LARGEFILE_SOURCE /options:strict -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_WIN32_WINNT=0x0600 -DWIN32_LEAN_AND_MEAN -wd4005 /link C:/Test/install/lib/libvmaf.a C:/Test/install/lib/libpthreadVC3.a` -> 0
stdout:
testfile.c
-----------
Checking for function "vmaf_init" with dependency libvmaf: YES 

Actual behavior

-----------
Command line: `cl -IC:/install/include -IC:/install/include/libvmaf D:\a\vmaf\vmaf\ffmpeg\build\meson-private\tmpp16awo_z\testfile.c /nologo /showIncludes /utf-8 /EP -DPTW32_CLEANUP_C -DPTW32_STATIC_LIB -DHAVE_BUILTIN_CLZ_COMPAT /nologo /showIncludes /utf-8 /EP /Od /Oi- /std:c17` -> 0
stderr:
testfile.c
-----------
Has header "libvmaf.h" with dependency libvmaf: YES 
Running compile:
Working directory:  D:\a\vmaf\vmaf\ffmpeg\build\meson-private\tmp7703h_go
Code:
#include <libvmaf.h>

#include <limits.h>

        #if defined __stub_vmaf_init || defined __stub___vmaf_init
        fail fail fail this function is not going to work
        #endif
        
int main(void) {
            void *a = (void*) &vmaf_init;
            long long b = (long long) a;
            return (int) b;
        }
-----------
Command line: `cl -IC:/install/include -IC:/install/include/libvmaf D:\a\vmaf\vmaf\ffmpeg\build\meson-private\tmp7703h_go\testfile.c /FeD:\a\vmaf\vmaf\ffmpeg\build\meson-private\tmp7703h_go\output.exe /nologo /showIncludes /utf-8 /release /nologo -DPTW32_CLEANUP_C -DPTW32_STATIC_LIB -DHAVE_BUILTIN_CLZ_COMPAT /MD /nologo /showIncludes /utf-8 /release /nologo /Od /Oi- /std:c17 kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -D_ISOC11_SOURCE -D_GNU_SOURCE -D_LARGEFILE_SOURCE /options:strict -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_WIN32_WINNT=0x0600 -DWIN32_LEAN_AND_MEAN -wd4005 /link C:/install/lib/vmaf.lib C:/install/lib/pthreadVC3.lib` -> 2
stderr:
cl : Command line error D8043 : unknown option '/release'
cl : Command line error D8043 : unknown option '/release'
-----------
Checking for function "vmaf_init" with dependency libvmaf: NO 

System parameters

  • Operating system: Windows (GitHub Actions windows-latest)
  • Compiler: MSVC (cl)
  • Meson version that fails: >=1.10.2
  • Meson version that works: 1.10.0
  • Ninja: latest
  • The dependency is a static library (vmaf.lib) found via pkg-config

Additional context

This seems related to the MSVC linker flag handling changes introduced in 1.11 (especially the new -Db_lto / -Db_pgo support though they were not explicitelly used for this test).

Workaround: pin Meson to <1.11 (e.g. meson==1.10.0).

Happy to provide more logs or a minimal reproducer if needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions