Merge pull request #4573 from jon-turney/msys2-clang

More clang for Windows support
pull/4673/head
Jussi Pakkanen 6 years ago committed by GitHub
commit c220816350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      azure-pipelines.yml
  2. 9
      mesonbuild/compilers/compilers.py
  3. 18
      run_unittests.py
  4. 6
      test cases/common/143 C and CPP link/meson.build
  5. 3
      test cases/common/190 openmp/meson.build
  6. 8
      test cases/common/59 exe static shared/meson.build
  7. 5
      test cases/failing build/2 hidden symbol/meson.build
  8. 2
      test cases/windows/12 resources with custom targets/meson.build
  9. 2
      test cases/windows/5 resources/meson.build

@ -100,7 +100,7 @@ jobs:
testResultsFiles: meson-test-run.xml testResultsFiles: meson-test-run.xml
testRunTitle: $(System.JobName) testRunTitle: $(System.JobName)
- job: msys2_mingw - job: msys2
pool: pool:
vmImage: VS2017-Win2016 vmImage: VS2017-Win2016
strategy: strategy:
@ -108,9 +108,15 @@ jobs:
gccx86ninja: gccx86ninja:
MSYSTEM: MINGW32 MSYSTEM: MINGW32
MSYS2_ARCH: i686 MSYS2_ARCH: i686
compiler: gcc
gccx64ninja: gccx64ninja:
MSYSTEM: MINGW64 MSYSTEM: MINGW64
MSYS2_ARCH: x86_64 MSYS2_ARCH: x86_64
compiler: gcc
clangx64ninja:
MSYSTEM: MINGW64
MSYS2_ARCH: x86_64
compiler: clang
variables: variables:
MSYS2_ROOT: $(System.Workfolder)\msys64 MSYS2_ROOT: $(System.Workfolder)\msys64
steps: steps:
@ -124,20 +130,23 @@ jobs:
displayName: Update MSYS2 displayName: Update MSYS2
- script: | - script: |
set PATH=%MSYS2_ROOT%\usr\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem 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 ^ %MSYS2_ROOT%\usr\bin\pacman --noconfirm --needed -S ^
base-devel ^ base-devel ^
git ^ git ^
mercurial ^ mercurial ^
mingw-w64-$(MSYS2_ARCH)-cmake ^ mingw-w64-$(MSYS2_ARCH)-cmake ^
mingw-w64-$(MSYS2_ARCH)-pkg-config ^
mingw-w64-$(MSYS2_ARCH)-python2 ^ mingw-w64-$(MSYS2_ARCH)-python2 ^
mingw-w64-$(MSYS2_ARCH)-python3 ^ mingw-w64-$(MSYS2_ARCH)-python3 ^
mingw-w64-$(MSYS2_ARCH)-python3-setuptools ^ mingw-w64-$(MSYS2_ARCH)-python3-setuptools ^
mingw-w64-$(MSYS2_ARCH)-toolchain %TOOLCHAIN%
displayName: Install Dependencies displayName: Install Dependencies
- script: | - script: |
set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem 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" %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 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" %MSYS2_ROOT%\usr\bin\bash -lc "MSYSTEM= python3 run_tests.py --backend=ninja"
env: env:
CHERE_INVOKING: yes CHERE_INVOKING: yes

@ -1545,6 +1545,10 @@ class GnuLikeCompiler(abc.ABC):
# GNU ld and LLVM lld # GNU ld and LLVM lld
return ['-Wl,--allow-shlib-undefined'] 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): class GnuCompiler(GnuLikeCompiler):
""" """
@ -1583,11 +1587,6 @@ class GnuCompiler(GnuLikeCompiler):
def get_pch_suffix(self): def get_pch_suffix(self):
return 'gch' 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): def openmp_flags(self):
return ['-fopenmp'] return ['-fopenmp']

@ -1970,6 +1970,11 @@ class AllPlatformTests(BasePlatformTests):
https://github.com/mesonbuild/meson/issues/1646 https://github.com/mesonbuild/meson/issues/1646
''' '''
testdir = os.path.join(self.common_test_dir, '5 linkstatic') 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.init(testdir, extra_args='-Db_lto=true')
self.build() self.build()
self.run_tests() self.run_tests()
@ -2188,7 +2193,9 @@ int main(int argc, char **argv) {
'/NOLOGO', '/DLL', '/DEBUG', '/IMPLIB:' + impfile, '/NOLOGO', '/DLL', '/DEBUG', '/IMPLIB:' + impfile,
'/OUT:' + outfile, objectfile] '/OUT:' + outfile, objectfile]
else: 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] link_cmd = compiler.get_exelist() + ['-shared', '-o', outfile, objectfile]
if not mesonbuild.mesonlib.is_osx(): if not mesonbuild.mesonlib.is_osx():
link_cmd += ['-Wl,-soname=' + os.path.basename(outfile)] 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 is true and not when it is false. This can't be an ordinary test case
because we need to inspect the compiler database. 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') raise unittest.SkipTest('PIC not relevant')
testdir = os.path.join(self.common_test_dir, '3 static') testdir = os.path.join(self.common_test_dir, '3 static')
@ -4757,7 +4764,10 @@ class NativeFileTests(BasePlatformTests):
# invokes our python wrapper # invokes our python wrapper
batfile = os.path.join(self.builddir, 'binary_wrapper{}.bat'.format(self.current_wrapper)) batfile = os.path.join(self.builddir, 'binary_wrapper{}.bat'.format(self.current_wrapper))
with open(batfile, 'wt') as f: 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 return batfile
def helper_for_compiler(self, lang, cb): def helper_for_compiler(self, lang, cb):
@ -4802,6 +4812,8 @@ class NativeFileTests(BasePlatformTests):
def test_config_tool_dep(self): def test_config_tool_dep(self):
# Do the skip at this level to avoid screwing up the cache # 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'): if not shutil.which('llvm-config'):
raise unittest.SkipTest('No llvm-installed, cannot test') raise unittest.SkipTest('No llvm-installed, cannot test')
self._simple_test('config_dep', 'llvm-config') self._simple_test('config_dep', 'llvm-config')

@ -36,7 +36,11 @@ if cxx.get_argument_syntax() == 'msvc'
compile_cmd = ['/c', '@INPUT@', '/Fo@OUTPUT@'] compile_cmd = ['/c', '@INPUT@', '/Fo@OUTPUT@']
stlib_cmd = [static_linker, '/OUT:@OUTPUT@', '@INPUT@'] stlib_cmd = [static_linker, '/OUT:@OUTPUT@', '@INPUT@']
else 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@'] stlib_cmd = ['ar', 'csr', '@OUTPUT@', '@INPUT@']
endif endif

@ -13,6 +13,9 @@ endif
if cc.get_id() == 'clang-cl' if cc.get_id() == 'clang-cl'
error('MESON_SKIP_TEST clang-cl does not support OpenMP.') error('MESON_SKIP_TEST clang-cl does not support OpenMP.')
endif 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' if host_machine.system() == 'darwin'
error('MESON_SKIP_TEST macOS does not support OpenMP.') error('MESON_SKIP_TEST macOS does not support OpenMP.')
endif endif

@ -1,8 +1,12 @@
project('statchain', 'c') project('statchain', 'c')
subdir('subdir') subdir('subdir')
# Test that -fPIC in c_args is also accepted # Test that -fPIC in c_args is also accepted (on platforms where it's permitted)
statlib2 = static_library('stat2', 'stat2.c', c_args : '-fPIC', pic : false) 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 # Test that pic is needed for both direct and indirect static library
# dependencies of shared libraries (on Linux and BSD) # dependencies of shared libraries (on Linux and BSD)
statlib = static_library('stat', 'stat.c', link_with : [shlib, statlib2], pic : true) statlib = static_library('stat', 'stat.c', link_with : [shlib, statlib2], pic : true)

@ -1,10 +1,7 @@
project('hidden symbol', 'c') project('hidden symbol', 'c')
if host_machine.system() == 'windows' or host_machine.system() == 'cygwin' if host_machine.system() == 'windows' or host_machine.system() == 'cygwin'
cc = meson.get_compiler('c') error('MESON_SKIP_TEST -fvisibility=hidden does not work for PE files.')
if cc.get_id() == 'gcc'
error('MESON_SKIP_TEST -fvisibility=hidden does not work on MinGW or Cygwin.')
endif
endif endif
l = shared_library('bob', 'bob.c', l = shared_library('bob', 'bob.c',

@ -3,7 +3,7 @@ project('winmain', 'c')
# MinGW windres has a bug due to which it doesn't parse args with space properly: # MinGW windres has a bug due to which it doesn't parse args with space properly:
# https://github.com/mesonbuild/meson/pull/1346 # https://github.com/mesonbuild/meson/pull/1346
# https://sourceware.org/bugzilla/show_bug.cgi?id=4933 # 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 # Construct build_to_src and skip this test if it has spaces
# because then the -I flag to windres will also have spaces # because then the -I flag to windres will also have spaces
# and we know the test will fail # and we know the test will fail

@ -3,7 +3,7 @@ project('winmain', 'c')
# MinGW windres has a bug due to which it doesn't parse args with space properly: # MinGW windres has a bug due to which it doesn't parse args with space properly:
# https://github.com/mesonbuild/meson/pull/1346 # https://github.com/mesonbuild/meson/pull/1346
# https://sourceware.org/bugzilla/show_bug.cgi?id=4933 # 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 # Construct build_to_src and skip this test if it has spaces
# because then the -I flag to windres will also have spaces # because then the -I flag to windres will also have spaces
# and we know the test will fail # and we know the test will fail

Loading…
Cancel
Save