aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
AgeCommit message (Collapse)AuthorFilesLines
2018-11-03Add new compiler.get_argument_syntax methodDylan Baker1-0/+14
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 Gao1-2/+2
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-26add implib support for ArmclangCompiler (#4420)pbl1-0/+14
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 Seifert1-26/+32
* 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-07Adding "compiler_type" flag to ARM compilers.Mohammed Amer Khalidi1-3/+7
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-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 Seifert1-159/+84
2018-09-16Fix ICC on macOSDavid Seifert1-2/+17
2018-09-16Fix GCC on macOSDavid Seifert1-4/+12
* `common/40 has function` still fails due to alloca being a GCC builtin.
2018-09-16Use enum instead of `int` for compiler variantsDavid Seifert1-68/+69
* 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-11Sprinkle functools.lru_cache() in a few more placesNirbheek Chauhan1-5/+5
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 Baker1-0/+4
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-08-29Improve support for macOS dylib versioningNirbheek Chauhan1-15/+15
We now use the soversion to set compatibility_version and current_version by default. This is the only sane thing we can do by default because of the restrictions on the values that can be used for compatibility and current version. Users can override this value with the `darwin_versions:` kwarg, which can be a single value or a two-element list of values. The first one is the compatibility version and the second is the current version. Fixes https://github.com/mesonbuild/meson/issues/3555 Fixes https://github.com/mesonbuild/meson/issues/1451
2018-08-28Deduplicate build-tree RPATHs on macOSDavid Seifert1-2/+4
* Currently, RPATHs coming from dependencies and `build_rpath` provided by the user might contain the same path. Apple's `install_name` tool is allergic to providing the same argument twice when removing RPATHs: error: install_name_tool: "-delete_rpath /usr/lib" specified more than once
2018-08-28CompilerArgs: -Wl,-lfoo is also a valid way to pass a libraryNirbheek Chauhan1-2/+2
Treat it the same as -lfoo by deduping and adding to --start/end-group Reported at https://gitlab.gnome.org/GNOME/glib/issues/1496 We don't do any advanced transformation for MSVC or de-dup because this is a very rare syntax.
2018-08-27Merge pull request #3981 from GoaLitiuM/d-win-fixesJussi Pakkanen1-6/+15
Fix D support on Windows
2018-08-23CompilerArgs: Allow calling to_native() multiple timesNirbheek Chauhan1-5/+9
Add a keyword argument to to_native() to operate on a copy so that we can call it multiple times instead of modifying the original compiler args while iterating. This is used in the unit test, and might be used in Meson at some point too.
2018-08-23compilers: Handle dupes in the --start/end-group logicOle André Vadla RavnÄs1-3/+4
The index calculated through `self.index()` may find the same flag earlier in the list and end up putting `--end-group` in the wrong spot.
2018-08-22compilers: Reduce sizes of MSVC linked binariesOle André Vadla RavnÄs1-3/+3
- For optimization=s add /O1: Use Maximum Optimization (Favor Size), and remove /Os as it's implied by /O1. - Because we add /O1, this implies /Gy, i.e. Function-Level Linking, so unused code can be omitted. - Add /Gw: Optimize Global Data, so unused data can be omitted. With buildtype=minsize on x86 this reduces the size of a statically linked Vala compiler binary from 5 MB down to just 1.87 MB.
2018-08-22find_library: Use _build_wrapper to get library dirsBruce Richardson1-10/+14
This means that we will take into account all the flags set in the cross file when fetching the list of library dirs, which means we won't incorrectly look for 64-bit libraries when building for 32-bit. Signed-off-by: Nirbheek Chauhan <nirbheek@centricular.com> Closes https://github.com/mesonbuild/meson/issues/3881
2018-08-20UserArrayOption: Allow duplicates when used as <lang>_args optionXavier Claessens1-2/+2
Closes: #4021.
2018-08-20Handle proper linking of MSVC runtime librariesGoaLitiuM1-0/+9
DMD expects mscrtlib arguments while compiling, whereas LDC2 expects these while linking.
2018-08-20Remove optimization related arguments from buildtype args, inline release buildsGoaLitiuM1-6/+6
Dub enables inlining by default for release builds, so meson should do it as well.
2018-08-18Convert buildtype to optimization and debug options (#3489)Jussi Pakkanen1-25/+77
2018-08-15Unconditionally use get_gui_app_args()Jon Turney1-0/+3
Add get_gui_app_args() to the Compiler class so it can be unconditionally used
2018-08-15Explicitly set the Windows subsystem for ninja/VisualCJon Turney1-2/+2
2018-08-11Merge pull request #3831 from mesonbuild/symvisibilityJussi Pakkanen1-0/+15
Add gnu_symbol_visibility keyword argument
2018-08-11PkgConfigDependency: Don't try to resolve internal compiler libsNirbheek Chauhan1-0/+3
-lc -lm -ldl -lrt -lpthread are special linker arguments that should never be resolved to on-disk libraries. Closes https://github.com/mesonbuild/meson/issues/3879
2018-08-09Call it gnu_symbol_visibility instead.Jussi Pakkanen1-12/+12
2018-08-09Add kwarg for specifying symbol visibility.Jussi Pakkanen1-0/+15
2018-07-10Implement get_link_whole_for() for IntelCompiler (#3863)Alberto Sartori1-0/+3
closes #3862
2018-06-21Added ARMCLANG compiler support for C/C++ (#3717)Vasu Penugonda1-0/+80
2018-06-20Rename clike_langs to clink_langs for clarityNirbheek Chauhan1-11/+11
D is not a 'c-like' language, but it can link to C libraries. The same might be true of Rust in the future and Go when we add support for it. This contains no functionality changes.
2018-06-20dependencies: Don't assume self.compiler is a C compilerNirbheek Chauhan1-1/+5
All dependencies were using find_library, has_header, get_define, etc on self.compiler assuming that it's a compiler that outputs and consumes C-like libraries. This is not true for D (and in the future, for Rust) since although they can consume C libraries, they do not use the C ecosystem. For such purposes, we now have self.clib_compiler. Nothing uses self.compiler anymore as a result, and it has been removed.
2018-06-18Add missing stubs to Compiler.Christoph Behle1-0/+12
Added missing stubs to class Compiler for the methods: * compute_int * has_members * has_type * symbols_have_underscore_prefix
2018-06-18Use stub to report misuse of get_defineChristoph Behle1-0/+3
Instead of checking on the call site add a stub to Compiler which raises an exception.
2018-06-18macos: Rewrite install_name for dependent built libraries on installNirbheek Chauhan1-13/+19
On macOS, we set the install_name for built libraries to @rpath/libfoo.dylib, and when linking to the library, we set the RPATH to its path in the build directory. This allows all built binaries to be run as-is from the build directory (uninstalled). However, on install, we have to strip all the RPATHs because they point to the build directory, and we change the install_name of all built libraries to the absolute path to the library. This causes the install name in binaries to be out of date. We now change that install name to point to the absolute path to each built library after installation. Fixes https://github.com/mesonbuild/meson/issues/3038 Fixes https://github.com/mesonbuild/meson/issues/3077 With this, the default workflow on macOS matches what everyone seems to do, including Autotools and CMake. The next step is providing a way for build files to override the install_name that is used after installation for use with, f.ex., private libraries when combined with the install_rpath: kwarg on targets.
2018-06-10vala: fix extract_all_objects() resultPaolo Bonzini1-2/+2
Because vala is not listed in clike_langs, is_source(fname) is returning False for Vala source files. Therefore, extract_all_objects() is completely empty for Vala programs. Fixes #791
2018-06-06compilers: Use RUSTFLAGS from the env as default rust_args valueXavier Claessens1-1/+2
2018-06-06optinterpreter: Remove duplicated list of languagesXavier Claessens1-0/+1
It is important to keep the list of languages up to date in optinterpreter, otherwise we could have conflicting options when adding new languages.
2018-06-06Fix issues found by flake8Xavier Claessens1-1/+0