aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
AgeCommit message (Collapse)AuthorFilesLines
2018-11-04Use lld-link with clang-clJon Turney1-1/+6
Use lld-link dynamic linker with clang-cl Don't hardcode dynamic linker name in tests
2018-11-04Qualify checks of self.version by self.id in VisualStudioC/CPPCompilerJon Turney2-10/+17
2018-11-04Teach VisualStudioCCompiler.get_pch_use_args() to handle clang-clJon Turney1-0/+2
It seems that clang-cl isn't quite compatible with cl in the way it handles pch, and when the precompiled header is used, the pathname of the header is needed, not just its filename. This fixes test\common\13 pch with clang-cl
2018-11-04Teach VisualStudioCCompiler.has_arguments() about clang-clJon Turney1-0/+2
When invoked as clang-cl to compile, it doesn't emit cl-compatible D9002 warnings about unknown options, but fortunately also supports -Werror-unknown-argument instead. When invoked to link, and using LINK, it does emit cl-compatible LNK4044 warnings about unknown options.
2018-11-04Only add link arguments when needed in Compiler object methodsJon Turney2-0/+4
Currently, ComplierHolder.determine_args() unconditionally adds the link arguments to the commmand, even if we aren't linking, because it doesn't have access to the mode (preprocess, compile, link) that _get_compiler_check_args() will use. This leads to command lines like: 'cl testfile.c /nologo /showIncludes /c /Fooutput.obj /Od kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib' which clang-cl considers invalid; MSVS cl accepts this, ignoring the unneeded libraries Change from passing extra_args down to _get_compiler_check_args(), to passing down a callback to CompilerHolder.determine_args() (with a bound kwargs argument), so it can consult mode and kwargs to determine the args to use.
2018-11-04Detect clang-cl as msvc-like, not clang-likeJon Turney3-4/+16
Handle clang's cl or clang-cl being in PATH, or set in CC/CXX Future work: checking the name of the executable here seems like a bad idea. These compilers will fail to be detected if they are renamed. v2: Update compiler.get_argument_type() test Fix comparisons of id inside CCompiler, backends and elsewhere v3: ClangClCPPCompiler should be a subclass of ClangClCCompier, as well Future work: mocking in test_find_library_patterns() is effected, as we now test for a subclass, rather than self.id in CCompiler.get_library_naming()
2018-11-03Add new compiler.get_argument_syntax methodDylan Baker2-0/+17
Some compilers try very had to pretend they're another compiler (ICC pretends to be GCC and Linux and MacOS, and MSVC on windows), Clang behaves much like GCC, but now also has clang-cl, which behaves like MSVC. This method provides an easy way to determine whether testing for MSVC like arguments `/w1234` or gcc like arguments `-Wfoo` are likely to succeed, without having to check for dozens of compilers and the host operating system, (as you would otherwise have to do with ICC).
2018-10-30Hoist gen_vs_module_defs_args from Gnu to GnuLike.Josh Gao1-10/+10
Support vs_module_defs when cross-compiling to Windows with clang. Fixes #4434.
2018-10-30Generalize gnulike-targeting-windows checks.Josh Gao3-6/+6
Replace several checks against GCC_MINGW or (GCC_MINGW, GCC_CYGWIN) with is_windows_compiler instead, so that clang and other gcc-like compilers using MinGW work appropriately with vs_module_defs, c_winlibs, and cpp_winlibs. Fixes #4434.
2018-10-28get_base_compile_args: Add -fprofile-correction to -fprofile-useJan Alexander Steffens (heftig)1-2/+2
This allows using the imperfect profiles generated by multithreaded programs. Without the argument, GCC fails to load them. Clang just ignores the argument AFAICT. Fixes https://github.com/mesonbuild/meson/issues/2159
2018-10-27add support for `/permissive-`Nicole Mazzuca1-8/+21
We do this with `std_ver=vc++NM` - `vc++` does not add `/permissive-`, while `std_ver=c++NM` adds `/permissive-`.
2018-10-26add implib support for ArmclangCompiler (#4420)pbl1-0/+14
2018-10-25compilers/c: Fix allow undefined link arg for PE/COFFMarvin Scholz1-0/+3
For PE/COFF it is not possible to allow undefined symbols, so do not try to use the option to do so. While gcc ld silently ignores it, this is not the case for the llvm linker. Fix #4415
2018-10-22add cpp_std support for MSVCNicole Mazzuca1-3/+34
2018-10-20Order rpaths so that internal ones come first.Jussi Pakkanen1-1/+17
2018-10-20Keep absolute rpaths to libraries outside the build dir.Jussi Pakkanen1-10/+13
2018-10-20Add 'b_pie' compiler optionXavier Claessens1-1/+22
On Android executables must be position independent, many distributions enable it by default too for security reasons.
2018-10-14Use relative build-tree RPATHs on macOSDavid Seifert2-30/+33
* This helps with reproducibility on macOS in the same way `$ORIGIN` improves reproducibility on Linux-like systems. * This makes the build-tree more resilient to users injecting rpaths via `LDFLAGS`. Currently Meson on macOS crashes when a build-tree rpath and a user-provided `-Wl,-rpath` in LDFLAGS collide, leading to `install_name_tool` failures. While this still does not solve the root cause, it makes the occurrence much less likely, as users will generally pass absolute `-Wl,-rpath` arguments into Meson.
2018-10-13Added .so to list possible darwin dynamic library suffixes (#4364)gsobala1-1/+1
Occasionally Darwin libraries can be .so rather than .dylib e.g. tensorflow_cc.so tensorflow_cc is a c++ API for Tensorflow (https://github.com/FloopCZ/tensorflow_cc) which was primarily written for Linux but is also compilable on Darwin. Possibly through laziness, possibly just to have consistent filenames, the developers did not opt to change the suffix from the Linux default when this is compiled on Darwin. Also, the Darwin linker will find libraries with a .so suffix if they are in its path. find_library() needs to match the linker behaviour.
2018-10-07d: Allow static library to be passed with -L to dmd/ldcMatthias Klumpp1-2/+6
2018-10-07Adding "compiler_type" flag to ARM compilers.Mohammed Amer Khalidi3-11/+15
2018-10-03Verify library directories as either 32-bit or 64-bitBruce Richardson1-4/+47
In get_library_dirs() we are trusting the compiler to return a correct list of directories to search for libraries, based on whether or not we are compiling 64-bit or 32-bit. Unfortunately, this is often not the case, as 64-bit libraries often are returned when compiling with -m32 on a 64-bit OS. Since system directories do not contain a mix of libraries, the solution here is to check each directory, by picking a .so file in the directory and checking whether its 64-bit or 32-bit. If we can't determine if we want 32-bit or 64-bit, just skip the checks and assume the directory is good.
2018-10-02Merge pull request #4051 from GoaLitiuM/d-debugJussi Pakkanen1-3/+47
D: Add conditional debug compilation flags
2018-10-01msvc: Don't use /O3 with MSVCMartin Storsjö1-1/+1
MSVC doesn't support that option, and warns about ignoring an unknown option.
2018-10-01compilers/c: don't return -pthread for MacOS with any compilerDylan Baker1-12/+2
With GCC, Clang, or ICC, and for C++ Fixes #2628
2018-09-28compilers: Do not use -pthread with clang for darwinMarvin Scholz1-0/+10
Using the -pthread argument is not needed with clang when compiling for darwin, and it results in the warning: warning: argument unused during compilation: '-pthread'
2018-09-27Add conditional debug identifiers for D compilers, and enable for debug buildsGoaLitiuM1-3/+47
Also includes parsing the highest integer level for debug and version.
2018-09-25Don't add rpath linker flags when building for MinGWMartin Storsjö1-0/+2
GNU binutils ld silently ignores -rpath flags when targeting windows (and it is already commented within ninjabackend.py that rpath as concept doesn't exist on windows), and build_rpath_args in VisualStudioCCompiler also returns an empty array. Therefore skip this flag altogether. This fixes linking with lld in MinGW mode, which doesn't support the rpath flag.
2018-09-23linker flags --as-needed and --no-undefined aren't meaningful for PEJon Turney1-2/+4
--as-needed controls ELF-specific functionality (the emission of DT_NEEDED tags) --no-undefined is effectively always on for PE/COFF, as the linkage model always requires symbols to be defined binutils ld silently ignores these flags for PE targets, but lld warns that it's ignoring them, so just don't bother emitting them for PE targets.
2018-09-21Updating compilers.py to add functions - get_optimization_args, ↵Mohammed Amer Khalidi1-0/+28
get_debug_args in ARMCC and ARMCLANG classes.
2018-09-19Fix setting `-Doptimization` breaking buildDavid Seifert1-2/+19
Closes #4206
2018-09-17ICC does not support `-Og`David Seifert1-1/+1
2018-09-17Abstract shared GCC/Clang/ICC methods in GnuLikeCompilerDavid Seifert3-178/+84
2018-09-16Implement thread linker args for D compilersMihails Strasuns1-0/+3
D compilers are configured to have highest priority when chosing linker for targets mixing C/C++/D code and before this change meson would fail to configure gtest target that uses D library as a dependency.
2018-09-16Fix ICC on macOSDavid Seifert3-8/+40
2018-09-16Fix GCC on macOSDavid Seifert1-4/+12
* `common/40 has function` still fails due to alloca being a GCC builtin.
2018-09-16D: Fix some compiler arguments not getting passed through properlyGoaLitiuM1-1/+1
2018-09-16Merge pull request #4175 from GoaLitiuM/d-archfixesJussi Pakkanen1-14/+13
D: Improve target architecture handling
2018-09-16Do not use relative RPATHs on macOS with ICC/GCCDavid Seifert1-1/+2
* Currently, absolute rpaths on macOS are only used with Clang, which breaks Meson builds when using ICC or GCC from Homebrew or MacPorts.
2018-09-16Use enum instead of `int` for compiler variantsDavid Seifert8-146/+129
* Enums are strongly typed and make the whole `gcc_type`/`clang_type`/`icc_type` distinction redundant. * Enums also allow extending via member functions, which makes the code more generalisable.
2018-09-14Refactor D target architecture handlingGoaLitiuM1-14/+13
The stored architecture matches the same format accepted by dub.
2018-09-13Fix flake8 'imported but unused' reportsJon Turney1-1/+0
$ flake8 | grep F401 ./mesonbuild/compilers/d.py:19:1: F401 '.compilers.GCC_CYGWIN' imported but unused ./test cases/unit/35 dist script/replacer.py:3:1: F401 'sys' imported but unused
2018-09-11Sprinkle functools.lru_cache() in a few more placesNirbheek Chauhan2-16/+13
This improves the backend generation time for gst-build from 7.4s to 6.6s. This is probably all the low-hanging fruit we can get, further improvements will probably require refactoring, moving to pathlib.Path or reimplementing CompilerArgs: 222045 0.551 0.000 1.324 0.000 compilers.py:666(__iadd__) 3691 0.230 0.000 0.885 0.000 ninjabackend.py:99(write) 233560 0.441 0.000 0.701 0.000 posixpath.py:75(join) 882 0.141 0.000 0.636 0.001 backends.py:509(generate_basic_compiler_args) 256301 0.248 0.000 0.576 0.000 compilers.py:562(_can_dedup) 37369 0.035 0.000 0.466 0.000 compilers.py:652(extend_direct) 74650 0.067 0.000 0.431 0.000 compilers.py:641(append_direct) 158153 0.089 0.000 0.405 0.000 ninjabackend.py:129(<lambda>) 845 0.064 0.000 0.391 0.000 ninjabackend.py:279(get_target_generated_sources) 58161 0.070 0.000 0.317 0.000 backends.py:217(get_target_generated_dir) 216825 0.175 0.000 0.275 0.000 ninjabackend.py:48(ninja_quote) 845 0.058 0.000 0.255 0.000 ninjabackend.py:2289(guess_external_link_dependencies) 845 0.068 0.000 0.239 0.000 backends.py:793(get_custom_target_provided_libraries) 52101 0.030 0.000 0.237 0.000 compilers.py:716(append) 1319326 0.231 0.000 0.231 0.000 {built-in method builtins.isinstance} 1189117 0.229 0.000 0.229 0.000 {method 'startswith' of 'str' objects} 3235 0.102 0.000 0.228 0.000 compilers.py:614(to_native) Note: there are 845 build targets.
2018-09-07Add method to check for C/C++ function attributesDylan Baker4-1/+161
It's fairly common on Linux and *BSD platforms to check for these attributes existence, so it makes sense to me to have this checking build into meson itself. Autotools also has a builtin for handling these, and by building them in we can short circuit cases that we know that these don't exist (MSVC). Additionally this adds support for two common MSVC __declspec attributes, dllimport and dllexport. This implements the declspec version (even though GCC has an __attribute__ version that both it and clang support), since GCC and Clang support the MSVC version as well. Thus it seems reasonable to assume that most projects will use the __declspec version over teh __attribute__ version.
2018-09-06Make sure static library files are passed properly to the linkerGoaLitiuM1-0/+11
2018-09-06Fix remaining soname and rpath issues on OSXGoaLitiuM1-6/+9
2018-09-06Remove translation of file pathsGoaLitiuM1-5/+0
This would also pass all the source and object files to linker, which is not desirable.
2018-09-06Refactor D argument translation functionGoaLitiuM1-23/+45
2018-09-06Improve D link argument handlingGoaLitiuM1-4/+3
2018-09-05D: Fix linking errors with static D libraries on WindowsGoaLitiuM1-0/+11