diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-12-21 00:01:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-21 00:01:31 +0200 |
commit | c220816350c74f59619b82e2dabebf2255acf07c (patch) | |
tree | 4d2327f43ef35c9a2fc9012efd39b2a749b99b3a | |
parent | 6864ed60dddf68e1e035194e50088649599a8d04 (diff) | |
parent | 8d6f5d869686f09957bb732f5b7acd0f98b1c195 (diff) | |
download | meson-c220816350c74f59619b82e2dabebf2255acf07c.zip meson-c220816350c74f59619b82e2dabebf2255acf07c.tar.gz meson-c220816350c74f59619b82e2dabebf2255acf07c.tar.bz2 |
Merge pull request #4573 from jon-turney/msys2-clang
More clang for Windows support
-rw-r--r-- | azure-pipelines.yml | 13 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 9 | ||||
-rwxr-xr-x | run_unittests.py | 18 | ||||
-rw-r--r-- | test cases/common/143 C and CPP link/meson.build | 6 | ||||
-rw-r--r-- | test cases/common/190 openmp/meson.build | 3 | ||||
-rw-r--r-- | test cases/common/59 exe static shared/meson.build | 8 | ||||
-rw-r--r-- | test cases/failing build/2 hidden symbol/meson.build | 5 | ||||
-rw-r--r-- | test cases/windows/12 resources with custom targets/meson.build | 2 | ||||
-rw-r--r-- | test cases/windows/5 resources/meson.build | 2 |
9 files changed, 47 insertions, 19 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 diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 5c88c3c..2a5c976 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'] diff --git a/run_unittests.py b/run_unittests.py index 663a3ca..91daa1b 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1970,6 +1970,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() @@ -2188,7 +2193,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)] @@ -3546,7 +3553,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') @@ -4757,7 +4764,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): @@ -4802,6 +4812,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') 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/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 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) 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', 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 |