summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/c.py
Commit message (Collapse)AuthorAgeFilesLines
* cross: Be more permissive about not-found exe_wrappernirbheek/exe-wrapper-compiler-fallbacksNirbheek Chauhan2018-07-091-4/+7
| | | | | | | | | | | | | | | | | | | | | | We used to immediately try to use whatever exe_wrapper was defined in the cross file, but some people generate the cross file once and use it for several projects, most of which do not even need an exe wrapper to build. Now we're a bit more resilient. We quietly fall back to using non-exe-wrapper paths for compiler checks and skip the sanity check. However, if some code needs the exe wrapper, f.ex., if you run a built executable using custom_target() or run_target(), we will error out during setup. Tests will, of course, continue to error out when you run them if the exe wrapper was not found. We don't want people's tests to silently "pass" (aka skip) because of a bad CI setup. Closes https://github.com/mesonbuild/meson/issues/3562 This commit also adds a test for the behaviour of exe_wrapper in these cases, and refactors the unit tests a bit for it.
* cross: Use ExternalProgram for cross-file exe_wrapperNirbheek Chauhan2018-07-091-5/+4
| | | | | | We already have code to fetch and find binaries specified in a cross file, so use the same code for exe_wrapper. This allows us to handle the same corner-cases that were fixed for other cross binaries.
* find_library: Only run link test on system dirsNirbheek Chauhan2018-07-041-11/+16
| | | | | | | Paths provided to us by the user or by pkg-config can be (and must be) assumed to be usable since they might not be usable standalone. Closes https://github.com/mesonbuild/meson/issues/3832
* prune nonexistent dirs from library search pathBruce Richardson2018-07-031-1/+1
| | | | | | Rather than storing in the cache of search paths the full list returned from the compiler and having each call ignore the non-existent ones, remove from the list all non-existent ones before returning to the caching function.
* fix find_library when cross-compiling 32-bit on 64-bit systemsBruce Richardson2018-06-301-1/+11
| | | | | | | | | | | | | When find_library is used to find dependencies, meson checks all paths for libraries with all prefixes that could match. This means that when we are compiling with -m32 on a 64-bit system, meson will find 64-bit libraries and assumes that they will work. Naturally that is not the case. The obvious fix is to do a test link against those libraries, but the extra wrinkle here is that we need to do a "whole link" so as to test the static libs. A check with gcc+ld on linux shows that unless there are unresolved symbols from the main.c file, the static library is never checked so we avoid the error from an incompatible library.
* Return a better warning if compiled executable is invalid.Jussi Pakkanen2018-06-241-1/+4
|
* Added ARMCLANG compiler support for C/C++ (#3717)Vasu Penugonda2018-06-211-0/+29
|
* macos: Rewrite install_name for dependent built libraries on installNirbheek Chauhan2018-06-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* pkgconfig deps: Also resolve paths to shared librariesNirbheek Chauhan2018-06-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | This allows us to more aggressively de-dup them, and also sets RPATHs to all libraries that are not in the system linker paths so that binaries can be run uninstalled without any special steps. These RPATHs will be wiped on install, so they do not affect reproducible builds. De-duping: Fixes https://github.com/mesonbuild/meson/issues/2150 Fixes https://github.com/mesonbuild/meson/issues/2118 Fixes https://github.com/mesonbuild/meson/issues/3071 RPATHs: Fixes https://github.com/mesonbuild/meson/issues/314 Fixes https://github.com/mesonbuild/meson/issues/2881 Also fixes the uninstalled usage portions of: https://github.com/mesonbuild/meson/issues/3038 https://github.com/mesonbuild/meson/issues/3077
* Always apply concatenate_string_literal.Christoph Behle2018-06-121-1/+1
| | | | | get_define always applies concatenate_string_literal to its result. Remove kwarg concatenate_string_literal from get_define.
* Make concatenate_string_literals staticChristoph Behle2018-06-121-1/+2
|
* get_define can concatenate string literals.Christoph Behle2018-06-121-1/+10
| | | | | | | Added method concatenate_string_literals to CCompiler. Will concatenate string literals. Added keyword argument 'concatenate_string_literals' to Compiler.get_define. If used will apply concatenate_string_literals to its return value.
* Revert changeChristoph Behle2018-06-121-2/+2
|
* Concatenate string literals in get_defineChristoph Behle2018-06-121-3/+4
| | | | | If get_define returns a list of string_literals concatenate them into one string.
* find_library: Add a cache for library searchingNirbheek Chauhan2018-06-071-6/+18
| | | | | | | | | Otherwise we can end up searching for the same library tens of times, because pkg-config does not de-duplicate -lfoo args before returning them. We use -Wl,--start-group/end-group, so we do not need to worry about ordering issues in static libraries.
* Fix issues found by flake8Xavier Claessens2018-06-061-1/+1
|
* Move <lang>_args to coredata.compiler_optionsXavier Claessens2018-06-061-3/+3
|
* Compilers: Chain-up to parent class in get_options()Xavier Claessens2018-06-061-23/+30
| | | | | Parent class could have common options for all compilers, and we'll soon add some.
* Add prog/lib dirs from the mingw cross-compiler to PATHNirbheek Chauhan2018-06-051-2/+25
| | | | | These directories contain DLLs that the executable may need, such as libstdc++-6.dll, libwinpthread, etc.
* New compiler method: check_headerNirbheek Chauhan2018-05-301-0/+6
| | | | | | | | This checks not only for existence, but also for usability of the header, which means it does a full compilation and not just pre-processing or __has_include. Fixes https://github.com/mesonbuild/meson/issues/2246
* Add support for finding libraries in Fortran projectsMatthew Krupcale2018-05-211-2/+5
| | | | | | | | * mesonbuild/compilers/c.py: Make the `find_library` method more generic by allowing the user to supply the `code` for compiling and linking. * mesonbuild/compilers/fortran.py: Use the methods inherited from `Compiler` base class where appropriate. Also reuse `CComiler` methods where applicable. This should be sufficient to get various compiler/linker arguments as well as to compile and link Fortran programs. This was tested with `gfortran` compiler, and while the other compilers ought to work for simple cases, their methods are primarily inherited from the base `FortranCompiler` class. * test cases/fortran/10 find library/gzip.f90: Fortran module with some basic Fortran wrapper interfaces to `gzopen`, `gzwrite`, and `gzclose` C `zlib` functions. * test cases/fortran/10 find library/main.f90: Fortran program using the `gzip` Fortran interface module to write some data to a gzip file. * test cases/fortran/10 find library/meson.build: Meson build file for this test case. This demonstrates the ability to link the Fortran program against an external library.
* Revert "Add macOS linker versioning information"Nirbheek Chauhan2018-05-091-1/+1
| | | | | | This reverts commit fa6ca160548d7e8df9c4c724e6c96f5e004e5316. Closes https://github.com/mesonbuild/meson/issues/3550
* has_multi_link_arguments: Some compilers needs -Wl,--fatal-warningsXavier Claessens2018-04-301-0/+14
| | | | ld does not treat wrong -z options as fatal by default.
* CCompiler: Cache result of get_library_dirs().Martin Hostettler2018-04-271-1/+9
| | | | It is repeatedly used by e.g. guess_external_link_dependencies.
* CCompiler: Do not call to_native() twiceXavier Claessens2018-04-191-1/+1
| | | | | | | compile() method already does it so links() and compiles() shouldn't do it too. This fix regression introduced in 3d91a08b. Closes #3431
* Merge pull request #3353 from xclaesse/has-link-argumentJussi Pakkanen2018-04-171-37/+38
|\ | | | | Add has_link_argument() and friends
| * Add has_link_argument() and friendsXavier Claessens2018-04-161-12/+28
| | | | | | | | Closes: #3335.
| * Compilers: Reduce code duplication between compiles and linksXavier Claessens2018-04-161-26/+11
| | | | | | | | This also fix links() not calling args.to_native() unlike compiles()
* | Merge pull request #1852 from QuLogic/openmpJussi Pakkanen2018-04-171-0/+5
|\ \ | | | | | | Add an OpenMP dependency.
| * | Add an OpenMP dependency.Elliott Sales de Andrade2018-04-171-0/+5
| |/ | | | | | | | | This works similarly to the thread dependency which stores the various inconsistent flags in each compiler.
* | cc.has_multi_arguments: Convert all -Wno argsNirbheek Chauhan2018-04-171-6/+6
| | | | | | | | Also add a test for it.
* | fix checks for gcc disable warning flagsBruce Richardson2018-04-171-0/+5
|/ | | | | | | | | | GCC does not print a warning or error for unknown options if the options are to disable warnings. Therefore, when checking for options starting '-Wno-', also check the opposite enabling option. This fixes the case where e.g. -Wno-implicit-fallthrough is incorrectly reported as supported by gcc 5.4. To avoid missed warnings when using combinations of flags, such as in test case "112 has arg", we limit the checking of for the positive option to where the negative option is checked alone.
* Merged Arm CC support.Jussi Pakkanen2018-04-161-0/+20
|\
| * Updates to CPP support and update review changesSomasekhar Penugonda2018-03-271-40/+20
| |
| * - Updating cpp_std options similar to other compiler classesBedarkar, Malhar2018-03-141-20/+0
| | | | | | | | | | | | | | - Updating environment.py for selecting '--vsn' option for armcc only. - Updating build type arguments from GitHub pull request - 3157 Change-Id: Id3151e7715ec1016afdbd65391bb0d414ec7de13
| * Meson Github pull request - 3186 requested changesSomasekhar Penugonda2018-03-071-0/+3
| | | | | | | | | | - Fixing flake8 error in compilers.py - [E124] closing bracket does not match visual indentation - Updating ARMCCompiler constructor in c.py to raise error as per comments
| * First cut of ARMCC support for MESON.Bedarkar, Malhar2018-03-051-0/+57
| | | | | | | | Change-Id: I15d8258e84d392baaccb8f670e33eefcfe8cd49a
* | Add macOS linker versioning informationTom Schoonjans2018-04-161-1/+1
| | | | | | | | | | | | This patch exploits the information residing in ltversion to set the -compatibility_version and -current_version flags that are passed to the linker on macOS.
* | Merge pull request #3115 from makise-homura/e2k-lcc-supportJussi Pakkanen2018-04-151-0/+24
|\ \ | | | | | | Support lcc compiler for e2k (Elbrus) architecture
| * | Fixed lchmod detection for lcc C/C++ compilersmakise-homura2018-03-211-0/+8
| | |
| * | Added Elbrus lcc compilers support as inheritance from gcc onesmakise-homura2018-03-191-0/+16
| |/
* | ninjabackend: Try to guess library dependencies for linker invocation.Martin Hostettler2018-04-151-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The linkers currently do not support ninja compatible output of dependencies used while linking. Try to guess which files will be used while linking in python code and generate conservative dependencies to ensure changes in linked libraries are detected. This generates dependencies on the best match for static and shared linking, but this should not be a problem, except for spurious rebuilding when only one of them changes, which should not be a problem. Also makes sure to ignore any libraries generated inside the build, to keep the optimisation working where changes in a shared library only cause relink if the symbols have changed as well.
* | compilers: Cache compiler checks where we don't want the outputNirbheek Chauhan2018-04-141-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | This caching is only for a single run, so it doesn't help reconfigure. However, it is useful for subproject setups where different subprojects will run the same compiler checks. The cache is also per compiler instance and is not used for functions that want to read or run the outputted object file or binary. For gst-build, this halves the number of compiler checks that are run and reduces configuration time by 20%.
* | Remove arbitrary [-1024,1024] limit in cross_compute_int()Xavier Claessens2018-04-081-13/+41
| | | | | | | | | | | | | | | | | | Copy the algorithm used by autoconf. It computes the upper and lower limits by starting at [-1,1] and multiply by 2 at each iteration. This is even faster for small numbers (the common case), for example it finds value 0 in just 2 compilations where old algorithm would check for 1024, 512, ..., 0.
* | Support data types larger than 128 bytesThierry Reding2018-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent versions of systemd (starting with v238) started to check for the existence of the statx structure using the cc.sizeof() operation. The cc compiler implementation fails to detect this structure because it's size limit is 128, meaning it will fail for any type larger than 128 bytes in the following way during cross-compilation checks: meson.build:10:2: ERROR: Cross-compile check overflowed Increase the size limit for data types to 1024 bytes, which should give plenty of room for even large data structures. This is obviously not guaranteed to be an upper bound, but given the binary search algorithm implemented in the cross-compile check, raising the limit too high may significantly increase the time required for this check on smaller data types. Signed-off-by: Thierry Reding <treding@nvidia.com>
* | Enable b_ndebug on VisualStudioCCompilerAleksey Filippov2018-03-231-1/+1
| |
* | Do not use bare except [flake8]Aleksey Filippov2018-03-111-2/+2
|/ | | | | Use more specific exception types where appropriate. This patch does not change bare except calls if exception is re-raised.
* pkgconfig deps: Warn when a static library isn't foundNirbheek Chauhan2018-02-201-1/+4
| | | | | | | | | | | | A hard error makes this feature useless in most cases since a static library usually won't be found for every library, particularly system libraries like -lm. Instead, warn so the user can provide the static library if they wish. This feature will be expanded and made more extensible and more usable in the future. Closes https://github.com/mesonbuild/meson/issues/2785
* Don't use --export-dynamic on CygwinJon Turney2018-02-081-1/+1
| | | | | | | | | | | | | | | | | | After PR #2662, running test case common/125 shared module/ on Cygwin gets me: $ ninja -C _build ninja: Entering directory `_build' [7/7] Linking target prog.exe. /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: warning: --export-dynamic is not supported for PE+ targets, did you mean --export-all-symbols? Also, fix doc for correct version of first apperance. Future work: Notwithstanding the hint that ld gives, these options are not equivalent, and it's not clear we should be using it here: --export-all-symbols is the default behaviour, and if the exports are restricted by explicit annotations or a .def file, this option might be overriding that...
* Use os.path: basename() and dirname() instead of split()Aleksey Filippov2018-01-301-6/+6
| | | | | | | | | | | | According to Python documentation[1] dirname and basename are defined as follows: os.path.dirname() = os.path.split()[0] os.path.basename() = os.path.split()[1] For the purpose of better readability split() is replaced by appropriate function if only one part of returned tuple is used. [1]: https://docs.python.org/3/library/os.path.html#os.path.split