Commit Graph

215 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
Jussi Pakkanen 90c799fc61 Do not use lundef on OSX. 2016-03-17 22:52:55 +02:00
Jussi Pakkanen 8b6848ebc3 Add dir support for find_library and remove deprecated standalone version. Closes #450. 2016-03-17 20:55:19 +02:00
Jussi Pakkanen 19046fd854 Added new base options and some sample opts for gcc. 2016-03-16 21:55:03 +02:00
Jussi Pakkanen 9c5bda3f40 Return array by value so it does not get modified. 2016-03-12 17:32:43 +02:00
Jussi Pakkanen 6b548a1c75 Added find_library method and deprecated the standalone version. Closes #396. 2016-03-12 17:00:55 +02:00
Jussi Pakkanen c6138fe8bd .ipp is a C++ header suffix. 2016-02-26 22:52:36 +02:00
Nirbheek Chauhan d95a108503 compilers: MSVC does not understand the -lfoo syntax
MSVC requires import libraries called foo.lib for linking to foo.dll, so
translate -lfoo to that. If foo.lib doesn't exist, linking will fail as
expected.
2016-02-21 13:44:43 +02:00
Martin Ejdestig a179d07fd1 Do not pass -Weverything to Clang at warning level 3
-Weverything is not a good match for behavior of other compilers at warning
level 3. Align flags with what Meson passes to GCC instead.

The warnings generated are often conflicting with what the user most
probably wants. E.g.:

* -Wc++98-compat does not make sense when building code that uses -std= to
  set a later standard.

* -Wpadding warns when compiler pads classes and structs for better
  performance, probably something the user wants.

These warnings, and maybe a couple of others, can of course be disabled by
Meson with -Wno-* but it is not future proof (other warnings that makes
sense to disable by default may be added which means Meson will probably
have to pass different flags depending on the Clang version).

It is also problematic to compile many system and library headers with
-Weverything. For instance:

* stdio.h and sigaction.h on Linux makes use of recursive macros
  (-Wdisabled-macro-expansion).

* Many library headers make use of deprecated functionality (-Wdeprecated).

* Many library (e.g. GTK+ and Qt) headers trigger Clang's Doxygen warnings
  (-Wdocumentation-unknown-command and -Wdocumentation).

There are a couple of more warnings that need to be disabled when building
files that use GTK+ and Qt. GTest is also problematic.

Maybe it would make sense to add a higher level, where -Weverything would
be passed to Clang, that aligns with the original intent of -Weverything.
See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20121029/067071.html .
GCC does not have a similar flag though. I do not know about other
compilers (MSVC etc).
2016-02-20 21:51:32 +01:00
Jussi Pakkanen 53e90acda9 Fix Vala cross compilation. Closes #370. 2016-02-17 22:15:32 +02:00
Nirbheek Chauhan deff35eef6 Filter out UNIX flags from external deps when using the MSVC compiler
This is very useful to prevent compiler noise about invalid cflags; particularly
for the -mms-bitfields cflag which most libraries send to the mingw-gcc
compiler. More can be added later.
2016-02-17 20:22:34 +02:00
Nirbheek Chauhan 3dd039487e compilers: /LD is not needed for PIC support in DLLs
On Windows, the advantages of PIC are provided by the runtime DLL loader. /LD is
also only valid as an argument to cl.exe, and the linker link.exe just barfs
when it sees it.

The code assumes that the compiler is the same as the linker which caused this
problem to occur.
2016-02-17 19:49:31 +02:00
Nirbheek Chauhan 3fcd056e86 compilers: Don't pass /D for debugoptimized build type
/D is the same as -D and stands for define not debug. Passing this would swallow
the next argument.
2016-02-17 14:28:19 +05:30
Jussi Pakkanen 819da091c2 Use deterministic mode in ar when it is available. 2016-02-12 23:42:20 +02:00
Jussi Pakkanen 6a3e29ccd4 If test exes can not be removed (because e.g. an antivirus program holds on to the file), just leave them behind. Closes #378. 2016-02-03 13:27:58 +11:00
Jussi Pakkanen 23b98cd6e6 Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir. 2016-01-16 17:35:29 +02:00