Commit Graph

145 Commits

Author SHA1 Message Date
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