diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-11-05 03:04:57 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-11-10 00:40:16 +0530 |
commit | 69756fdabb123b3e0499f6daa0f32ef06b406614 (patch) | |
tree | 47f22208cc06b610f363cc3e5877f256a5e71f35 | |
parent | 408686a31d3cf88a823b19399b16310ebbb94938 (diff) | |
download | meson-69756fdabb123b3e0499f6daa0f32ef06b406614.zip meson-69756fdabb123b3e0499f6daa0f32ef06b406614.tar.gz meson-69756fdabb123b3e0499f6daa0f32ef06b406614.tar.bz2 |
Fix 103 manygen with MSVC on Windows
The code generated manually with manygen.py must use the same CRT
compiler arguments as the final executable itself or we get an error
during linking:
MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
depuser.exe : fatal error LNK1120: 1 unresolved externals
-rwxr-xr-x | test cases/common/103 manygen/subdir/manygen.py | 3 | ||||
-rw-r--r-- | test cases/common/103 manygen/subdir/meson.build | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/test cases/common/103 manygen/subdir/manygen.py b/test cases/common/103 manygen/subdir/manygen.py index 4fd2f25..8449dc3 100755 --- a/test cases/common/103 manygen/subdir/manygen.py +++ b/test cases/common/103 manygen/subdir/manygen.py @@ -9,6 +9,7 @@ import shutil, subprocess with open(sys.argv[1]) as f: funcname = f.readline().strip() outdir = sys.argv[2] +buildtype_args = sys.argv[3] if not os.path.isdir(outdir): print('Outdir does not exist.') @@ -67,7 +68,7 @@ with open(tmpc, 'w') as f: ''' % funcname) if is_vs: - subprocess.check_call([compiler, '/nologo', '/c', '/Fo' + outo, tmpc]) + subprocess.check_call([compiler, '/nologo', '/c', buildtype_args, '/Fo' + outo, tmpc]) else: subprocess.check_call([compiler, '-c', '-o', outo, tmpc]) diff --git a/test cases/common/103 manygen/subdir/meson.build b/test cases/common/103 manygen/subdir/meson.build index 5c5d763..3036899 100644 --- a/test cases/common/103 manygen/subdir/meson.build +++ b/test cases/common/103 manygen/subdir/meson.build @@ -1,6 +1,17 @@ gen = find_program('manygen.py') +buildtype = get_option('buildtype') +buildtype_args = '-Dfooxxx' # a useless compiler argument if meson.get_compiler('c').get_id() == 'msvc' + # We need our manually generated code to use the same CRT as the executable. + # Taken from compilers.py since build files do not have access to this. + if buildtype == 'debug' + buildtype_args = '/MDd' + elif buildtype == 'debugoptimized' + buildtype_args = '/MDd' + elif buildtype == 'release' + buildtype_args = '/MD' + endif outfiles = ['gen_func.lib', 'gen_func.c', 'gen_func.h', 'gen_func.o'] else outfiles = ['gen_func.a', 'gen_func.c', 'gen_func.h', 'gen_func.o'] @@ -9,5 +20,5 @@ endif generated = custom_target('manygen', output : outfiles, input : ['funcinfo.def'], - command : [gen, '@INPUT@', '@OUTDIR@'], + command : [gen, '@INPUT@', '@OUTDIR@', buildtype_args], ) |