Skip to content

rc.py passes MSVC options to Clang #15709

Description

@lhmouse

Describe the bug

cmd = [cl, '/showIncludes', '/EP', '/nologo', '/DRC_INVOKED'] + include_args + ['/Tc' + target]

'--cl', compiler.get_exelist(False)[0],

This passes MSVC-style options to cl, but cl itself isn't always CL. In MSVC dev shell, it's possible to use Clang as the compiler (and LINK as the linker by default), where this produces errors like

[2/3] Compiling Windows resource rc-test.rc
clang: error: no such file or directory: '/showIncludes'
clang: error: no such file or directory: '/EP'
clang: error: no such file or directory: '/nologo'
clang: error: no such file or directory: '/DRC_INVOKED'
clang: error: no such file or directory: '/Tc../rc-test.rc'
clang: error: no input files
Error running preprocessor to find resource dependencies
[3/3] Linking target main.exe

Despite these errors, the build actually succeeds.

To Reproduce

  • meson.build
project('rc-test', 'c', version: '0.0.0')
rc_obj = import('windows').compile_resources('rc-test.rc')
executable('main', sources: [ 'main.c', rc_obj ])
  • rc-test.rc
c RCDATA { "c" }
  • main.c
int main(void) { return 0; }
  • llvm.x86_64-pc-windows-msvc
[binaries]
c = [ 'clang', '--target=x86_64-pc-windows-msvc' ]
cpp = [ 'clang++', '--target=x86_64-pc-windows-msvc' ]
ar = 'llvm-ar'
objcopy = [ 'llvm-objcopy', '--target=x86_64-pc-windows-msvc' ]
strip = 'llvm-strip'
windres = [ 'llvm-rc', '--target=x86_64-pc-windows-msvc' ]
dlltool = [ 'llvm-dlltool', '-m', 'i386:x86-64' ]

[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

This is the output, in MSVC x64 dev shell:

E:\lh_mouse\Desktop>meson setup --native-file llvm.x86_64-pc-windows-msvc build
The Meson build system
Version: 1.11.0
Source dir: E:\lh_mouse\Desktop
Build dir: E:\lh_mouse\Desktop\build
Build type: native build
Project name: rc-test
Project version: 0.0.0
C compiler for the host machine: clang --target=x86_64-pc-windows-msvc (clang 20.1.8 "clang version 20.1.8")
C linker for the host machine: clang --target=x86_64-pc-windows-msvc link 14.50.35729.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
Windows resource compiler: LLVM Resource Converter
Build targets in project: 1

rc-test 0.0.0

  User defined options
    Native files: llvm.x86_64-pc-windows-msvc

Found ninja-1.13.2 at C:\MSYS64\usr\bin\..\..\mingw64\bin\ninja.EXE
E:\lh_mouse\Desktop\build>ninja
[2/3] Compiling Windows resource rc-test.rc
clang: error: no such file or directory: '/showIncludes'
clang: error: no such file or directory: '/EP'
clang: error: no such file or directory: '/nologo'
clang: error: no such file or directory: '/DRC_INVOKED'
clang: error: no such file or directory: '/Tc../rc-test.rc'
clang: error: no input files
Error running preprocessor to find resource dependencies
[3/3] Linking target main.exe

Expected behavior

There should be no error messages from Clang.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
    Native.
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
    Windows 11 Insider Preview 26300.8170
  • what Python version are you using e.g. 3.8.0
    Python 3.14.4 (from MSYS2)
  • what meson --version
    1.11.0 (from MSYS2)
  • what ninja --version if it's a Ninja build
    1.13.2 (from MSYS2)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions