Commit Graph

1079 Commits

Author SHA1 Message Date
Dylan Baker 68c23a6120 Add option to to transpile Cython to C++
This patch adds a new meson built-in option for cython, allowing it to
target C++ instead of C as the intermediate language. This can, of
course, be done on a per-target basis using the `override_options`
keyword argument, or for the entire project in the project function.

There are some things in this patch that are less than ideal. One of
them is that we have to add compilers in the build layer, but there
isn't a better place to do it because of per target override_options.
There's also some design differences between Meson and setuptools, in
that Meson only allows options on a per-target rather than a per-file
granularity.

Fixes #9015
2021-09-24 22:56:46 +03:00
Dylan Baker 9795323b86 pylint: check for duplicate imports
I ran into one of these from LGTM, and it would be nice if pylint could
warn me as part of my local development process instead of waiting for
the CI to tell me.
2021-09-24 10:36:05 -07:00
Andrea Pappacoda 68eca11cc6 Use -Oz when optimization=s in Clang
-Oz is the appropriate flag to use when you want to produce the smallest
possible binary, and is one would expect when setting optimization to s
or using the minsize build type.
2021-09-21 09:58:48 -07:00
Rohit Goswami 32ba349f0a compilers: Use standards compliant test 2021-09-20 01:29:59 -04:00
miebka 59fe80602e C2000: Added depfile generation for incremental builds 2021-09-16 02:37:13 +03:00
Eli Schwartz 87e13af1c8
apply flake8 fixes for unused imports and missing imports 2021-09-14 15:55:07 -04:00
Eli Schwartz cbfdfca089
compilers: publicly export one more constant
It is imported from a subpackage in __init__ alongside a big list of
other things which are all exported. And elsewhere, this import is
re-imported by other code. It's pretty clearly an oversight that it
didn't get added to __all__
2021-09-14 15:50:29 -04:00
Mat Cross 85a5aed60f nagfor preprocessor flag. 2021-09-10 16:08:57 -04:00
Mat Cross 436a257c50 Comments on nagfor options setup. 2021-09-10 16:08:57 -04:00
Mat Cross 0e86258748 Implemented some missing operation for the NAG Fortran Compiler. 2021-09-10 16:08:57 -04:00
Eli Schwartz 3f796c43df objc/objcpp compiler: accept all gnu stds corresponding to c/c++ stds
The clang compiler now reimplements and re-checks the c_std and cpp_std
options in order to use them for objc as well, but it didn't
consistently support the same options. First it completely excluded all
the gnu ones, and then it added a handful of them but not for C++.

Be fully consistent -- or at least as consistent as we can be, given a
minimally working fix. (The C/C++ compiler mixin actually gates
different stds depending on detected clang version, we do not do that
here.)

Fixes regression in c54dd63547
Fixes incomplete fix from #8766 (which didn't fix objcpp at all)

Fixes #9237
2021-09-10 13:03:56 -07:00
Paolo Bonzini 8596b3bcd1 interpreter: detect and pass compiler to be used for linker tests
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: #7703
2021-09-07 14:18:33 +02:00
Paolo Bonzini 90ee43463f compilers: allow link tests to use objects from a different compiler
In some cases, link tests would like to use objects provided by a compiler
for a different language, for example linking a C object file with a C++
compiler.  This kind of scenario is what link_language is for, but it is
impossible to test that it works with a linker test.

This patch implements the required support in the Compiler class.  The
source code compiler is passed to the Compiler.links method as an
argument.
2021-09-07 13:38:12 +02:00
Paolo Bonzini 2997480ee6 compilers: do accept None in Compiler.compile extra_args
The type information allows it, but it is not actually handled.
2021-09-07 13:37:37 +02:00
Paolo Bonzini 63ddb8aafa compilers: fix flake8 issues 2021-09-07 13:37:36 +02:00
Evan Miller b8cfb3d131 Support for appleframeworks with GCC and Intel
Fixes #8792
Fixes #8733
2021-09-04 01:29:35 +03:00
Dylan Baker 9bf669a016
Clang should error for all implicit function checks (#9165)
* compilers: improve docstring to `get_compiler_check_args()`

There was an incomplete list, which wasn't useful as it now takes an
enum anyway. Also add a new entry to the list of reasons to use this
function.

* clang: Add -Werror=implicit-function-declarations to check_args

Unlike GCC, clang warns but doesn't error when an implicit function
declaration happens. This means in checks like
`compiler.has_header_symbol('string.h', 'strlcat')` (on Linux, at least)
that GCC will fail, as there is no such function; clang will emit a
warning, but since it exists with a 0 status Meson interprets that as
success. To fix this, add `-Werror=implicit-function-declarations` to
clang's check arguments.

There seems to be something specific about functions that _may_ exist in
a header on a given system, as `cc.has_header_symbol('string.h',
'foobar')` will return false with clang, but `strlcat` will return true,
even though it's not defined. It is however, defined in some OSes, like
Solaris and the BSDs.

Fixes #9140
2021-09-01 22:25:32 +03:00
Xavier Claessens ea02c1c48a msvc: Assume UTF8 source by default
Currently every project that uses UTF8 for its source files must add
'/utf-8' argument otherwise they don't work non-English locale MSVC.

Since meson.build itself is assumed to be UTF8 by default, seems better
to assume it for source files by default too.

For example:
- https://gitlab.freedesktop.org/gstreamer/gst-build/-/blob/master/meson.build#L62
- https://gitlab.gnome.org/GNOME/glib/-/blob/main/meson.build#L29
2021-09-01 19:26:36 +03:00
Dylan Baker 4d7031437c pylint: turn on superflous-parens
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
2021-08-31 16:28:54 -04:00
Tristan Partin be92e37837 Add Java module
The Java module will serve as a source for easing Java development
within Meson. Currently it only supports generating native header files.
2021-08-22 07:57:29 -07:00
Dylan Baker a3c94956c8 compilers: Add get_no_warn_args to the base Compiler class
Because it should be defined there.
2021-08-20 18:57:19 +02:00
Dylan Baker 6d055b1e27 compilers/compilers: Fix some potential issues spotted by pyright
There are two changes here, one is to remove an `elif` that is
effectively an `else`, that helps the type checker and provides a small
speedup potentially. The second is a potentially unbound variable, that
currently isn't hit, but very much could be.
2021-08-16 16:21:51 -07:00
Dylan Baker e3c72ad7c7 compilers: Fix extra_args parameter
which can also be a callable taking a CompileChekcMode as an argumetn
and returning a list of strings.
2021-08-16 16:21:51 -07:00
Dylan Baker e9639be167 compilers: Fix annotations for run and cached_compile
Which absolutely should accept `str | File`, but the annotations claim
that only strings are accepted.
2021-08-16 16:21:51 -07:00
Jussi Pakkanen a90d2925dd Revert "compilers/c++: Add MSVC option to make the __cplusplus define accurate"
This reverts commit 0b97d58548.
2021-08-15 13:18:35 +03:00
Dylan Baker 0b97d58548 compilers/c++: Add MSVC option to make the __cplusplus define accurate
Otherwise it always returns the value for c++98, starting with MSVC 2017
15.7 or later. Earlier versions are not affected by this mis-feature
2021-08-11 21:54:16 +03:00
Jussi Pakkanen f2fe271198 Add support for finding Javascript source libraries with Emscripten. 2021-08-08 15:25:48 +03:00
miebka f8c4752cbc C2000 compiler also accepts *.cla files 2021-07-25 09:07:12 -07:00
David Seifert 28d13f4bfe
Cuda: Enable PGO 2021-07-18 23:14:38 +02:00
David Seifert d648f3497e
Cuda: Filter -isystem with system paths 2021-07-18 23:14:36 +02:00
David Seifert 631abce82f
Cuda: Pass -DNDEBUG through 2021-07-18 23:14:34 +02:00
Paolo Bonzini 3efed376c3 linkers: remove is_shared_module argument to get_soname_args
The argument is now unused, drop it.
2021-07-14 22:53:04 +02:00
Pamplemousse 762c073500 Clang: Apply `-O0`
Fix #8986
2021-07-13 16:40:40 -07:00
Andrea Pappacoda 81d9acab87 Fix unsupported linker error message
An `f` was dropped in bd6f46e723
2021-07-06 11:46:20 -04:00
Eli Schwartz bd6f46e723 condense lines 2021-07-05 17:55:04 +03:00
Eli Schwartz b4b488f33c simplify mesonlib imports for the sake of line lengths 2021-07-05 17:55:04 +03:00
Eli Schwartz dd31891c1f more f-strings too complex to be caught by pyupgrade 2021-07-05 17:55:04 +03:00
miebka 3021f256ea C2000: linker uses now binary setting defined within the cross-file 2021-07-01 01:58:24 +03:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Ian Harvey 84b371c645 Update detect.py
Adjust Intel Fortran compiler detection to handle changes in ifort logo with the introduction of the oneapi toolkit.  See #8338.
2021-06-27 17:50:30 +03:00
Daniel Mensinger b95d6e319f typing: Annotate compilers.detect 2021-06-25 19:34:48 +02:00
Daniel Mensinger 3f889606c7 Split compiler detection from Environment
This moves all the compiler detection logic into the new
compilers.detect module. This dramatically reduces the size
and complexity of Environment.
2021-06-25 19:34:48 +02:00
Justin Handville e8e03cdc72 Fixed style issue as per comments on PR 8911. 2021-06-22 12:46:17 +02:00
Justin Handville 9f248c778d Fix for Issue 8910 (Meson filters CMake asm files) 2021-06-22 12:46:17 +02:00
Daniel Mensinger 66b32a4591 holders: Introduce HoldableObject 2021-06-18 23:48:33 +02:00
Daniel Mensinger 202e345dfb interpreter: Refactor interpreter.compiler to use ObjectHolder 2021-06-18 23:48:33 +02:00
Daniel Mensinger 9c40b33cf6 compilers: Fix missing functions in Compiler base class 2021-06-09 09:46:37 +02:00
Eli Schwartz 998076a192
upgrade percent formatted strings pyupgrade did not catch 2021-06-07 16:51:47 -04:00
Eli Schwartz 3eb1da1fa2
condense lines 2021-06-07 16:51:47 -04:00
Eli Schwartz 2c71b63e77
more f-strings everywhere
pyupgrade didn't catch many .format() methods which were too complex
(e.g. multiline or applied to templates rather than string literals)
2021-06-07 16:51:47 -04:00
Dylan Baker 0bc18f26a2 cython: Add an option for selecting python 3 vs python 2 output 2021-06-07 09:25:32 -07:00
Dylan Baker 4d1cbd1b8a compilers: Add cython file suffixes 2021-06-07 09:16:19 -07:00
Dylan Baker edf1a21722 compilers: Expose Cython compiler 2021-06-07 09:16:18 -07:00
Dylan Baker e9681b463d hack: compilers/cython: hardcode python 3 not 2 2021-06-07 09:15:13 -07:00
Dylan Baker 79e50caa7f compilers: Add a cython Compiler 2021-06-07 09:15:13 -07:00
Daniel Mensinger 240434b167 typing: Fully annotate dependencies.cuda 2021-06-05 12:35:48 +02:00
Dylan Baker 113a159514 use an immutable list for an lru_cached functions
When mutable items are stored in an lru cache, changing the returned
items changes the cached items as well. Therefore we want to ensure that
we're not mutating them. Using the ImmutableListProtocol allows mypy to
find mutations and reject them. This doesn't solve the problem of
mutable values inside the values, so you could have to do things like:

```python
ImmutableListProtocol[ImmutableListProtocol[str]]
```

or equally hacky. It can also be used for input types and acts a bit
like C's const:

```python
def foo(arg: ImmutableListProtocol[str]) -> T.List[str]:
    arg[1] = 'foo'  # works while running, but mypy errors
```
2021-06-02 15:53:17 -07:00
Dylan Baker 156d6160d1 compilers: Add `get_debug_args` to base Compiler
This was missed, there should be an implementation in the base Compiler
class, if for nothing else to help mypy
2021-05-19 23:28:17 +03:00
Dylan Baker b1b8e777a2 rust: override get_linker_always_args
instead of opencoding what should be there in the rust compile rule
2021-05-19 23:28:17 +03:00
Volker-Weissmann 4ca9a16288
.C files are now treated as C++ code 2021-05-19 17:10:22 +03:00
Peter Harris be015a37d7
Visual Studio Address Sanitizer updates
* Allow address sanitizer for Visual Studio 2019 version 16.9

Address Sanitizer was first supported with the current syntax in Visual
Studio 16.9.0 (cl version 19.28.29910).

* VS: Convert /fsanitize=address to project file setting
2021-05-15 18:47:04 +03:00
Jussi Pakkanen ab0b727427 Add gnuXX stds to Objective C. 2021-05-15 18:45:54 +03:00
Jussi Pakkanen c54dd63547 Make objective C use C standard version. Closes #5495. 2021-05-11 22:47:17 +03:00
Alexander Neumann 8f12102549 deactivate intrinsic functions if no optimizations are requested 2021-05-10 19:17:39 +03:00
Ralf Gommers a48a89374a Clean up unused imports 2021-05-02 22:27:40 +03:00
Ralf Gommers d0325c898a Use sanity_check_impl for objc/objpp
This gets rid of compile warnings, and simplifies the code.
Note that `work_dir` in sanity_check_impl was incorrect,
it was used both to prepend to file names and as cwd=work_dir
argument to Popen. This is fixed here.

Closes gh-7344
2021-05-02 22:27:40 +03:00
Dylan Baker f99ed692c4 environment: get environment variables for both host and build machines
Fixes #8605
2021-04-01 09:54:43 -07:00
Dylan Baker 2cd0723c42 Split environment variable and command line cflags
They are supposed to have different behavior. The environment variables
apply to both the compiler and linker when the compiler acts as a
linker, but the command line ones do not.

Fixes #8345
2021-03-30 18:52:17 +03:00
Olexa Bilaniuk 2579420a72 Strip host-compiler -std flag from NVCC line.
Closes #8523.
2021-03-28 20:12:45 +03:00
Olexa Bilaniuk 5941e94ff8 Retract "DQSQ" merging in NVCC arguments handling.
No coverage, no tests, unreadable, unused, likely premature
optimization.
2021-03-28 20:12:45 +03:00
Olexa Bilaniuk 3dbd493de2 Canonicalize and merge consecutive -Xcompiler flags together.
Makes command-line more readable.
2021-03-28 20:12:45 +03:00
D Scott Phillips 703fd6d1fa
compilers: clang-cl: Also accept .s files (#8520)
* compilers: clang-cl: Also accept .s files

clang-cl has support for gas-compatible assembly files.

* Add clang-cl to '128 generated assembly' test
2021-03-24 12:43:51 +02:00
Jussi Pakkanen 9ab4dadef9 Remove -pipe from default list of args. Closes #8508. 2021-03-23 17:26:08 +02:00
Dylan Baker 40e3577a65 split program related classes and functions out of dependencies
Dependencies is already a large and complicated package without adding
programs to the list. This also allows us to untangle a bit of spaghetti
that we have.
2021-03-19 08:47:10 -04:00
Remi Thebault c756d97895 Fix D lib search path translation
This requires quite a complex and messy logic.
As @dcbaker suggested in #8491, this could be replaced by
an abstraction over linker flags instead of having GNU flags
translated.
2021-03-17 10:14:55 -07:00
Dylan Baker 2be074b1d4 ninjabackend: Use rsp_file_syntax method
This also makes us of the new enum value in the backend, for better type
saftey.
2021-03-14 22:05:55 -07:00
Dylan Baker 320412b3bb compilers/linkers: Add a methhod for getting the rspfile syntax 2021-03-14 22:05:55 -07:00
Jussi Pakkanen d76345b4be Add address sanitizer support for Visual Studio. 2021-03-09 13:52:15 -08:00
Vili Väinölä 96405c3923 Add /Od flag to msvc optimization 0 args
Without specifying optimization the used optimization depends on vs runtime-library.
With mdd it is /Od but with md it is /O2.
2021-03-08 22:11:04 +02:00
Dylan Baker 504ae2dee8
compilers: Use EnvironmentException not EnvironmentError/OSError
The latter is a python built-in exception, the former is a meson
exception.
2021-03-04 22:13:33 -05:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Eli Schwartz 76df995ba6
raw string literals are next to godliness
Invalid escape sequences are deprecated and will be removed from a
future version of python. Use r"" to define them so they remain
readable.
2021-03-04 17:09:00 -05:00
Remi Thebault 25848fc05f fix missing versions with generated source 2021-03-02 09:31:40 -08:00
Remi Thebault 3bf207ab1b D add build dir to -J switch 2021-03-01 09:51:40 -08:00
Olexa Bilaniuk 4c1a0c400f [CUDA] Bugfix: Forward sanitizer_*_args() methods to host compiler.
Enables -Db_sanitize=undefined and company.

Also serves as a testcase for NVCC comma-shielding: Because the test-
case declares `b_sanitize=address,undefined`, the host GCC compiler
needs `-fsanitize=address,undefined`, but this stands a danger of being
split by NVCC when wrapped with `-Xcompiler=args,args`. Special,
already-existing comma-shielding codepaths activate to prevent this
splitting.

Closes #8394.
2021-02-22 23:56:55 +02:00
Dylan Baker 90a7de3f2b Ensure that $lang_args and $lang_link_args are properly parsed
Currently we don't handle things correctly if we get a string we should
split, and the linker and needs compiler arguments. It would result in
two unsplit strings in a list, instead of the split arguments in a list

Fixes: #8348
2021-02-19 17:16:42 +02:00
Krzysztof Małysa c24a0f8524 compilers: clang: Drop -Xclang before -fcolor-diagnostics flag
Using -Xclang -fcolor-diagnostics provides no advantage to using just -fcolor-diagnostics option and sometimes causes problems:
* uncolored diagnostics on Arch Linux: https://bugs.archlinux.org/task/69662
* simple problem with removing flag -fcolor-diagnostics:  https://github.com/clangd/clangd/issues/279
2021-02-18 17:30:33 +02:00
Dylan Baker 6c1467db27 compilers: Only insert -flto-jobs in clang's link arguments
Clang has a hand `-Wunused-command-line-argument` switch, which when
turned to an error, gets very grump about `-flto-jobs=0` being set in
the compiler arguments (although `-flto=` belongs there). We'll refactor
a bit to put that only in the link arguments.

GCC doesn't have this probably because, a) it doesn't have an equivalent
warning, and b) it uses `-flto=<$numthreads.

Fixes: #8347
2021-02-17 18:06:52 +02:00
Olexa Bilaniuk d1e945f442 Add optional -Dcuda_ccbindir= option and -ccbin flag to CUDA compiler.
Closes #8110.
2021-02-16 15:10:21 -05:00
Olexa Bilaniuk cc09d984f1 Armour-grade quoting to account for NVCC's -Xcompiler peculiarities. 2021-02-16 15:10:11 -05:00
Olexa Bilaniuk 3669be30aa Extensive rewrite of GCC/MVSC flag translation to NVCC flags. 2021-02-16 15:00:31 -05:00
Olexa Bilaniuk a2530373c7 Add default debug flags for two configurations to NVCC. 2021-02-16 14:46:17 -05:00
Jussi Pakkanen 6a75d6c233 Add custom entyr to cuda buildtype dict. Closes #8336. 2021-02-14 18:41:07 +02:00
Dylan Baker 6f532b72c8 Add support for LLVM's thinLTO
This uses a separate option, b_lto_mode. It works in conjunction with
b_lto_threads.

Fixes #7493
2021-02-02 12:42:48 -08:00
Dylan Baker bffc94b08f compilers: Add support for using multiple threads with lto
Both Clang and GCC support using multiple threads for preforming link
time optimizaions, and they can now be configured using the
`-Db_lto_threads` option.

Fixes #7820
2021-02-02 12:42:48 -08:00
Dylan Baker 23d3b98fc1 split mesonlib into a package
Currently mesonlib does some import tricks to figure out whether it
needs to use windows or posix specific functions. This is a little
hacky, but works fine. However, the way the typing stubs are implemented
for the msvcrt and fnctl modules will cause mypy to fail on the other
platform, since the functions are not implemented.

To aleviate this (and for slightly cleaner design), I've split mesonlib
into a pacakge with three modules. A universal module contains all of
the platform agnositc code, a win32 module contains window specific
code, a posix module contains the posix specific code, and a platform
module contains no-op implementations. Then the package's __init__ file
imports all of the universal functions and all of the functions from the
approriate platform module, or the no-op versions as fallbacks. This
makes mypy happy, and avoids `if`ing all over the code to switch between
the platform specific code.
2021-01-23 12:48:29 +01:00
Marios Staikopoulos f8681b12e1 MSVC and Clang-Cl Compiler Argument Cleanup
This commit performs some cleanup for the msvc and clang-cl arguments.

* "Disable Debug" (`/Od`) is no longer manually specified for optimization levels {`0`,`g`} (it is already the default for MSVC).
* "Run Time Checking" (`/RTC1`) removed from `debug` buildtype by default
* Clang-CL `debug` buildtype arguments now match MSVC arguments
* There is now no difference between `buildtype` flags and `debug` + `optimization` flags
2021-01-20 14:11:16 -05:00
Brion Vibber d808429a48 Avoid accidental use of STANDALONE_WASM mode on compiler tests
Compiler tests, such as checking for atomics support, could fail
when compiling to WebAssembly multithreaded targets because the
compiler tests got compiled to 'output.wasm'.

Using the '.wasm' suffix in recent versions of emscripten engages
STANDALONE_WASM mode, which disables features that require a JS
runtime like shared memory.

This created false negatives on support of those features when
building a library to be linked into an executable that is not
in STANDALONE_WASM mode.

Changing these to 'output.o' will continue to produce WebAssembly
object files, but they will no longer be configured for standalone
runtime mode.
2021-01-20 19:10:21 +00:00
Marios Staikopoulos a3d8dc546c Removal of /ZI on MSVC Debug
The /ZI flag adds in "Edit and Continue" debug information, which will
cause massive slowdown. It is not a flag that we should be adding by
default to debug builds.

/Zi will still be added.
2021-01-17 21:03:35 +00:00
Antonin Décimo 39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
Dylan Baker 4b0b44afac move handling of CFLAGS and friends to environment
This has a bunch of nice features. It obviously centralizes everything,
which is nice. It also means that env is only re-read at `meson --wipe`,
not `meson --reconfigure`. And it's going to allow more cleanups.
2021-01-11 11:15:06 -08:00
Dylan Baker f202da0689 use PEP8 style naming for LANGUAGES_USING_* as well 2021-01-11 11:15:06 -08:00
Dylan Baker 4580433b82 rename cflags_mapping to CFLAGS_MAPPING
This is PEP8 convention for a const variable. Also, make the type
Mapping, which doesn't have mutation methods. This means mypy will warn
us if someone tries to change this.
2021-01-11 11:15:06 -08:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Dylan Baker f9b19e73a5 move OptionKey to mesonlib
There's starting to be a lot of things including coredata that coredata
needs to itself include. putting it in mesonlib makes more sense
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker bdca05e2e6 Add choices to OptionProxy
they're probably not strictly needed, but it makes mypy happy.
2021-01-04 12:15:41 -08:00
Remi Thebault 7a9a9e4a99
Implement support of dlang -makedeps switch (#8119)
* Implement support of dlang -makedeps switch

Fix #8118

* resolve code review comments
2020-12-29 09:56:35 -08:00
Laurin-Luis Lehning 4164efceca Propagate Windows target checks up 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 919278e3e1 Give get_gui_app_args access to the Environment 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 4053babf9c Slight consistency changes to get_gui_app_args 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 9de09e9aa6 Give get_win_subsystem_args access to env 2020-12-14 11:23:53 -08:00
Laurin-Luis Lehning 2fb4d1f751 Make win_subsystem a linker property 2020-12-14 11:23:53 -08:00
Jussi Pakkanen 9f1ba40252
Merge pull request #8013 from mesonbuild/cppmodules
C++ module support
2020-12-14 15:00:04 +00:00
Laurin-Luis Lehning bab1087422
Add support for driving lld-link indirectly through clang on Windows 2020-12-13 16:34:50 +02:00
Jussi Pakkanen 5bd1276d20 Create unit test for C++ modules and accept ixx as C++ source extension. 2020-12-11 19:21:02 +00:00
Florian Schmaus a7aba905a0 compilers: add support for c++20/gnu++20
Fixes #8084.
2020-12-10 00:30:48 +02:00
Jussi Pakkanen c21b04ba08 Add prelinking support for static libraries. 2020-12-03 22:58:07 +02:00
Dylan Baker 8915538c31 compilers/fortran: Add "none" to intel compielrs for standards
Fixes #8023
2020-11-24 23:11:23 -05:00
Christoph Reiter abc7e6af01 Add a variant of TemporaryDirectory that uses windows_proof_rmtree()
Adds TemporaryDirectoryWinProof which calls windows_proof_rmtree() on
error.

Use instead of hacky error handling (which might shadow other OSError)
in Compiler.compile().
2020-11-23 09:26:41 -08:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Jussi Pakkanen c8af3c8d29 Revert "Add thinlto support. Closes #7493."
This reverts commit 3e6fbde94c.
2020-11-17 17:51:23 +02:00
Jussi Pakkanen 299a67781e
Merge pull request #7843 from dcbaker/submit/rustc-fixes
A few fixups for rust
2020-11-14 13:47:39 +02:00
jpark37 2748c9fb3d msvc: enable /std:c17 flag
Increase allowed c_std options, and check compiler version.

Also update mlog pattern to not crash.
2020-11-13 16:13:02 -08:00
Dylan Baker 5afd608a75 compilers/rust: add and use an implementation of use_linker_args 2020-11-13 09:00:35 -08:00
Jussi Pakkanen 91876b4031
Merge pull request #7866 from dcbaker/submit/compiler-std-in-base
Put the Compiler standard option in the Language mixin
2020-11-13 17:49:52 +02:00
Dylan Baker f31acbe2a4 clang-cl: Allow clang-cl (when compiling C) to pass std to underlying clang)
This allows a wider array of standard support than would be available
directly from clang-cl, emulating MSVC stds.
2020-11-12 12:52:27 -08:00
Dylan Baker 0217faf13f compilers/c: Log that MSVC doesn't support gnu stds
Since the current approach of demoting to the nearest C standard *might*
work, but might not. For projects like Glib that detect which standard
is used and fall back this is fine. For projects like libdrm that only
work with gnu standards, this wont. We're nog tusing a warning because
this shouldn't be fatal if --meson-fatal-warnings is used. Also demote a
similar message in IntelCl from warning to log.
2020-11-12 10:06:11 -08:00
Dylan Baker 2844afedde compilers: define standards in the base language compiler
And then update the choices in each leaf class. This way we don't end up
with another case where we implicitly allow an invalid standard to be
set on a compiler that doesn't have a 'std' setting currently.
2020-11-12 10:03:15 -08:00
Dylan Baker a28a34c684 compilers: Standardize the names of compiler options
Most options don't use language prefaced options (std vs c_std)
internally, as we don't need that due to namespacing. Let's do that
across the board
2020-11-12 10:03:14 -08:00
Dylan Baker 3e62307f3a compilers/c: Clang-cl also needs specific handling for standards 2020-11-12 10:03:14 -08:00
Jussi Pakkanen 333e0aeef4 Make MSVC accept gnu11 as a language standard version. Closes: #7611.
Fixes: #7611
2020-11-12 10:03:14 -08:00
Dylan Baker ce46070b4e compilers/rust: Add color output
Rust has color output, although it's help doesn't document it. It uses
the same values as cargo (and everything else), auto, never, always.
2020-11-10 12:09:21 -08:00
Dylan Baker e430c01ef5 compilers/rust: Add vs_crt support
As far as I can Tell, rust just handles this for us (it's always worked
with no special arguments from us). However, since we're going to add
support for base options for rust, we need to add the method.
2020-11-10 12:09:03 -08:00
Jussi Pakkanen dffd66e0ff Fix WASM thread count option. Closes #7921. 2020-11-09 23:06:52 +02:00
Christoph Reiter 5dd174c60b Fix "generator doesn't stop" on Windows
When TemporaryDirectory() cleans up on __exit__ it sometimes throws
OSError noting that the dir isn't empty. This happens after the
first yield in this generator and leads to the exception being handled
which leads to a second yield.

contextlib.contextmanager() fails then since the function it wraps is only
allowed to yield once.

Fix this by not yielding again in the error case.

Fixes #7947
2020-11-08 19:10:48 +02:00
Jussi Pakkanen 3e6fbde94c Add thinlto support. Closes #7493. 2020-11-08 16:00:05 +02:00
Dylan Baker 7860a6aeab rust: implement support for --edition
Using the std option, so now `rust_std=..` will work. I've chosen to use
"std" even though rust calls these "editions", as meson refers to
language versions as "standards", which makes meson feel more uniform,
and be less surprising.

Fixes: #5100
2020-11-05 21:24:20 +02:00
Xavier Claessens 7902d2032d Refactor handling of machine file options
It is much easier to not try to parse options into complicated
structures until we actually collected all options: machine files,
command line, project()'s default_options, environment.
2020-10-16 17:42:24 -04:00
Carlos Bederian c3b3dc598e compilers/cuda: Use format_map(mapping) instead of format(**mapping) 2020-10-16 18:18:46 +02:00
Carlos Bederian f09457a1e8 compilers/cuda: Fix has_header_symbol check 2020-10-16 18:18:46 +02:00
Peter Harris 8b8a610ea4 vs: add static_from_buildtype to b_vscrt 2020-10-14 19:35:28 +03:00
Jussi Pakkanen 1a0603835e Add win_subsystem kwarg. Closes #7765. 2020-10-07 18:55:25 +03:00
Vinson Lee 5d7069664b compilers: Enable C++20 for Intel C++ Compiler.
Intel C++ Compiler 19.1 has C++20 features.

https://software.intel.com/content/www/us/en/develop/articles/intel-c-compiler-191-for-linux-release-notes-for-intel-parallel-studio-xe-2020.html

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
2020-10-06 22:11:34 +03:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Dylan Baker 2fe400c350 compilers/icl fix IntelClCPP argument checking
Unlike MSVC and ClangCl it needs to call into it's own compiler check
args
2020-10-01 15:06:10 -07:00
Dylan Baker f9316fbb46 compilers/icl: Fix pch usage 2020-10-01 15:06:10 -07:00
Dylan Baker b309f4904b compilers/fortran: make ifort on windows signature match ICL's 2020-10-01 15:06:10 -07:00
Dylan Baker ff51e1c5aa compilers/clike: Store exe_wrapper as ExternalProgram
Which is what other languages do.
2020-10-01 15:06:10 -07:00
Dylan Baker 135f5d5838 compilers: make get_optimization_args abstract 2020-10-01 15:06:10 -07:00
Dylan Baker 577a2de7e8 compilers/fortran: fix has_multi_*_arguments
The implementation of the link variant was what should have been the
compiler variant, and there was no valid compiler variant, which meant
it was getting C code.
2020-10-01 15:06:10 -07:00
Dylan Baker 6a9761a2c0 compilers/d: add type annotations 2020-10-01 15:06:10 -07:00
Dylan Baker 6eb981e0c0 compilers/gnu: Don't pretend to inherit CLike
We don't need it anymore, and it would be problematic for the D
compilers.
2020-10-01 15:05:01 -07:00
Dylan Baker 738e343860 compilers: move _build_wrapper out of clike into Compiler
This abstraction is really useful, and most compilers could use it
(including D). It also will allow the Gnu mixins to work properly
without the CLikeCompiler in their mro.
2020-10-01 15:05:01 -07:00
Dylan Baker cd59ce98dc compilers: clang: use get_compiler_check_args 2020-10-01 15:05:01 -07:00
Dylan Baker 1c20f187e8 compilers/intel: use get_compiler_check_args
Instead of trying to override the compiles() method, which gets skipped
in a bunch of cases.
2020-10-01 15:05:01 -07:00
Dylan Baker 8291e947f5 compilers: move get_compile_check_args() to Compiler
This is groundwork to put _build_wrapper in the base Compiler, which is
needed to make the D compilers truly type safe.
2020-10-01 15:05:01 -07:00
Dylan Baker e039727e63 compilers/fortran: add type annotations 2020-10-01 15:05:01 -07:00
Dylan Baker 3fc37fc13e compilers/java: Add type annotations 2020-10-01 15:05:01 -07:00
Dylan Baker 4430269d4e compilers/rust: add type annotations 2020-10-01 15:05:01 -07:00
Dylan Baker e437bdd0a9 compilers/swift: Add type annotations 2020-10-01 15:05:01 -07:00
Dylan Baker efceec9615 Compilers/vala: Add type annotations 2020-10-01 15:05:00 -07:00
Dylan Baker d3a059b55f compilers/cuda: make type safe 2020-10-01 15:05:00 -07:00
Dylan Baker 224a752489 compilres: move depfile_for_object to compiler 2020-10-01 15:05:00 -07:00
Dylan Baker 413f4d87e9 compilers/cs: Add type annotations 2020-10-01 15:05:00 -07:00
Dylan Baker e7f0890cb9 compilers: move get_dependency_gen_args to base Compiler
So that every subclass doesn't have to reimplement it. Especially since
the Gnu implementation moved out of the CCompiler and into the
GnuLikeCompiler mixin
2020-10-01 15:05:00 -07:00
Dylan Baker 1513aa437d compilers: move split_shlib_to_parts to the base compiler
Only the GnuLikeCompiler overrides this, and it's implemented multiple
places
2020-10-01 15:05:00 -07:00
Dylan Baker fe97977b00 compilers/cpp: Add type annotations 2020-10-01 15:05:00 -07:00
Dylan Baker 96a1ae6dfe compilers: fully type annotate the C compilers 2020-10-01 15:05:00 -07:00
Ian Harvey 3afe18228a compilers: Use /Od for no-optimisation flag for Intel compilers on windows
Intel compilers on Windows (and the Microsoft C++ compiler) use /Od to disable optimisation, not /O0.
2020-09-30 12:01:50 -07:00
Vili Väinölä d1638a4fde compilers/VS: fix build to use optimization and debug flags
- Fixed using debug and optimization built-in options in MSVC.
- Fixed that VS backend does not create pdb files in release mode.
VS implicitly adds the debug fields if left out.
- Fix that it is possible to add debug info with ninja backend with
optimizations.
2020-09-29 19:25:50 +03:00
Dylan Baker da4c1945fc compilers/objcpp: add type annotations 2020-09-24 12:14:13 -07:00
Dylan Baker 05df8320db compilers/objc: Add type annotations 2020-09-24 12:14:13 -07:00
Dylan Baker 682d22129c compilers: Tell mypy that the compiler mixins are just that
We do this by making the mixins inherit the Compiler class only when
mypy is examining the code (using some clever inheritance shenanigans).
This caught a bunch of issues, and also lets us delete a ton of code.
2020-09-24 12:14:13 -07:00
Dylan Baker 2c0fbe161d compilers: make is_cross part of the base Compiler class
Every class needs to set this, so it should be part of the base. For
classes that require is_cross, the positional argument remains in their
signature. For those that don't, they just allow the base class to set
their value to it's default of False.
2020-09-24 12:14:13 -07:00
Dylan Baker 1592b7a800 compilers: make sanity_check_impl a protected method
It's an implementation detail after all
2020-09-24 12:14:13 -07:00
Dylan Baker 98416e7f75 compilers: put name_string method in base compiler
Every language had the exact same implementation
2020-09-24 12:14:13 -07:00
Dylan Baker fa1398f86c compilers/mixins: make xc16 type safe 2020-09-24 12:14:13 -07:00
Dylan Baker 4911e8eef4 compilers/mixins: make visual studio type safe 2020-09-24 12:14:13 -07:00
Dylan Baker b6c8b8a5be compilers/mixins/pgi: Make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker 6dc774f1b6 compilers/mixins/islinker: Make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker 8ee1e6b768 compilers/mixins/intel: make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker a0a8ef567e compilers/mixins/intel: Use the has_func_attribute_extra_args function
Instead of putting that extra argument in the base compiles() class
2020-09-24 12:14:13 -07:00
Dylan Baker 1e93d2875e compilers/mixins/emscripten: make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker 04a98baafb compilers/mixins/elbrus: make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker bc532a8543 compilers/mixins: make compcert type safe 2020-09-24 12:14:13 -07:00
Dylan Baker 48a181866f compilers/mixins/clang: Make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker 4b52184dc6 compilers/mixings/gnu: make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker bb3fe3c451 compilers/mixins/clike: fix mypy issues 2020-09-24 12:14:13 -07:00
Dylan Baker 4cfddd1fe6 compilers/mixins/ccrx: make mypy safe 2020-09-24 12:14:13 -07:00
Dylan Baker c93395bfc7 compilers/mixins/c2000: Make mypy safe 2020-09-24 12:14:13 -07:00
Dylan Baker b7db3660a0 compilers/mixins/arm: make type safe 2020-09-24 12:14:13 -07:00
Dylan Baker 79d1ecd5bc compilers/compilers: Fully type annotate 2020-09-24 12:14:13 -07:00
Dylan Baker d326c87fe2 compilers: Use a distinct type for compile/link results
Currently we do some crazy hackery where we add extra properties to a
Popen object and return that. That's crazy. Especially since some of our
hackery is to delete attributes off of the Popen we don't want. Instead,
let's just have a discrete type that has exactly the properties we want.
2020-09-24 12:14:13 -07:00
Sebastian Meyer 35a5a69355 Some fixes for CompCert
1. Like with gcc's `ld`, also use the `group_start` code to create a
   `--start-group`/`--end-group`
2. xc16 tricked into believing the 'link_whole' was about `--*-group`,
   but it should use gcc's `--whole-archive` instead.
3. Not clear what the get_lib_prefix should really do, but for picolibc
   it seems I want just `''`.

The problem with picolibc was that the `-l` would be prefixed to a lib
like `picolib/libm/libm.a`. Though of course the `-l` would be necessary
for just a plain `m` (that's what I assumed this would be used for).
I think this might need some clarification from the meson devs ;-)
2020-09-18 08:59:39 -07:00
Martin Storsjö deb1d7caba Canonicalize target architectures aarch64/armv* into arm64/arm for MSVC tools
If the architectures are taken from the output of "clang-cl --version",
we need to convert these names into names that the MSVC tools accept
as the -machine: parameter.
2020-09-17 11:23:36 +00:00
Dylan Baker 4401668c9a linkers/compilers: Move an emscripten method to the compiler
This needed an attribute the linker doesn't have.
2020-09-16 20:28:56 -07:00
Sebastian Meyer a24fde6fde
Add support for the CompCert C Compiler
* Add preliminary support for the CompCert C Compiler

The intention is to use this with the picolibc, so some GCC flags are
automatically filtered. Since CompCert uses GCC is for linking, those
GCC-linker flags which are used by picolibc, are automatically prefixed
with '-WUl', so that they're passed to GCC.

Squashed commit of the following:

commit 4e0ad66dca9de301d2e41e74aea4142afbd1da7d
Author: Sebastian Meyer <meyer@absint.com>
Date:   Mon Aug 31 14:20:39 2020 +0200

    remove '-fall' from default arguments, also filter -ftls-model=.*

commit 41afa3ccc62ae72824eb319cb8b34b7e6693cb67
Author: Sebastian Meyer <meyer@absint.com>
Date:   Mon Aug 31 14:13:55 2020 +0200

    use regex for filtering ccomp args

commit d68d242d0ad22f8bf53923ce849da9b86b696a75
Author: Sebastian Meyer <meyer@absint.com>
Date:   Mon Aug 31 13:54:36 2020 +0200

    filter some gcc arguments

commit 982a01756266bddbbd211c54e8dbfa2f43dec38f
Author: Sebastian Meyer <meyer@absint.com>
Date:   Fri Aug 28 15:03:14 2020 +0200

    fix ccomp meson configuration

commit dce0bea00b1caa094b1ed0c6c77cf6c12f0f58d9
Author: Sebastian Meyer <meyer@absint.com>
Date:   Thu Aug 27 13:02:19 2020 +0200

    add CompCert to meson (does not fully work, yet)

* remove unused import and s/cls/self/

fixes the two obvious LGTM warnings

* CompCert: Do not ignore unsupported GCC flags

Some are safe to ignore, however, as per
https://github.com/mesonbuild/meson/pull/7674, they should not be
ignored by meson itself. Instead the meson.build should take care to
select only those which are actually supported by the compiler.

* remove unused variable

* Only add arguments once.

* Apply suggestions from code review

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>

* Remove erroneous ' ' from '-o {}'.format()

As noticed by @dcbaker

* added release note snippet for compcert

* properly split parameters

As suggested by @dcbaker, these parameters should be properly split into multiple strings.

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>

* Update add_compcert_compiler.md

Added a sentence about the state of the implementation (experimental); use proper markdown

* properly separate arguments

Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-09-15 21:51:21 +03:00
Xavier Claessens 9d338200da external-project: New module to build configure/make projects
This adds an experimental meson module to build projects with other
build systems.

Closes: #4316
2020-09-13 13:54:47 -04:00
Daniel Mensinger 47373a2438
typing: get rid of most T.cast 2020-09-08 20:15:58 +02:00
Daniel Mensinger 3dbfe8f75a
typing: fully annotate arglist 2020-09-08 20:15:57 +02:00
James Hilliard 646ae846be backends: check external rpaths for all languages using ldflags
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-09-06 21:07:14 +03:00
Pierrick Bouvier 1900720353 D: fix include order
Commit 93c3ec7e introduced a new way to handle deduplication with
compiler args. This resulted in D includes to be reversed.
2020-08-30 18:56:24 +03:00
Nirbheek Chauhan 6f74692ae0 Fix typo when fetching buildtype option for compiler checks
This type happened in https://github.com/mesonbuild/meson/pull/7432
and wasn't noticed because I didn't add a test for it. Rectified now.

If we don't specify the CRT, MSVC will pick /MT by default (!?) and
link to `libcmt.lib`. This actually *breaks* UWP because `libcmt.lib`
is not available by default when building for UWP.

Was noticed here: https://github.com/cisco/libsrtp/pull/505
2020-08-27 00:13:58 +00:00
Jussi Pakkanen 3a25efc056
Merge pull request #7581 from peterh/aix
Add AIX support
2020-08-25 23:58:17 +03:00
Jussi Pakkanen fc13c90de3
Merge pull request #7600 from alexrp/master
Add C2x option support.
2020-08-23 00:26:44 +03:00
Jussi Pakkanen a9f33d96c6
Merge pull request #7609 from dcbaker/submit/2020-08/cmake-fix-apple-clang
Fix mapping of apple compilers in cmake
2020-08-22 22:40:44 +03:00
Dylan Baker b6c28d282c compilers: Add Apple subclasses for ObjC and ObjC++
These are needed because in some cases we need to be able to know if
we're using vanilla clang or Apple's clang.
2020-08-22 10:49:35 -07:00
Alex Rønne Petersen 450155110c Add C2x option support. 2020-08-22 18:57:05 +02:00
Jussi Pakkanen e9a71ebf60
Merge pull request #7607 from bonzini/speedup
Various speedups from profiling QEMU's meson.build
2020-08-22 18:40:03 +03:00
Jussi Pakkanen c42298e146
Merge pull request #7447 from scivision/nvc
Add support for NVidia HPC SDK compilers
2020-08-22 18:31:56 +03:00
makise-homura 1f2150fe49 Correctly determine C++ stds for Elbrus compiler 2020-08-20 23:49:18 +03:00
Paolo Bonzini 847bb43470 clike: optimize to_native
Look for group-able flags with a single regex match, since we are already using
regexes for .so files.  Also weed out flags other than -isystem very quickly
with a single startswith call.

On a QEMU build, the time spent in to_native goes from 2.279s to 1.322s.
2020-08-18 08:11:25 +02:00
Peter Harris 7b0c1e2349 find_library: include get_linker_always_args in link args
The linker always args, as the name implies, should always be included. For
example, the AIX get_allow_undefined_link_args are a syntax error unless
the AIX get_linker_always_args are also used.
2020-08-17 21:21:33 -04:00
Michael Hirsch f2890cbf97 msvc: enable /std:c11 flag 2020-08-09 11:48:41 -07:00
Antony Chan 70edf82c6c Make meson recognize the Qualcomm LLVM toolchain
Meson calls `path/to/clang++ --version` to guess which build toolchain the
user has picked to build the source code. For the Qualcomm LLVM toolchain,
the output have an unusual output as shown below:

```
clang version 8.0.12
Snapdragon LLVM ARM Compiler 8.0.12 (based on llvm.org 7.0+)
Target: arm-unknown-linux-gnueabi
Thread model: posix
Repository: (ssh://git-hexagon-aus.qualcomm.com:...)
InstalledDir: /pkg/qct/software/llvm/release/arm/8.0.12/bin
```

Another unusual pattern is the output of `path/to/ld.qcld --version`:

```
ARM Linker from Snapdragon LLVM ARM Compiler Version 8.0.12
ARM Linker based on LLVM version: 8.0
```

The Meson logic is modified accordingly so that Meson can correctly
determine toolchain as "LLVM aarch64 cross-compiler on GNU/Linux64 OS".

This is the expected output of
`meson --native-file native_file.ini --cross-file cross_file.ini build/aarch64-debug/`:

```
...
C++ compiler for the host machine: ... (clang 8.0.12 "clang version 8.0.12")
C++ linker for the host machine: ... ld.lld 8.0.12
...
```
2020-08-02 10:39:44 -07:00
Nirbheek Chauhan 6e7d548b11 compilers: Cache gnu-mixins has_arguments() checks
want_output gives us the output file. We don't need the file. We just
need the compiler stderr, which is always stored.
2020-07-23 07:39:59 +00:00
Xavier Claessens 6bf61b2a38 visualstudio: warning_level 0 should not map to /W1
In every other compilers level 0 maps to no argument at all.
2020-07-22 15:54:13 -04:00
Elliot Haisley 063b74ebba fix msvc not recognising b_ndebug
fixes #7404
2020-07-19 15:26:30 +03:00
Nirbheek Chauhan 21da2c9040 Fix native builds on Windows ARM64 machines
I made the mistake of always selecting the debug CRT for compiler
checks on Windows 4 years ago:
https://github.com/mesonbuild/meson/pull/543
https://github.com/mesonbuild/meson/pull/614

The idea was to always build the tests with debugging enabled so that
the compiler doesn't optimize the tests away. But we stopped doing
that a while ago, and also the debug CRT has no relation to that.

We should select the CRT in the same way that we do for building
targets: based on the options.

On Windows ARM64, the debug CRT for ARM64 isn't always available, and
the release CRT is available only after installing the runtime
package. Without this, we will always try to pick the debug CRT even
when --buildtype=debugoptimized or release.
2020-07-13 15:28:38 +00:00
Michael Hirsch, Ph.D f985bb7383
add Nvidia HPC SDK compilers 2020-07-13 00:16:52 -04:00
Dylan Baker 4f6bd29ac9 arglist: Split the C/C++ specifics parts into a subclass for CLike
This means that we don't need work arounds for D-like compilers, as the
special c-like hanlding wont be used for D compilers.
2020-06-22 12:06:10 -07:00
Dylan Baker 93c3ec7e2d compilers: Return CompilerArgs from compiler instance
Since the CompileArgs class already needs to know about the compiler,
and we really need at least per-lanaguage if not per-compiler
CompilerArgs classes, let's get the CompilerArgs instance from the
compiler using a method.
2020-06-22 12:06:10 -07:00
Dylan Baker 9d0ad66c29 compilers: Split CompilerArgs into a separate module
I've also moved this out of the compilers pacakge because we're soon
going to need it in linkers, and that creates some serious spagetti
2020-06-22 12:06:10 -07:00
Dylan Baker 386721f7fd compilers: Add missing annotations to CompilerArgs class 2020-06-22 12:06:10 -07:00
Dylan Baker b887212bee compilers: Use enum for for deupdlication returns in CompilerArgs 2020-06-22 12:06:10 -07:00
Tim-Philipp Müller 246e5437aa compiler: add 'force_align_arg_pointer' function attribute 2020-06-21 23:34:11 +03:00
Nirbheek Chauhan 47c477711b apple: -headerpad args are ignored when bitcode is enabled
Causes spammy warnings from the linker:

ld: warning: -headerpad_max_install_names is ignored when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES)
2020-06-11 07:10:43 +00:00
Marcel Hollerbach 18b99b3bc3 compilers: corretify deduplication direction
so: when building compile args, meson is deduplicating flags. When a
compiler argument is appended, a later appearance of a dedup'ed is going
to remove a earlier one. If the argument is prepended, the element
*before* the new one is going to be removed. And that is where the
problem reported in https://github.com/mesonbuild/meson/pull/7119 is
coming in. In the revision linked there, the order of replacement in the
prepend case was revesered.

With this patch, we restore this behaviour again.
2020-06-11 01:42:59 +03:00
Seungha Yang 8edbb2859c compilers: Add UNIX large file support for MinGW
MinGW gcc supports _FILE_OFFSET_BITS=64 and we need to set it for
MinGW as well
2020-06-09 12:49:11 +00:00
Jussi Pakkanen 7e1bef6959
Merge pull request #7119 from marcelhollerbach/master
Performance optimize ninja backend
2020-06-07 22:33:04 +03:00
Jussi Pakkanen 508a0d6073
Merge pull request #7256 from peterh/openmp
Fix OpenMP on Visual Studio
2020-06-07 22:24:40 +03:00
Jussi Pakkanen 86df85d511 Remove warnings from sample code. Closes #7248. 2020-06-07 20:27:18 +03:00
Jussi Pakkanen fd0ad977a6 End test code with a newline. Closes #7247. 2020-06-07 20:20:31 +03:00
Peter Harris 9462f0c7bc msvc: Avoid spurious openmp link warnings
The linker that comes with MSVC does not understand the /openmp flag.
This results in a string of

    LINK : warning LNK4044: unrecognized option '/openmp'; ignored

warnings, one for each static_library linked with an executable.

Avoid this by only setting the linker openmp flag when the compiler is
not MSVC.
2020-06-06 12:04:28 -04:00
Marcel Hollerbach 032ab3606d CompilerArgs: refactor __iadd__
the previous optimizations from 4524088d38
were not relaly good, and not really scaleable, since only the lookup
was improved. However, the really heavy calls to remove have not been
improved.

With this commit we are refactoring CompilerArgs into a data structure
which does not use remove at all. This works that we are building a pre
and post list, which gets flushed into __container at some point.
However, we build pre and post by deduplicating forward. Later on, when
we are flushing pre and post into __container, we are deduplicating
backwards the list, so we are not changing behaviour here.

This overall cuts off 10s of the efl configuration time. Further more
this improves configure times on arm devices a lot more, since remove
does seem to be a lot slower there. In general this results in the fact
that __iadd__ is not within the top 5 of costly functions in
generate_single_complie.
2020-06-05 09:21:23 +02:00
Marcel Hollerbach ba8e838dcf Revert "CompilerArgs: make lookup faster"
This was a not so nice solution, and should be replaced with something
better.

This reverts commit 4524088d38.
2020-06-05 09:04:04 +02:00
Marcel Hollerbach 256e910dee cache up regex mathings
the names passed in here are often the same. We should ensure that we
cache the regex match, as this will speed up our runtime a lot.
2020-06-05 09:02:23 +02:00
Mike Gilbert 5b3bed525d Ignore file access errors when scanning .so files in system libdirs
Bug: https://bugs.gentoo.org/726524
2020-06-02 20:50:36 +03:00
Michael Hirsch, Ph.D e2c475939e add type anno: compilers/clike 2020-05-27 20:24:21 +03:00
Phillip Johnston bdfd46e579 Recognize Arduino .ino files as C++
Renaming .ino files is not an option when working with the IDE. Meson should recognize it as C++ however.
2020-05-27 20:17:26 +03:00
Drew Reed 9a94ffe061 Modifed buildtypes and armclang compiler flags to match documented results 2020-05-22 18:28:09 +03:00
georgev93 eee117aa24 Allow building with b_coverage set to true when clang is being used regardless of linker selection. 2020-05-22 17:18:54 +03:00
Yevhenii Kolesnikov 9dc3ca2c1c compilers: add fetching of define list for clang
Simmilar to gcc, the list of pre-processor defines can be fetched with
`-dM -E` option. The way cpu_family is determined on linux relies on
this list.

Fixes incorrect value of cpu_family on linux, when crosscompiling:

```
CC="clang -m32" meson ./build
```

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
2020-05-22 16:58:12 +03:00
Dylan Baker 29ef4478df compilers/d: Add b_ndebug support
D lang compilers have an option -release (or similar) which turns off
asserts, contracts, and other runtime type checking. This patch wires
that up to the b_ndebug flag.

Fixes #7082
2020-05-20 14:20:26 -07:00
Dylan Baker d04e2c2f1f compilers: Move b_ndebug into the compiler classes
Right now we hardcode -DNDEBUG as the value to be added for b_ndebug.
Which is a not the correct behavior for non C/C++ languages. By pushing
this back into the compiler classes we can change this for other
languages.
2020-05-20 14:20:26 -07:00
Jussi Pakkanen 751ea3df72
Merge pull request #7103 from dankegel/bug4027-rpath-remember
Let .pc files and LDFLAGS provide rpaths.
2020-05-18 23:17:34 +03:00
Dylan Baker 6fe68edbf8 compilers/d: Enable pgo for GDC 2020-05-18 19:29:18 +03:00