Commit Graph

65 Commits

Author SHA1 Message Date
Nirbheek Chauhan abf81aab77 Use cross-info c_args, c_link_args, etc for all compiler checks
This allows the user to specify custom arguments to the compiler to be used
while performing cross-compiler checks. For example, passing a GCC specs file as
c_link_args so that a "prefix" filled with libraries that are to be compiled
against can be found with cc.find_library, or an `-mcpu` c_arg that is required
for compilation.

Also ensure that unix_link_flags_to_native() and unix_compile_flags_to_native()
always return a copy of the original arguments and not a reference to the
original arguments. We never want to modify the original arguments.
2016-06-15 13:13:06 +05:30
Nirbheek Chauhan 777c1e9c19 compilers: Fix usage of cross tools args in sanity checks
The cross-extra-flags were being overwritten and ignored. Also, we don't
link while doing a cross-compiled sanity check even with ObjC++
2016-06-15 11:03:28 +05:30
Martin Hostettler 4979b4c84f compiler: Use cross tools args in sanity check. 2016-06-13 00:41:19 +02:00
Jussi Pakkanen d4adf0983b Add special casing for VS which ignores unknown arguments. 2016-06-11 13:27:04 +03:00
Jussi Pakkanen beef7cb291 Added functionality to pick the first supported argument from a list. Closes #583. 2016-06-09 21:36:58 +03:00
Jussi Pakkanen d8d989d9b8 Add a has_arg method to compiler to check whether it supports a given argument. 2016-06-09 21:19:58 +03:00
Nirbheek Chauhan 9f4d963bd9 compilers: Add the buildtype args for checks that perform linking (#543)
This is required for checking for compiler checks that involve linking
to a static library with MSVC. Without this, MSVC errors out since no
CRT is specified.
2016-05-30 21:57:58 +03:00
Jussi Pakkanen a6712b7f20 Can haz next revision of C++ standard. 2016-05-30 20:13:56 +03:00
Jussi Pakkanen 92dfc4eb0b Pch disabling works now. 2016-05-30 20:11:36 +03:00
Nicolas Schneider 60bca15e78 set working dir for sanity check compilation 2016-05-26 12:01:21 +02:00
Nirbheek Chauhan 7aa24c7d0a compilers: Fix header stub change that broke has_function checks on Windows (#559)
Fixes https://github.com/mesonbuild/meson/issues/558
2016-05-26 00:31:51 +03:00
Jussi Pakkanen df03f849a8 Merge pull request #542 from mesonbuild/ownstdlib
Build transparently with a custom standard library
2016-05-25 23:44:24 +03:00
Jussi Pakkanen 255208fd60 Merge pull request #540 from centricular/sanity_check_msvc_fix
Fix the MSVC sanity check to use the generic C/C++ sanity check
2016-05-25 23:41:12 +03:00
Jussi Pakkanen 8119207ee2 Merge pull request #547 from centricular/limits-h_needed_for_stubs
compilers: Always include limits.h to make the stub machinery work
2016-05-25 23:40:44 +03:00
Nirbheek Chauhan 4578e11618 compilers: Always include limits.h to make the stub machinery work
limits.h is a requirement of the C language and is available with all compilers
and platforms from the last two decades. If limits.h is not available, the
compiler only supports an ancient dialect of C and lots of other things will
break too.
2016-05-24 12:18:59 +05:30
Nirbheek Chauhan 3776975203 compilers: Remove duplication in sanity check implementations
Consolidate the C/C++ compiler sanity checks since the test code is almost
exactly the same, and then use that for the MSVC C/C++ compilers as well. All
these sanity checks had diverged because of the code duplication.

This also fixes an intermittent sanity check failure that I was seeing with
MSVC.

Note: The ObjC/C++ compilers can also probably use the same implementation.
2016-05-22 09:36:54 +05:30
Jussi Pakkanen afe7252476 Can specify a stdlib subproject that is used implicitly on all targets with said language. 2016-05-21 21:46:03 +03:00
Jussi Pakkanen 1574471822 Option for GCC STL debug mode. 2016-05-21 16:31:21 +03:00
Nirbheek Chauhan 58386c4df3 compilers: Remove spurious wait while running sanity check
Popen.communicate() already waits for the process to complete.
2016-05-18 03:58:59 +05:30
Nirbheek Chauhan c9f16a4ab1 cc.has_function: Don't forget to check for stubs in the fallback test
The fallback test was making the stub check on Linux/glibc completely useless.

Fixes #535
2016-05-16 07:49:37 +05:30
Nirbheek Chauhan 2300c022c2 has_function: Also detect function implementations inside headers
This also detects when the header has re-defined the symbol to something
else that is then provided by libc, which is also a case we want to
support.
2016-05-04 00:17:27 +05:30
Nirbheek Chauhan aa7202d42f compilers: Remove outdated MSVC implementation of cc.find_library
With the change to cc.links to translate unix link flags, this is no
longer needed and is wrong because it hasn't kept-up with the improved
default cc.find_library implementation.
2016-04-19 14:13:45 +05:30
Nirbheek Chauhan d87f2f5b42 compilers: Convert args to cc.{links,run} from unix to native
This allows build files to pass -L and -l flags and have them converted
automatically as needed.
2016-04-19 00:32:02 +05:30
Nirbheek Chauhan 2c687b02c2 Fix symbol-exists check for cross_sizeof and add the same check to cross_alignment
The previous check was failing while checking pointer sizes such as
void* due to a syntax error.
2016-04-15 18:51:41 +05:30
Nirbheek Chauhan 9a9654c4bd Fix off-by-one in cross_sizeof and cross_alignment on MSVC 2016-04-15 17:49:58 +05:30
Nirbheek Chauhan b56f008f80 compilers: Fix cross_sizeof when the type doesn't exist (#514)
compilers: Fix cross_sizeof when the type doesn't exist
2016-04-14 21:46:09 +03:00
Jussi Pakkanen 5d65c4b678 Merge pull request #490 from centricular/has_function_link
Use the linker to check if a specific function is provided by the toolchain or runtime
2016-04-13 19:09:22 +03:00
Nirbheek Chauhan e72523ae41 compilers: Use compiler-specific no-optimization flags
MSVC doesn't understand -O0. It uses -Od (or /Od) instead.
2016-04-11 04:30:48 +05:30
Nirbheek Chauhan 804a3ca72a compilers: Debug optimization level should be -O0 (#509)
Without any -O options, gcc does not generate properly debuggable code.



> With no -O option at all, some compiler passes that collect information useful

> for debugging do not run at all



gcc recommends -Og, but that isn't supported by clang, so we use -O0



See https://github.com/mesonbuild/meson/pull/509 for more discussion
2016-04-07 22:16:45 +03:00
Nirbheek Chauhan 4e084e7ac1 compilers: Also support built-in functions in cc.has_function 2016-04-07 20:53:12 +05:30
Tim-Philipp Müller 1934ddfc5b Improve cc.has_function() check to not require any includes and detect stubs
We now use .links() to detect if a C compiler function is available
or not, that way the user doesn't need to specify all the possible
includes for the check, which simplifies things considerably.

Also detect glibc stub functions that will never work and return
false for them.

Closes #437
2016-04-07 20:53:12 +05:30
Nirbheek Chauhan 700010e452 New API: cc.has_header_symbol to check if a header defines a specific symbol
Also supports a 'prefix' keyword argument for feature checks such as _GNU_SOURCE
or for headers that need to be included first
2016-04-07 20:53:12 +05:30
Jussi Pakkanen cab5ce4fc0 Merge pull request #438 from trhd/testing_options
New options for controlling test output.
2016-04-06 23:10:20 +03:00
Jussi Pakkanen 737fde65fa Bring back the old manual search to cc.find_library. 2016-04-04 22:18:14 +03:00
Jussi Pakkanen 873ffe782c Merge pull request #390 from nirbheek/msvc-module-defs
Add support for passing a module definitions file for exporting symbols while linking
2016-04-03 18:12:18 +03:00
Jussi Pakkanen e0792295bc Whitespace fixing. 2016-04-03 18:00:41 +03:00
Jussi Pakkanen 6291fb4056 Put buildtype flags to vala compiles. 2016-04-03 16:44:18 +03:00
Jussi Pakkanen 3415c3a693 Add coverage option to compilers. 2016-04-02 19:13:26 +03:00
Hemmo Nieminen 336904b553 Move MesonException from coredata to mesonlib. 2016-04-01 00:52:45 +03:00
Nirbheek Chauhan 1713fa0297 Add shared_library argument for a Visual Studio module definitions file
On MSVC, shared libraries only export symbols that have been explicitly exported
either as part of the symbol prototype or via a module definitions file.

On compilers other than MSVC, all symbols are exported in the shared library by
default and the format for the list of symbols to export is different, so this
is only used with the VisualStudio compiler.

The module defs file path can either be relative to the current source directory
or an absolute path using meson.source_root() + '/some/path'
2016-03-30 16:24:35 +05:30
Jussi Pakkanen 37d7473615 Merge pull request #478 from centricular/sizeof_no_symbol
Return -1 from cc.sizeof if the symbol could not be found
2016-03-28 18:36:35 +03:00
Nirbheek Chauhan a8c6fd6aa4 compilers: Return -1 from cc.sizeof if the symbol could not be found
Allows people to avoid adding a separate check for the symbol existing in case
it's platform-specific
2016-03-28 20:43:15 +05:30
Tim-Philipp Müller 8945c85f96 Fix up typo in precompiled headers base option handling 2016-03-20 22:57:49 +00:00
Jussi Pakkanen d87eb7d290 Merge branch 'base_options'. 2016-03-20 22:04:24 +02:00
Jussi Pakkanen 79de463993 Converted precompiled headers into a base option. 2016-03-20 19:35:42 +02:00
Jussi Pakkanen 0c63f75aaf Converted coverage into a base option. 2016-03-20 19:16:49 +02:00
Jussi Pakkanen 0c9c29b6b6 Preserve b_ prefix for base option names. 2016-03-20 19:00:57 +02:00
Nirbheek Chauhan 57e01c2964 compilers: While linking, filter out libraries that are bundled with the MSVC runtime 2016-03-19 05:39:48 +05:30
Jussi Pakkanen ae1f284ade Added base options to Clang compilers. 2016-03-18 00:36:39 +02:00
Nirbheek Chauhan 64a0dc6269 Implement cc.find_library for the Visual Studio C/C++ compilers
Without this find_library always succeeds because MSVC just ignores -lfoo
as an invalid argument
2016-03-18 02:58:02 +05:30