Skip to content

msvc: use /experimental:c11atomics when finding stdatomic #14233

Open
@mochaaP

Description

Describe the bug
c11 atomics is behind a flag in msvc:
https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/

To Reproduce

project('msvc-stdatomic', 'c', default_options: ['c_std=c11'])

cc = meson.get_compiler('c')
atomic_dep = dependency('atomic', required: false)
# atomic_flag_clear forwards to __c11_atomic_store in msvc,
# which behaves like __builtin_* in gcc, and we're unable to detect it with .has_function().
atomic_without_flag = cc.has_function('_Atomic_thread_fence', prefix: '#include <stdatomic.h>')
atomic_with_flag = cc.has_function(
  '_Atomic_thread_fence',
  args: '/experimental:c11atomics',
  prefix: '#include <stdatomic.h>',
)

summary(
  {
    'atomic_dep': atomic_dep.found(),
    'atomic_without_flag': atomic_without_flag,
    'atomic_with_flag': atomic_with_flag,
  },
)

Expected behavior
atomic_dep.found() == true

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
    happens on both native vs2022 and wine-msvc.
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
    Windows 10 (19045.4780)
  • what Python version are you using e.g. 3.8.0
    Python 3.13.2
  • what meson --version
    1.7.0-rc2 (master)
  • what ninja --version if it's a Ninja build
    1.12.1

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions