Skip to content

Commit 0705795

Browse files
dblsaikojpakkane
authored andcommitted
swift: Pass C++ base compile options to swiftc
1 parent eefad4a commit 0705795

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
## Swift compiler receives select C family compiler options
22

3-
Meson now passes select few C family (C/Obj-C) compiler options to the
4-
Swift compiler, notably *-std=*, in order to improve the compatibility
5-
of C code as interpreted by the C compiler and the Swift compiler.
3+
Meson now passes select few C family (C/C++/Obj-C/Obj-C++) compiler
4+
options to the Swift compiler, notably *-std=*, in order to improve
5+
the compatibility of C code as interpreted by the C compiler and the
6+
Swift compiler.
67

78
NB: This does not include any of the options set in the target's
89
c_flags.

mesonbuild/compilers/swift.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ def get_option_std_args(self, target: build.BuildTarget, env: Environment, subpr
140140
args += ['-swift-version', std]
141141

142142
# Pass C compiler -std=... arg to swiftc
143-
c_lang = first(['objc', 'c'], lambda x: x in target.compilers)
143+
c_langs = ['objc', 'c']
144+
if target.uses_swift_cpp_interop():
145+
c_langs = ['objcpp', 'cpp', *c_langs]
146+
147+
c_lang = first(c_langs, lambda x: x in target.compilers)
144148
if c_lang is not None:
145149
cc = target.compilers[c_lang]
146150
args.extend(arg for c_arg in cc.get_option_std_args(target, env, subproject) for arg in ['-Xcc', c_arg])

0 commit comments

Comments
 (0)