Commit Graph

470 Commits

Author SHA1 Message Date
Dylan Baker 91e56c7d59 environment: Allow setting build options in cross files
This did work previously, so we need to let it continue working. I'm
proposing removing it in 0.60 because the correct solution has always
worked.

I've also been a bit more defensive here, and made setting
`subproject:opt = foo` in the machine files an error, as we have
`[subproject:built-in options]` or `[subproject:project options]` for
that.
2021-02-18 10:57:20 -08:00
Dylan Baker 10d94a12b8 Environment: Fix passing envrionment variables CPPFLAGS and CFLAGS
Or other language flags that use CPPFLAGS (like CXXFLAGS). The problem
here is actually rather simple, `dict.setdefault()` doesn't work like I
thought it did, I thought it created a weak entry, but it actually is
equivalent to:
```python
if k not in dict:
    dict[k] = v
```
Instead we'll use an intermediate dictionary (a default dictionary
actually, since that makes things a little cleaner) and then add the
keys from that dict to self.options as applicable.

Test case written by Jussi, Fix by Dylan

Co-authored-by: Jussi Pakkanen
Fixes: #8361
Fixes: #8345
2021-02-17 14:46:15 +02:00
Ali Alnubani a174855200 environment: fix typos
Fixed typos and reworded some sentences.

Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
2021-02-03 15:30:10 +00: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
Dylan Baker ff40ca25b7 make some Environment methods protected
they're really not public methods, they'r only meant to be called from
the initializer. Let's mark them as such.
2021-01-11 11:15:07 -08:00
Dylan Baker 1cc7e4c84c clean up get_env_var_pair
This function returns both the name and the value, but we never actually
use the name, just the value. Also make this module private. We really
want to keep all environment variable reading in the Environment class
so it's done once up front. This should help with that goal.
2021-01-11 11:15:07 -08:00
Dylan Baker 0076db6ff9 move get_env_var_pair to environment
This is only used in environment, so it should live there too.
2021-01-11 11:15:07 -08:00
Dylan Baker f3fcbba1f8 boost: default machine file properties to env var values
This both moves the env reading to configuration time, which is useful,
and also simplifies the implementation of the boost dependency. The
simplification comes from being able to delete basically duplicated code
since the values will be in the Properties if they exist at all.
2021-01-11 11:15:07 -08:00
Dylan Baker e7a5c75285 Move BinaryTable environment lookups to Environment
This means that all the env lookups are done once, at initial configure
time. This has all of the expected advantages.
2021-01-11 11:15:07 -08: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 3949c2a0e0 move CMAKE_PREFIX_PATH env var handling to environment
This causes the variable to be read up front and stored, rather than be
re-read on each invocation of meson.

This does have two slight behavioral changes. First is the obvious one
that changing the variable between `meson --reconfigure` invocations has
no effect. This is the way PKG_CONFIG_PATH already works. The second
change is that CMAKE_PREFIX_PATH the env var is no longer appended to
the values set in the machine file or on the command line, and is
instead replaced by them. CMAKE_PREFIX_PATH is the only env var in meson
that works this way, every other one is replaced not appended, so while
this is a behavioral change, I also think its a bug fix.
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 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 b25a423a64 use the OptionKey type for command line and machine files 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
Persian Prince f5871f434a
environment.py: Detect all mips* architectures (#8108)
* environment.py: Detect all mips* architectures

We have more than those values, like:

mipsel
mipsel-nf
mips32el
mips33el-nf
mipsisa32r6
mipsisa32r6el

So lets just detect them all.

Sorry I forgot about 64bit and closed https://github.com/mesonbuild/meson/pull/8106

But now it even detects:

mipsisa64r6
mipsisa64r6el

* Make dcbaker happy
2020-12-17 10:37:39 -08: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 cef13b04c2 Bump Ninja requirement to 1.8. 2020-11-26 20:28:55 +02:00
Dylan Baker 6ce3812762 environment: Fix detection of rust compilers, more 2020-11-13 09:00:35 -08:00
Dylan Baker 86957cfc90 compilers/rust: warn about setting -C linker in your compiler args 2020-11-13 09:00:35 -08:00
Dylan Baker 5afd608a75 compilers/rust: add and use an implementation of use_linker_args 2020-11-13 09:00:35 -08:00
Dylan Baker 8640dbabc4 environment: Properly pass linker to rustc
rustc is very different than other compilers, in that it doesn't
generate object files, it just creates a final target out of the
intermediate sources. As such, it needs to know about the linker args in
the compiler invocation.
2020-11-13 08:55:30 -08:00
Dylan Baker 712cbe0568 environment: Fix detection of swift linker
Apparently in some cases swift prints to stderr instead of stdout
2020-10-30 02:04:26 +02:00
Ken Cunningham faabbb3bb2 fix typo "machintosh" -> "macintosh"
fixes machine detection for
power macintosh systems
2020-10-19 09:39:03 -07:00
Xavier Claessens 7271b1e942 Machine file pkg_config_path overrides environment
This is consistent with c_args in machine file overriding CFLAGS from
env. This also spotted an issue where in a native build this resulted
in pkg_config_path being /bar instead of /foo:
`-Dpkg_config_path=/foo -Dbuild.pkg_config_path=/bar`

Fixes: #7573
2020-10-16 17:42:24 -04: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
Daniel Mensinger 7e58f33376
cmake: Add cross compilation support 2020-10-13 17:04:19 +02:00
Dylan Baker 88fecedc77 environment: provide a more detailed explanation of linker detection failures
Just saying "it failed" is accurate, but not useful to helping someone
figure out why it failed. Giving them the stdout and stderr (like we
might with compilers) should help people resolve the issue.

Fixes: #7173
2020-10-06 23:06:28 +03:00
Dylan Baker b309f4904b compilers/fortran: make ifort on windows signature match ICL's 2020-10-01 15:06:10 -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
Dylan Baker dff40ca259 environment: Pass defines to clang based ObjC[++] compilers
mypy noticed that we were passing [] (instead of a dict or None) to the
ClangCompiler class in objc, which made me noticed that for C and C++ we
set the defines, but not for ObjC and ObjC++
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
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
Tamás Bálint Misius 9d017a9c15 Improve regexp for MSVC target arch detection again 2020-09-13 06:27:57 +00:00
Jon Turney 77930d80c3 Store first line of VisualStudio compiler output as full_version
Store the first line of VisualStudio compiler output as full_version,
so it gets output when we report compiler details.
2020-09-11 20:45:09 +00:00
Daniel Mensinger 47373a2438
typing: get rid of most T.cast 2020-09-08 20:15:58 +02:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
Paolo Bonzini 492afe50a4 environment: use ExternalProgram to find ninja
This allows the NINJA environment variable to support all the Windows special
cases, especially allowing an absolute path without extension.

Based on a patch by Yonggang Luo.

Fixes: #7659
Suggested-by: Nirbheek Chauhan <nirbheek@centricular.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-04 15:38:12 +02:00
Matt Madison 3eab43136c environment: do not raise exception in detect_cuda_compiler
when the compiler is not a string.  When the compiler
is set in the build configuration (required, for example,
in a cross-build setup), the compiler setting is already
a list, which is the desired type.

Signed-off-by: Matt Madison <matt@madison.systems>
2020-09-02 17:48:39 +02:00
Christoph Reiter 0710ad18d9 Be stricter when detecting Windows/Cygwin
This removes the check for "mingw" for platform.system(). The only case I know
where "mingw" is return is if using a msys Python under a msys2 mingw environment.
This combination is not really supported by meson and will result in weird errors,
so remove the check.

The second change is checking sys.platform for cygwin instead of platform.system().
The former is document to return "cygwin", while the latter is not and just
returns uname().

While under Cygwin it uname() always starts with "cygwin" it's not hardcoded in MSYS2
and starts with the environment name. Using sys.platform is safer here.

Fixes #7552
2020-08-30 23:37:46 +03: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 9f338e41b0 Update LLVM tool versions for LLVM/Clang 10. 2020-08-22 18:57:09 +02: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
Peter Harris 0f90299b1c aix: allow both 32-bit and 64-bit objects in a static library
Without the -Xany flag, the ar command will complain when an .o file is
compiled for the non-default bit width. This change is necessary to allow
64-bit builds via a native (or cross) file.
2020-08-12 21:13:07 -04:00
Peter Harris abe72d5c84 aix: detect and support the AIX dynamic linker 2020-08-12 21:13:07 -04:00