Commit Graph

168 Commits

Author SHA1 Message Date
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Dylan Baker 5065db86f2 compilers/c: Fix removal of name from Combo options for ICL 2019-06-06 01:57:13 +03:00
John Ericson 4030e7cb7a UserOption no longer has a name field.
This avoids the duplication where the option is stored in a dict at its
name, and also contains its own name. In general, the maxim in
programming is things shouldn't know their own name, so removed the name
field just leaving the option's position in the dictionary as its name.
2019-05-15 14:21:47 +03:00
Dylan Baker fa54f05f09 compilers: Add basic ICL abstractions 2019-05-13 11:22:31 -07:00
Dylan Baker 080f59cf43 compilers: rename IntelCompiler to IntelGnuLikeCompiler
The Intel compiler is strange. On Linux and macOS it's called ICC, and
it tries to mostly behave like gcc/clang. On Windows it's called ICL,
and tries to behave like MSVC. This makes the code that's used to
implement ICC support useless for supporting ICL, because their command
line interfaces are completely different.
2019-05-13 11:22:31 -07:00
Dylan Baker 541523eeba compilers: Split C-Like functionality into a mixin classes
Currently C++ inherits C, which can lead to diamond problems. By pulling
the code out into a standalone mixin class that the C, C++, ObjC, and
Objc++ compilers can inherit and override as necessary we remove one
source of diamonding. I've chosen to split this out into it's own file
as the CLikeCompiler class is over 1000 lines by itself. This also
breaks the VisualStudio derived classes inheriting from each other, to
avoid the same C -> CPP inheritance problems. This is all one giant
patch because there just isn't a clean way to separate this.

I've done the same for Fortran since it effectively inherits the
CCompiler (I say effectively because was it actually did was gross
beyond explanation), it's probably not correct, but it seems to work for
now. There really is a lot of layering violation going on in the
Compilers, and a really good scrubbing would do this code a lot of good.
2019-05-03 10:36:50 -07:00
Dylan Baker da5f07cf39 Revert "detect Intel ICL on windows"
This reverts commit 3a75bb5259.
2019-05-02 14:56:23 -07:00
Dylan Baker c0aa89e57f
Merge pull request #4952 from mensinda/cacheCompiles
Cache compilers.compile() in coredata
2019-05-02 14:54:02 -07:00
Daniel Mensinger bf98ffca9e
Fix blind exceptions 2019-04-29 12:16:06 +02:00
Daniel Mensinger c61ae46461
Moved caching into a seperate function 2019-04-28 14:33:22 +02:00
Daniel Mensinger 8a32fc8dbe
Disable cache for dependencies 2019-04-28 14:33:22 +02:00
Daniel Mensinger 210fe5bf40
Add option to disable the cache 2019-04-28 14:33:21 +02:00
Daniel Mensinger 6969772a3e
Changing cached flag from True to False 2019-04-28 14:33:21 +02:00
Daniel Mensinger 971dfd664b
Added some cahced values 2019-04-28 14:33:21 +02:00
Daniel Mensinger dfe3d56bfd
Print '(cached)' when compiler result was cached 2019-04-28 14:33:21 +02:00
Daniel Mensinger c9bd84fd25
Cache compile results in coredata 2019-04-28 14:31:49 +02:00
Michael Hirsch, Ph.D 3a75bb5259 detect Intel ICL on windows
ICL CPP working
2019-04-27 23:19:01 -04:00
Michael Hirsch, Ph.D ee40533b61 better default order for fotran compiler search
correct PGI windows detection

doc

cleanup PGI detect
2019-04-27 23:19:01 -04:00
Dylan Baker 5678468c2c Don't use len() to test for container emptiness
I ran the numbers once before (it's in the meson history) but it's
*much* faster to *not* use len for testing if a container is empty or
not.
2019-04-25 12:28:51 -07:00
Nirbheek Chauhan 7654db511c vs: Update toolset table for VS 2019
Also add a test to ensure that we don't forget it in the future.
2019-04-18 09:01:23 +00:00
jrl64 a2d222c383 Update Built-in Option c_std for C17. Closes #4842. 2019-04-10 23:14:51 +03:00
Dylan Baker 6ad7fbf950 dependencies/misc: don't special case threads
Instad of having special casing of threads in the backends and
everywehre else, do what we did for openmp, create a real
dependency. Then make use of the fact that dependencies can now have
sub dependencies to add threads.
2019-04-05 16:41:08 -07:00
John Ericson f4da210f46 Sanity check with external args
Previously cross, but not native, external args were used. Then in
d451a4bd97 the cross special cases were
removed, so external args are never used.

This commit switches that so they are always used. Sanity checking works
just the same as compiler checks like has header / has library.
2019-03-27 10:54:56 -04:00
John Ericson e677704d21 Don't collect preprocssor flags separately from compiler flags
I recall that @jpakkane never wanted this, but @nirbheek did, but then
@nirbheek changed his mind.

I am fine either way except for the cross inconsistency that exists
today: There is no `c_preproc_args` or similar one can put in the cross
file, so no way to replicate the effect of CPPFLAGS during cross
compilation.
2019-03-27 14:45:42 +00:00
Jussi Pakkanen 3a613564d3
Merge pull request #5116 from dcbaker/openmp-de-specialize
dependencies/openmp: Don't special case OpenMP
2019-03-21 01:21:37 +02:00
Dylan Baker ac627bcea7 replace library type strings with an enum
This patch creates an enum for selecting libtype as static, shared,
prefer-static, or prefer-shared. This also renames 'static-shared'
with 'prefer_static' and 'shared-static' with 'prefer_shared'. This is
just a refactor with no behavioral changes or user facing changes.
2019-03-20 18:45:56 +02:00
Dylan Baker 1f342a2081 dependencies/openmp: Don't special case OpenMP
Currently we specialcase OpenMP like we do threads, with a special
`need_openmp` method. This seems like a great idea, but doesn't work
out in practice, as well as it complicates the opemp
implementation. If GCC is built without opemp support for example, we
still add -fopenmp to the the command line, which results in
compilation errors.

This patch discards that and treats it like a normal dependency,
removes the need_openmp() method, and sets the compile_args attributes
from the compiler.

Fixes #5115
2019-03-19 12:48:22 -07:00
Jussi Pakkanen 44dd5535f0
Merge pull request #4724 from jon-turney/lib-machine-always
Fix linking when cross-compiling and a windows resource is first object
2019-03-19 20:39:34 +02:00
Nirbheek Chauhan bcee8fb8ca compilers: Update comment about library search patterns 2019-03-14 12:21:05 +00:00
Nirbheek Chauhan 07818dac6a compilers: Try harder to dedup builtin libs
Compiler internal libs should always be de-duplicated, no matter what.

Closes https://github.com/mesonbuild/meson/issues/2150

Test case is by Bruce Richardson in the issue.
2019-03-14 12:21:05 +00:00
Niklas Claesson dd2c44cdf6 Add static as keyword to find_library 2019-03-11 20:56:52 +02:00
Antoine Jacoutot 03c0c3a8f4 Fix _get_patterns on OpenBSD
We need to account to the possible prefixes (empty or 'lib').
This allows both to work:
cc.find_library('foo')
cc.find_library('libfoo')
2019-03-11 06:02:17 +00:00
jml1795 a9e63568fe Add warning level zero 2019-02-19 00:06:27 +02:00
John Ericson d451a4bd97 Remove get_cross_extra_flags
This is no longer needed, we just remove conditionals around it.
2019-02-15 09:17:24 -08:00
John Ericson 19f81d3e33 Never access environment.properties downstream
Instead use coredata.compiler_options.<machine>. This brings the cross
and native code paths closer together, since both now use that.

Command line options are interpreted just as before, for backwards
compatibility. This does introduce some funny conditionals. In the
future, I'd like to change the interpretation of command line options so

 - The logic is cross-agnostic, i.e. there are no conditions affected by
   `is_cross_build()`.

 - Compiler args for both the build and host machines can always be
   controlled by the command line.

 - Compiler args for both machines can always be controlled separately.
2019-02-02 13:59:14 -05:00
Nirbheek Chauhan 50b863032e find_library: Check arch of libraries on Darwin
macOS provides the tool `lipo` to check the archs supported by an
object (executable, static library, dylib, etc). This is especially
useful for fat archives, but it also helps with thin archives.

Without this, the linker will fail to link to the library we mistakenly
'found' like so:

ld: warning: ignoring file /path/to/libfoo.a, missing required architecture armv7 in file /path/to/libfoo.a
2019-01-31 20:36:49 +00:00
Nirbheek Chauhan c0166355ce Rewrite appleframework and extraframework dependency classes
Instead of only doing a naive filesystem search, also run the linker
so that it can tell us whether the -F path specified actually contains
the framework we're looking for.

Unfortunately, `extraframework` searching is still not 100% correct in
the case when since we want to search in either /Library/Frameworks or
in /System/Library/Frameworks but not in both. The -Z flag disables
searching in those prefixes and would in theory allow this, but then
you cannot force the linker to look in those by manually adding -F
args, so that doesn't work.
2019-02-01 00:14:09 +05:30
Michael Hirsch, Ph.D 8636f31d9c BUGFIX: broken/missing Fortran code/unit tests 2019-01-27 20:57:21 +02:00
Michael Hirsch, Ph.D 72486afd08 Add PGI C and C++ compilers (#4803) 2019-01-21 20:09:36 +02:00
Phillip Cao 13fe2e40eb Add get_werror_args for CCRX C compiler 2019-01-10 22:56:47 +02:00
Daniel Mensinger 9742927903
Absolute path generation refactoring 2019-01-06 12:19:32 +01:00
Jon Turney a223b20bb6
Fix linking when cross-compiling and a windows resource is first object
It appears that LIB/LINK default to the host architecture if they can't
guess it from the first object.  With the MSVC toolchain, resource files
are (usually) compiled to an arch-neutral .res format.  Always
explicitly provide a '/MACHINE:' argument to avoid it guessing
incorrectly when cross-compiling.
2019-01-05 20:22:13 +00:00
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
Jon Turney a872b925ea
Store the target architecture for CL-like compilers
Store the MSVC compiler target architecture ('x86', 'x64' or 'ARM' (this
is ARM64, I believe)), rather than just if it's x64 or not.

The regex used for target architecture should be ok, based on this list
of [1] version outputs, but we assume x86 if no match, for safety's
sake.

[1] https://stackoverflow.com/a/1233332/1951600

Also detect arch even if cl outputs version to stdout.

Ditto for clang-cl

Future work: is_64 is now only used in get_instruction_set_args()
2018-12-06 13:25:16 +00:00
Jussi Pakkanen 2c91ca3d6a Remove linkerlike args from compile checks. Closes #4542. 2018-11-27 22:17:38 +02:00
Jon Turney a33acd31da Fix flake8 'imported but unused' reports
$ flake8 | grep F401
./run_unittests.py:43:1: F401 'mesonbuild.mesonlib.is_linux' imported but unused
./mesonbuild/compilers/c.py:32:1: F401 '.compilers.CompilerType' imported but unused
./mesonbuild/compilers/cpp.py:23:1: F401 '.compilers.CompilerType' imported but unused
2018-11-19 21:07:37 +02:00
Dylan Baker 0092a7d3f9
Merge pull request #4359 from dcbaker/icc-fixes
ICC fixes for Linux and MacOS
2018-11-17 06:57:07 -08:00
Jussi Pakkanen aa20c91e6e Guard against broken lib paths returned by gcc. 2018-11-17 16:26:02 +02:00
Dylan Baker 842d8556ec compilers: quiet ICC messages about pch
These are useful for debugging, but not interesting for end users, where
it just adds lines between ninja jobs without adding value.
2018-11-15 19:07:28 -08:00
Dylan Baker 9f9cfd2139 compilers: Move get_allow_undefined_link_args to Compiler
This allows each implementation (gnu-like) and msvc to be implemented in
their respective classes rather than through an if tree in the CCompiler
class. This is cleaner abstraction and allows us to clean up the Fortran
compiler, which was calling CCompiler bound methods without an instance.
2018-11-15 18:42:25 -08:00