From 541307a426d90915153f31614788fea97692d69e Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 30 Nov 2018 13:14:55 +0000 Subject: Windows clang supports `-mwindows` to set subsystem Promote get_gui_app_args from class GnuCompiler to GnuLikeCompiler --- mesonbuild/compilers/compilers.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index e27ae2b..f8b8b0d 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1545,6 +1545,10 @@ class GnuLikeCompiler(abc.ABC): # GNU ld and LLVM lld return ['-Wl,--allow-shlib-undefined'] + def get_gui_app_args(self, value): + if self.compiler_type.is_windows_compiler and value: + return ['-mwindows'] + return [] class GnuCompiler(GnuLikeCompiler): """ @@ -1583,11 +1587,6 @@ class GnuCompiler(GnuLikeCompiler): def get_pch_suffix(self): return 'gch' - def get_gui_app_args(self, value): - if self.compiler_type.is_windows_compiler and value: - return ['-mwindows'] - return [] - def openmp_flags(self): return ['-fopenmp'] -- cgit v1.1 From 6700a8bfd71dd831b1dd832efc6b70bfe69879de Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 30 Nov 2018 13:04:57 +0000 Subject: Fix hidden symbol test for Windows clang This only happened to work with MSVC by accident (since shared libraries don't export symbols by default with that) --- test cases/failing build/2 hidden symbol/meson.build | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test cases/failing build/2 hidden symbol/meson.build b/test cases/failing build/2 hidden symbol/meson.build index 0527347..f7c38e3 100644 --- a/test cases/failing build/2 hidden symbol/meson.build +++ b/test cases/failing build/2 hidden symbol/meson.build @@ -1,10 +1,7 @@ project('hidden symbol', 'c') if host_machine.system() == 'windows' or host_machine.system() == 'cygwin' - cc = meson.get_compiler('c') - if cc.get_id() == 'gcc' - error('MESON_SKIP_TEST -fvisibility=hidden does not work on MinGW or Cygwin.') - endif + error('MESON_SKIP_TEST -fvisibility=hidden does not work for PE files.') endif l = shared_library('bob', 'bob.c', -- cgit v1.1 From 65160a969e4ec078a8ec740160b3bfc96055bc8c Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Wed, 28 Nov 2018 23:45:40 +0000 Subject: Don't rely on -fPIC being ignored where it's meaningless clang considers it an error to try to use -fPIC for a windows target v2: '' isn't consistently elided, use [] --- run_unittests.py | 6 ++++-- test cases/common/143 C and CPP link/meson.build | 6 +++++- test cases/common/59 exe static shared/meson.build | 8 ++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/run_unittests.py b/run_unittests.py index f1b2249..6e5d8c9 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2165,7 +2165,9 @@ int main(int argc, char **argv) { '/NOLOGO', '/DLL', '/DEBUG', '/IMPLIB:' + impfile, '/OUT:' + outfile, objectfile] else: - extra_args += ['-fPIC'] + if not (compiler.compiler_type.is_windows_compiler or + compiler.compiler_type.is_osx_compiler): + extra_args += ['-fPIC'] link_cmd = compiler.get_exelist() + ['-shared', '-o', outfile, objectfile] if not mesonbuild.mesonlib.is_osx(): link_cmd += ['-Wl,-soname=' + os.path.basename(outfile)] @@ -3495,7 +3497,7 @@ class LinuxlikeTests(BasePlatformTests): is true and not when it is false. This can't be an ordinary test case because we need to inspect the compiler database. ''' - if is_cygwin() or is_osx(): + if is_windows() or is_cygwin() or is_osx(): raise unittest.SkipTest('PIC not relevant') testdir = os.path.join(self.common_test_dir, '3 static') diff --git a/test cases/common/143 C and CPP link/meson.build b/test cases/common/143 C and CPP link/meson.build index 79d6f67..75281de 100644 --- a/test cases/common/143 C and CPP link/meson.build +++ b/test cases/common/143 C and CPP link/meson.build @@ -36,7 +36,11 @@ if cxx.get_argument_syntax() == 'msvc' compile_cmd = ['/c', '@INPUT@', '/Fo@OUTPUT@'] stlib_cmd = [static_linker, '/OUT:@OUTPUT@', '@INPUT@'] else - compile_cmd = ['-c', '-fPIC', '@INPUT@', '-o', '@OUTPUT@'] + picflag = [] + if not ['darwin', 'windows'].contains(host_machine.system()) + picflag = ['-fPIC'] + endif + compile_cmd = ['-c', picflag, '@INPUT@', '-o', '@OUTPUT@'] stlib_cmd = ['ar', 'csr', '@OUTPUT@', '@INPUT@'] endif diff --git a/test cases/common/59 exe static shared/meson.build b/test cases/common/59 exe static shared/meson.build index 2888882..69ede5e 100644 --- a/test cases/common/59 exe static shared/meson.build +++ b/test cases/common/59 exe static shared/meson.build @@ -1,8 +1,12 @@ project('statchain', 'c') subdir('subdir') -# Test that -fPIC in c_args is also accepted -statlib2 = static_library('stat2', 'stat2.c', c_args : '-fPIC', pic : false) +# Test that -fPIC in c_args is also accepted (on platforms where it's permitted) +picflag = [] +if not ['darwin', 'windows'].contains(host_machine.system()) + picflag = ['-fPIC'] +endif +statlib2 = static_library('stat2', 'stat2.c', c_args : picflag, pic : false) # Test that pic is needed for both direct and indirect static library # dependencies of shared libraries (on Linux and BSD) statlib = static_library('stat', 'stat.c', link_with : [shlib, statlib2], pic : true) -- cgit v1.1 From 272623c5a344d503930e1f8b0807611e1a3eff9f Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 29 Nov 2018 12:13:08 +0000 Subject: Skip openmp test for windows clang This can probably be made to work, but the special steps needed aren't clear. --- test cases/common/190 openmp/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test cases/common/190 openmp/meson.build b/test cases/common/190 openmp/meson.build index 018bf24..f4652db 100644 --- a/test cases/common/190 openmp/meson.build +++ b/test cases/common/190 openmp/meson.build @@ -13,6 +13,9 @@ endif if cc.get_id() == 'clang-cl' error('MESON_SKIP_TEST clang-cl does not support OpenMP.') endif +if cc.get_id() == 'clang' and host_machine.system() == 'windows' + error('MESON_SKIP_TEST Windows clang does not support OpenMP.') +endif if host_machine.system() == 'darwin' error('MESON_SKIP_TEST macOS does not support OpenMP.') endif -- cgit v1.1 From 54c680c4ba2bdd53147316a64f46612f667065b5 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 30 Nov 2018 13:57:57 +0000 Subject: Apply work-around for windres bug with msys2 clang also The windres bug with paths with spaces appears irrespective of compiler --- test cases/windows/12 resources with custom targets/meson.build | 2 +- test cases/windows/5 resources/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test cases/windows/12 resources with custom targets/meson.build b/test cases/windows/12 resources with custom targets/meson.build index b1e2b09..282272d 100644 --- a/test cases/windows/12 resources with custom targets/meson.build +++ b/test cases/windows/12 resources with custom targets/meson.build @@ -3,7 +3,7 @@ project('winmain', 'c') # MinGW windres has a bug due to which it doesn't parse args with space properly: # https://github.com/mesonbuild/meson/pull/1346 # https://sourceware.org/bugzilla/show_bug.cgi?id=4933 -if meson.get_compiler('c').get_id() == 'gcc' and host_machine.system() == 'windows' +if ['gcc', 'clang'].contains(meson.get_compiler('c').get_id()) and host_machine.system() == 'windows' # Construct build_to_src and skip this test if it has spaces # because then the -I flag to windres will also have spaces # and we know the test will fail diff --git a/test cases/windows/5 resources/meson.build b/test cases/windows/5 resources/meson.build index ddb7d6e..27b2fcc 100644 --- a/test cases/windows/5 resources/meson.build +++ b/test cases/windows/5 resources/meson.build @@ -3,7 +3,7 @@ project('winmain', 'c') # MinGW windres has a bug due to which it doesn't parse args with space properly: # https://github.com/mesonbuild/meson/pull/1346 # https://sourceware.org/bugzilla/show_bug.cgi?id=4933 -if meson.get_compiler('c').get_id() == 'gcc' and host_machine.system() == 'windows' +if ['gcc', 'clang'].contains(meson.get_compiler('c').get_id()) and host_machine.system() == 'windows' # Construct build_to_src and skip this test if it has spaces # because then the -I flag to windres will also have spaces # and we know the test will fail -- cgit v1.1 From aff5b3f416b06ef90511fb1149ffc3c99c533d44 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 30 Nov 2018 17:31:18 +0000 Subject: Skip LTO test with Windows clang This doesn't seem to be working in clang, at the moment. --- run_unittests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/run_unittests.py b/run_unittests.py index 6e5d8c9..a512447 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1947,6 +1947,11 @@ class AllPlatformTests(BasePlatformTests): https://github.com/mesonbuild/meson/issues/1646 ''' testdir = os.path.join(self.common_test_dir, '5 linkstatic') + + env = get_fake_env(testdir, self.builddir, self.prefix) + if env.detect_c_compiler(False).get_id() == 'clang' and is_windows(): + raise unittest.SkipTest('LTO not (yet) supported by windows clang') + self.init(testdir, extra_args='-Db_lto=true') self.build() self.run_tests() -- cgit v1.1 From 468c4411e14cdce2a9ae92878393b0906f3efe92 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 30 Nov 2018 17:35:08 +0000 Subject: Skip test_config_tool_dep on MSYS2 llvm-config --libfiles --link-shared wants to link to a bunch of shared libraries which don't exist, so we end up at dev.py:308, but the guess that makes ('libLLVM*.dll') doesn't take into account the existence of implibs (which is fixable), but even if it did 'libLLVM-7.0.dll.a' doesn't seem to exist... so not sure how to fix this...) Also some steps towards making that work: Adjust helper_create_binary_wrapper for MSYS2. The .bat wrapper should run msys2 python, not try to invoke the 'py' python launcher (which may not be present) Suppress echoing of the command in helper_create_binary_wrapper (otherwise the echoed command can interfere in interpreting the output of the wrapped command, which seems to be the case when it's llvm-config) --- run_unittests.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/run_unittests.py b/run_unittests.py index a512447..5677efa 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4700,7 +4700,10 @@ class NativeFileTests(BasePlatformTests): # invokes our python wrapper batfile = os.path.join(self.builddir, 'binary_wrapper{}.bat'.format(self.current_wrapper)) with open(batfile, 'wt') as f: - f.write('py -3 {} %*'.format(filename)) + if mesonbuild.environment.detect_msys2_arch(): + f.write(r'@python3 {} %*'.format(filename)) + else: + f.write('@py -3 {} %*'.format(filename)) return batfile def helper_for_compiler(self, lang, cb): @@ -4745,6 +4748,8 @@ class NativeFileTests(BasePlatformTests): def test_config_tool_dep(self): # Do the skip at this level to avoid screwing up the cache + if mesonbuild.environment.detect_msys2_arch(): + raise unittest.SkipTest('Skipped due to problems with LLVM on MSYS2') if not shutil.which('llvm-config'): raise unittest.SkipTest('No llvm-installed, cannot test') self._simple_test('config_dep', 'llvm-config') -- cgit v1.1 From 8d6f5d869686f09957bb732f5b7acd0f98b1c195 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 29 Nov 2018 10:46:40 +0000 Subject: azure: Add msys2 clang to test matrix The clang package depends on the gcc package, so we need to explicitly select the compiler (as the priority order built into meson will prefer gcc to clang) v2: ensure $(MSYS2-ARCH)-pkg-config is installed --- azure-pipelines.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5b2447e..39e41e9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -100,7 +100,7 @@ jobs: testResultsFiles: meson-test-run.xml testRunTitle: $(System.JobName) -- job: msys2_mingw +- job: msys2 pool: vmImage: VS2017-Win2016 strategy: @@ -108,9 +108,15 @@ jobs: gccx86ninja: MSYSTEM: MINGW32 MSYS2_ARCH: i686 + compiler: gcc gccx64ninja: MSYSTEM: MINGW64 MSYS2_ARCH: x86_64 + compiler: gcc + clangx64ninja: + MSYSTEM: MINGW64 + MSYS2_ARCH: x86_64 + compiler: clang variables: MSYS2_ROOT: $(System.Workfolder)\msys64 steps: @@ -124,20 +130,23 @@ jobs: displayName: Update MSYS2 - script: | set PATH=%MSYS2_ROOT%\usr\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem + if %compiler%==gcc ( set "TOOLCHAIN=mingw-w64-$(MSYS2_ARCH)-toolchain" ) else ( set "TOOLCHAIN=mingw-w64-$(MSYS2_ARCH)-clang" ) %MSYS2_ROOT%\usr\bin\pacman --noconfirm --needed -S ^ base-devel ^ git ^ mercurial ^ mingw-w64-$(MSYS2_ARCH)-cmake ^ + mingw-w64-$(MSYS2_ARCH)-pkg-config ^ mingw-w64-$(MSYS2_ARCH)-python2 ^ mingw-w64-$(MSYS2_ARCH)-python3 ^ mingw-w64-$(MSYS2_ARCH)-python3-setuptools ^ - mingw-w64-$(MSYS2_ARCH)-toolchain + %TOOLCHAIN% displayName: Install Dependencies - script: | set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem %MSYS2_ROOT%\usr\bin\bash -lc "wget https://github.com/mesonbuild/cidata/raw/master/ninja.exe; mv ninja.exe /$MSYSTEM/bin" set PATHEXT=%PATHEXT%;.py + if %compiler%==clang ( set CC=clang && set CXX=clang++ ) %MSYS2_ROOT%\usr\bin\bash -lc "MSYSTEM= python3 run_tests.py --backend=ninja" env: CHERE_INVOKING: yes -- cgit v1.1