Skip to content

Commit 785abf0

Browse files
huthbonzini
authored andcommitted
meson.build: Remove the logic to link C code with the C++ linker
We are not mixing C++ with C code anymore, the only remaining C++ code in qga/vss-win32/ is used for a plain C++ executable. Thus we can remove the hacks for linking C code with the C++ linker now to simplify meson.build a little bit, and also to avoid that some C++ code sneaks in by accident again. Signed-off-by: Thomas Huth <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 3d7b897 commit 785abf0

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

meson.build

+6-16
Original file line numberDiff line numberDiff line change
@@ -473,19 +473,10 @@ if targetos != 'darwin'
473473
warn_flags += ['-Wthread-safety']
474474
endif
475475

476-
# Check that the C++ compiler exists and works with the C compiler.
477-
link_language = 'c'
478-
linker = cc
476+
# Set up C++ compiler flags
479477
qemu_cxxflags = []
480478
if 'cpp' in all_languages
481479
qemu_cxxflags = ['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'] + qemu_cflags
482-
if cxx.links(files('scripts/main.c'), args: qemu_cflags)
483-
link_language = 'cpp'
484-
linker = cxx
485-
else
486-
message('C++ compiler does not work with C compiler')
487-
message('Disabling C++-specific optional code')
488-
endif
489480
endif
490481

491482
# clang does not support glibc + FORTIFY_SOURCE (is it still true?)
@@ -1600,7 +1591,7 @@ if not get_option('snappy').auto() or have_system
16001591
snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
16011592
required: get_option('snappy'))
16021593
endif
1603-
if snappy.found() and not linker.links('''
1594+
if snappy.found() and not cc.links('''
16041595
#include <snappy-c.h>
16051596
int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
16061597
snappy = not_found
@@ -2746,7 +2737,7 @@ config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol(
27462737

27472738
have_vss = false
27482739
have_vss_sdk = false # old xp/2003 SDK
2749-
if targetos == 'windows' and link_language == 'cpp'
2740+
if targetos == 'windows' and 'cpp' in all_languages
27502741
have_vss = cxx.compiles('''
27512742
#define __MIDL_user_allocate_free_DEFINED__
27522743
#include <vss.h>
@@ -3827,7 +3818,6 @@ foreach target : target_dirs
38273818
c_args: c_args,
38283819
dependencies: arch_deps + deps + exe['dependencies'],
38293820
objects: lib.extract_all_objects(recursive: true),
3830-
link_language: link_language,
38313821
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
38323822
link_args: link_args,
38333823
win_subsystem: exe['win_subsystem'])
@@ -4061,7 +4051,7 @@ summary_info += {'host CPU': cpu}
40614051
summary_info += {'host endianness': build_machine.endian()}
40624052
summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())}
40634053
summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())}
4064-
if link_language == 'cpp'
4054+
if 'cpp' in all_languages
40654055
summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())}
40664056
else
40674057
summary_info += {'C++ compiler': false}
@@ -4074,13 +4064,13 @@ if get_option('optimization') != 'plain'
40744064
option_cflags += ['-O' + get_option('optimization')]
40754065
endif
40764066
summary_info += {'CFLAGS': ' '.join(get_option('c_args') + option_cflags)}
4077-
if link_language == 'cpp'
4067+
if 'cpp' in all_languages
40784068
summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args') + option_cflags)}
40794069
endif
40804070
if targetos == 'darwin'
40814071
summary_info += {'OBJCFLAGS': ' '.join(get_option('objc_args') + option_cflags)}
40824072
endif
4083-
link_args = get_option(link_language + '_link_args')
4073+
link_args = get_option('c_link_args')
40844074
if link_args.length() > 0
40854075
summary_info += {'LDFLAGS': ' '.join(link_args)}
40864076
endif

qga/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ endif
99
have_qga_vss = get_option('qga_vss') \
1010
.require(targetos == 'windows',
1111
error_message: 'VSS support requires Windows') \
12-
.require(link_language == 'cpp',
12+
.require('cpp' in all_languages,
1313
error_message: 'VSS support requires a C++ compiler') \
1414
.require(have_vss, error_message: '''VSS support requires VSS headers.
1515
If your Visual Studio installation doesn't have the VSS headers,

scripts/main.c

-1
This file was deleted.

0 commit comments

Comments
 (0)