summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers.py
Commit message (Collapse)AuthorAgeFilesLines
...
* | Fix several more lint errorsNirbheek Chauhan2016-12-201-5/+1
|/ | | | | | | | | | | | | | | | | | | Found by Igor Gnatenko ************* Module mesonbuild.interpreter E:1232,33: No value for argument 'interp' in constructor call (no-value-for-parameter) ************* Module mesonbuild.dependencies E: 68, 4: An attribute defined in mesonbuild.dependencies line 39 hides this method (method-hidden) ************* Module mesonbuild.environment E: 26, 0: class already defined line 19 (function-redefined) E: 68,18: Undefined variable 'InterpreterException' (undefined-variable) E:641,39: Undefined variable 'want_cross' (undefined-variable) E:850,94: Undefined variable 'varname' (undefined-variable) E:854,94: Undefined variable 'varname' (undefined-variable) E:860,102: Undefined variable 'varname' (undefined-variable) E:863,94: Undefined variable 'varname' (undefined-variable) ************* Module mesonbuild.modules.gnome E:438,26: Undefined variable 'compilers' (undefined-variable)
* Fix undefined variables in cross-compile.Elliott Sales de Andrade2016-12-191-4/+4
|
* Merge pull request #1207 from centricular/has-header-preprocess-onlyJussi Pakkanen2016-12-181-27/+45
|\ | | | | has_header: Don't compile, only preprocess
| * compilers: Always pass -pipe to compiler checksNirbheek Chauhan2016-12-181-0/+3
| | | | | | | | | | | | This is obviously much faster. Not sure why we weren't doing it already. Causes a speed-up of about 10-15%
| * has_header: Don't compile, only preprocessNirbheek Chauhan2016-12-181-27/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we're checking for the existence of a header, just running the preprocessor is enough. According to my benchmarks, doing this makes the test roughly 2x faster. I'm sure this will be useful for other checks too in the future. This shaves off 7% on the configure time for glib on my machine. This also fixes the issue that we had earlier where you had to specify any extra headers needed to resolve symbols in the header being checked for with `prefix`.
* | compilers: Ignore -pthread in link flags with MSVCNirbheek Chauhan2016-12-171-0/+3
|/ | | | | Sometimes .pc files add -pthread in Libs: instead of -lpthread, so ignore that too when building with MSVC.
* Only add build dir inlude directives if the corresponding dir exists. Closes ↵Jussi Pakkanen2016-12-131-2/+2
| | | | #1185.
* Merge pull request #1171 from ↵Jussi Pakkanen2016-12-131-2/+9
|\ | | | | | | | | centricular/fix-extracted-generated-prebuilt-object-targets-linking Several fixes to how we handle objects in build targets
| * Also use objects to populate target compilersNirbheek Chauhan2016-12-131-2/+9
| | | | | | | | | | | | | | | | | | This avoids us having no compilers at all for targets that are composed entirely of objects with no sources. Now we will always have a compiler for a target even if it is composed entirely of objects generated with custom targets unless it has completely unknown sources.
* | Merge pull request #1184 from centricular/cc.prefixes_underscoreJussi Pakkanen2016-12-131-13/+53
|\ \ | |/ |/| Add a new compiler function 'symbols_have_underscore_prefix'
| * compilers: Fix output ext while compile-only on MSVCNirbheek Chauhan2016-12-131-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | When doing a compile-only self.compile() check, cl.exe expects an output file of type *.obj, and passing it `output.exe` makes it write the compiled object to `output.exe.obj`. Detect when we're doing a compily-only check and change the suffix ourselves. This is fine most of the time, but fails when you need to inspect the compiled file manually. Also store stdout/stderr on the returned object.
| * New compiler function 'symbols_have_underscore_prefix'Nirbheek Chauhan2016-12-131-0/+34
| | | | | | | | | | | | | | | | | | | | Check if the compiler prefixes an underscore to global symbols. This is useful when linking to compiled assembly code, or other code that does not have its C symbol mangling handled transparently by the compiler. C symbol mangling is platform and architecture dependent, and a helper function is needed to detect it. Eg: Windows 32-bit prefixes underscore, but 64-bit does not. Linux does not prefix an underscore but OS X does.
* | Add Compiler.has_multi_arguments method.Elliott Sales de Andrade2016-12-121-8/+15
|/ | | | It allows checking if a compiler supports a multi-argument option.
* unity builds: Assembly and LLVM IR are incompatibleNirbheek Chauhan2016-12-111-0/+5
| | | | | | | Can't just #include them and use them directly in unity builds. Inline assembly is a thing, but it's not trivial and is deprecated with some compilers. Just build them separately and link them in. Ideally the user would then use LTO to ensure the same result.
* compilers: Implement support for LLVM IR compilationNirbheek Chauhan2016-12-111-4/+9
| | | | | | | | | | | | | Also C++ compilers can build .S assembly files. This wasn't noticed earlier because most people were also using C compilers in their C++ projects and we would fall back to using the C compiler for building the assembly files. Now we have a test for this. This was trivial to add; except that we needed a new LLVM IR rule because the compiler emits warnings if you pass any special arguments to it such as include arguments or dependency arguments. Closes #1089
* Use universal_newlines=True for all Popen callsNirbheek Chauhan2016-12-111-25/+9
| | | | | | | | | | | Instead of adding it everywhere manually, create a wrapper called mesonlib.Popen_safe and use that everywhere that we call an executable and extract its output. This will also allow us to tweak it to do more/different things if needed for some locales and/or systems. Closes #1079
* has_function: Fix checking for builtins with includesNirbheek Chauhan2016-12-101-5/+17
| | | | | | | | | | | | | | | | | | | | | | | We were checking for builtins explicitly like this because the ordinary checks don't work for builtins at all. We do exactly the same check as Autoconf and it doesn't work with Autoconf either (Autoconf is broken!) So now we check for it in two ways: if there's no #include in prefix, we check if `__builtin_symbol` exists (has_function allows checking for functions without providing includes). If there's a #include, we check if `symbol` exists. The old method was causing problems with some buggy toolchains such as MSYS2 which define some builtins in the C library but don't expose them via headers which meant that `__builtin_symbol` would be found even though `symbol` is not available. Doing this allows people to always get the correct answer as long as they specify the includes that are required to find a function while also not forcing people to always specify includes to find a function which is cumbersome. Closes #1083
* Merge pull request #1126 from mesonbuild/sharedmoduleJussi Pakkanen2016-12-071-20/+35
|\ | | | | Support for shared modules
| * Fix shared module support on WindowsNirbheek Chauhan2016-12-071-3/+0
| | | | | | | | | | | | | | | | | | | | | | Unlike Linux and OS X, when a library is loaded, all the symbols aren't loaded into a single namespace. You must fetch the symbol by iterating over all loaded modules. So, we shouldn't use /FORCE:UNRESOLVED since that is not what modules do on Windows. Instead, we now do exactly what GModule does on Windows. Also use `void` for functions that take no arguments.
| * Apply magical flags to make OSX ignore missing symbols in plugins.Jussi Pakkanen2016-12-041-1/+1
| |
| * Tell msvc not to error out on missing symbols.Jussi Pakkanen2016-12-031-0/+3
| |
| * Arg fix.Jussi Pakkanen2016-12-021-6/+6
| |
| * Do not use -install_name or -shared when building modules on OSX,Jussi Pakkanen2016-12-021-12/+27
| | | | | | | | but do use -bundle. Closes #1112.
| * Created new shared module build target type, and make sure ↵Jussi Pakkanen2016-12-021-2/+2
| | | | | | | | -Wl,--no-undefined is not used when linking it.
* | compilers.py: Fix typo in function documentationNirbheek Chauhan2016-12-041-1/+1
| |
* | Compiler check and extra args should always overrideNirbheek Chauhan2016-12-041-14/+45
|/ | | | | | | | | | | | | | | We want compiler check arguments (-O0, -fpermissive, etc) to override all other arguments, and we want extra_args passed in by the build file to always override everything. To do this properly, we must split include arguments out, append them first, append all other arguments as usual, and then append the rest. As part of this, we also add the compiler check flags to the cc.compiles() and cc.links() helper functions since they also most likely need them. Also includes a unit test for all this.
* Add both native and cross compiler options to option list.Jussi Pakkanen2016-11-261-26/+4
|
* Made has_function survive optimization flags. Closes #1053.Jussi Pakkanen2016-11-201-3/+5
|
* Hotfix for cross-compilation from Windows to LinuxNirbheek Chauhan2016-11-141-5/+27
| | | | | | | | | | | | | | We currently pass cross-compiler options to the native compiler too and when cross-compiling from Windows to Linux, `options` will contain Linux-specific options which doesn't include `c_winlibs`. The proper fix is to allow cross-info files to specify compiler options and to maintain both cross and native compiler options in coredata, but that will have to be done after the 0.36.0 release. Also fixes a typo in MinGW cpp_winlibs option setting. Closes #1029
* vala: Implement valac.find_libraryNirbheek Chauhan2016-11-121-56/+77
| | | | | | | | | | | | | Move CCompiler.compile to Compiler.compile so that ValaCompiler can use it. Also rewrite ValaCompiler.sanity_check to use it since it does a simple compile check. At the same time, it enhances ExternalLibrary to support arguments for languages other than C-like. Includes a test for this that links against zlib through Vala. Closes #983
* Merge pull request #1027 from centricular/has-header-prefixJussi Pakkanen2016-11-121-5/+3
|\ | | | | cc.has_header: Allow specifying a prefix for headers
| * cc.has_header: Allow specifying a prefix for headersNirbheek Chauhan2016-11-111-5/+3
| | | | | | | | Fixes #1026
* | compilers: add werror flag for msvcScott D Phillips2016-11-121-0/+3
|/
* Fix debug PCH builds with MSVC 2012 and laterNirbheek Chauhan2016-11-101-3/+12
| | | | | | | | | | With MSVC 2013 and newer, using pre-compiled headers with .pdb debugging fails with the following error message: fatal error C1041: cannot open program database '[...]\prog.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS So we use /FS when PCH is enabled. When PCH is enabled and debugging is disabled, this will have no effect since .pdb files will not be written.
* Merge pull request #1006 from centricular/cpp-has-header-symbolJussi Pakkanen2016-11-091-10/+48
|\ | | | | A bunch of fixes for compiler checks with C++
| * Inherit VisualStudioCPPCompiler from CPPCompilerNirbheek Chauhan2016-11-081-1/+2
| | | | | | | | | | Without this our custom C++ has_header_symbol implementation is not used with the Visual Studio C++ compiler.
| * has_function: Cast to void* instead of intNirbheek Chauhan2016-11-081-1/+1
| | | | | | | | | | | | | | Clang++ doesn't allow that, but void* will always be allowed because lots of projects depend on that. error: cast from pointer to smaller type 'int' loses information
| * has_function: Fix trivial typoNirbheek Chauhan2016-11-081-1/+1
| | | | | | | | This was breaking has_function on C++
| * has_header_symbol: Also detect C++ classes and templatesNirbheek Chauhan2016-11-081-0/+14
| | | | | | | | | | With the `using` keyword we can try to use the specified class or template which will tell us if it exists.
| * has_header_symbol: Make it work with C++ compilersNirbheek Chauhan2016-11-081-7/+30
| | | | | | | | | | | | | | | | | | | | | | Need to pass -fpermissive to force C++ compilers to only warn about our non-conformant code that tests for a symbol being defined. Also do a simple #ifdef check first in has_header_symbol to allow arbitrary macros to be detected which would not have been detected earlier. This follows what AC_CHECK_DECL does. Closes #958
* | javac: Fail gracefully if there's no JVMNirbheek Chauhan2016-11-091-5/+15
|/ | | | | | | | | | | | | | | | Without this, we error out with an exception if `javac` is found but `java` isn't: [...] File "mesonbuild/interpreter.py", line 1759, in detect_compilers comp.sanity_check(self.environment.get_scratch_dir(), self.environment) File "mesonbuild/compilers.py", line 1279, in sanity_check pe = subprocess.Popen(cmdlist, cwd=work_dir) File "/usr/lib64/python3.5/subprocess.py", line 947, in __init__ restore_signals, start_new_session) File "/usr/lib64/python3.5/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'java'
* Merge pull request #949 from centricular/has-function-xcode8-fixesJussi Pakkanen2016-11-021-78/+103
|\ | | | | Fix has_function with XCode 8 and related changes
| * Use *FLAGS from the env in compiler checksNirbheek Chauhan2016-10-261-17/+13
| | | | | | | | | | | | | | | | | | Every other build system does this, and at least OS X, iOS, and Android depend on this to select the OS versions that your application is targetting. At the same time, just use a wrapper for self.run and self.links to share the common (identical) code.
| * has_function: Try to use the function being checkedNirbheek Chauhan2016-10-261-3/+3
| | | | | | | | | | | | Simply placing a reference to it isn't enough for the linker to try and think it's being used and do a symbol availability check with -Wl,-no_weak_imports on OS X ld.
| * Add -Wl,-no_weak_imports to has_function with XCode 8Nirbheek Chauhan2016-10-251-1/+12
| | | | | | | | | | | | This is needed to ensure that symbol availability checks actually fail at link time (instead of at runtime) which is necessary for has_function to work correctly.
| * has_function: Only ignore prototype when no includes are specifiedNirbheek Chauhan2016-10-251-39/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Autoconf-style check we were doing gives false positives when the linker uses the prototype defined in the SDK header to decide whether a function is available or not. For example, with macOS 10.12, clock_gettime is now implemented (alongwith other functions). These functions are always defined in the XCode 8 SDK as weak imports and you're supposed to do a runtime check to see if the symbols are available and use fallback code if they aren't. The linker will always successfully link if you use one of those symbols (without a runtime fallback) even if you target an older OS X version with -mmacosx-version-min. This is the intended behaviour by Apple. But this makes has_function useless because to test if the symbol is available, we must know at link-time whether it is available. To force the linker to do the check at link-time you must use '-Wl,-no_weak_imports` *and* use the prototype in time.h which has an availability macro which tells the linker whether the symbol is available or not based on the -mmacosx-version-min flag. An autoconf-style check would override this prototype and use its own which would result in the linker thinking that the function is always available (a false positive). Worse, this would manifest at runtime and might not be picked up immediately. We now use the function prototype in the user-provided includes if the 'prefix' kwarg contains a `#include` and use the old Autoconf-style check if not. I've tested that the configure checks done by GStreamer and GLib are completely unaffected by this; at least on Linux. The next commit will also add `-Wl,-no_weak_imports` to extra_args by default so that Meson avoids this mess completely. We always want this because the user would not do a has_function check if they have a runtime fallback for the function in their code.
| * compilers: Derive ClangObj*Compiler from ClangCompiler tooNirbheek Chauhan2016-10-251-21/+10
| | | | | | | | The Clang ObjC/++ compiler is the same as the C/++ compiler.
* | Clang also supports gnu89/99/11, gnu++03/11/14/1zNirbheek Chauhan2016-10-301-4/+7
| | | | | | | | | | | | | | | | The list of supported standards is identical for GCC and Clang. We don't list duplicate standard names however, such as c++03 and c++09 https://github.com/llvm-mirror/clang/blob/master/include/clang/Frontend/LangStandards.def
* | compilers: Ignore pthread flags when using MSVCNirbheek Chauhan2016-10-271-2/+3
|/ | | | They don't make sense and just cause a build failure.
* Implement get_default_suffix in the base Compiler classNirbheek Chauhan2016-10-211-10/+3
| | | | This way every compiler has it implemented