Commit Graph

115 Commits

Author SHA1 Message Date
Dylan Baker b8368c1617 compilers: Put Intel compiler classes into the mixins folder 2019-07-15 10:59:22 -07:00
Dylan Baker cd5360821a compilers: split gnu and gnulike compilers out of compilers
I debated a bit whether both classes really belong in the same module,
and decided that they do because the share a number of helpers.
2019-07-15 10:59:22 -07:00
Dylan Baker d483da46a9 compilers: Move clike into a mixins directory
The compilers module is rather large and confusing, with spaghetti
dependencies going every which way. I'm planning to start breaking out
the internal representations into a mixins submodule, for things that
shouldn't be required outside of the compilers module itself.
2019-07-15 10:59:22 -07:00
Michael Hirsch, Ph.D c89aa20941 known Python 3.5 on windows workaround for subprocess(cwd=str(Path)) 2019-06-24 14:06:33 -04:00
Michael Hirsch, Ph.D 1d6ed8cac8 windows ifort can't do shared_library sanely 2019-06-24 14:06:32 -04:00
Michael Hirsch, Ph.D 5b109c9ad2 correct missing argument for IntelClFortranCompiler
ifort passes all tests

cleanup logic
2019-06-24 14:06:32 -04:00
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 7f1cecf25b compilers/fortran: Fix all has_argument methods in meson
Apparently we have no tests for this because this is broken pretty
badly. This extends the basic test to actually check for the correct
free-form argument and thus test this.
2019-05-16 22:01:35 +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 c0aa89e57f
Merge pull request #4952 from mensinda/cacheCompiles
Cache compilers.compile() in coredata
2019-05-02 14:54:02 -07:00
Michael Hirsch, Ph.D 06bfc2dab6 per-target manual specification of link_language 2019-05-02 23:26:51 +03:00
Daniel Mensinger 8a32fc8dbe
Disable cache for dependencies 2019-04-28 14:33:22 +02:00
Daniel Mensinger 47c06a7875
Add disable_cache to the fortran compiler 2019-04-28 14:33:22 +02: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
Tamer Fahmy 0259cc6de2 fortran: fix compile.links() when passing dependencies
With dependencies specifed, mode='compile' causes it to ignore the link
arguments and thereby always fails.
2019-04-22 15:46:43 -07:00
Michael Hirsch, Ph.D d6be7822a0 BUGFIX: don't crash Meson on bad existing exe file for Fortran sanity check 2019-04-05 23:50:22 +03: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
Michael Hirsch, Ph.D df74f8b7a9 more efficient submodule filenaming 2019-03-25 08:28:32 -04:00
Michael Hirsch, Ph.D a4827650fa BUGFIX: match submodule output names by compiler 2019-03-25 08:28:32 -04: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
Niklas Claesson dd2c44cdf6 Add static as keyword to find_library 2019-03-11 20:56:52 +02: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
Michael Hirsch, Ph.D 6b874339cc BUGFIX: Fortran openmp 2019-02-13 21:06:15 +02:00
Michael Hirsch, Ph.D 70e6f4198c Fortran 2008 submodule (#4874) 2019-02-05 22:41:44 +01:00
Michael Hirsch, Ph.D 8821c0aadc better handle variable HDF5 setups, update Fortran compiler def 2019-02-01 07:26:32 +00:00
Michael Hirsch, Ph.D cccffaa29d BUGFIX: allow fc.run(code) to work, pick only Fortran module 2019-01-29 23:25:23 +02:00
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
Michael Hirsch, Ph.D 9bb21be59b
FlangFortranCompiler inherit ClangCompiler 2019-01-16 17:06:44 -05:00
Michael Hirsch, Ph.D 9a318d3d5a
better handle link args: PGI and Flang
correct flang, pgi options
2019-01-16 17:06:44 -05:00
Michael Hirsch, Ph.D b40c1af900
Flang Fortran compiler added. 2019-01-16 17:06:43 -05:00
Michael Hirsch, Ph.D fff88b354a restore PGI compile functioning 2019-01-15 20:27:31 +02:00
Daniel Mensinger 9eca2e46a0
Added more compiler option support 2019-01-06 12:19:33 +01:00
Daniel Mensinger 9742927903
Absolute path generation refactoring 2019-01-06 12:19:32 +01:00
Dylan Baker b17ab09eaf compilers/fortran: pass -module ${path} instead of -module${path}
ifort doesn't like the latter, and gfortran seems happy with the former.
I don't have any of the other supported fortran compilers to test with.
2018-11-15 18:42:25 -08:00
Dylan Baker a7845d91aa ifort: ifort needs to have -lifcore like gfotran needs -lgfortran 2018-11-15 18:42:25 -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
Dylan Baker 7329ae3ce6 fortran: ifort doesn't have -pipe 2018-11-15 18:42:25 -08:00
Dylan Baker de175aac00 compilers: Use keyword only arguments for compiler interfaces
Because we need to inherit them in some cases, and python's
keyword-or-positional arguments make this really painful, especially
with inheritance. They do this in two ways:

1) If you want to intercept the arguments you need to check for both a
   keyword and a positional argument, because you could get either. Then
   you need to make sure that you only pass one of those down to the
   next layer.

2) After you do that, if the layer below you decides to do the same
   thing, but uses the other form (you used keyword by the lower level
   uses positional or vice versa), then you'll get a TypeError since two
   layers down got the argument as both a positional and a keyword.

All of this is bad. Fortunately python 3.x provides a mechanism to solve
this, keyword only arguments. These arguments cannot be based
positionally, the interpreter will give us an error in that case.

I have made a best effort to do this correctly, and I've verified it
with GCC, Clang, ICC, and MSVC, but there are other compilers like Arm
and Elbrus that I don't have access to.
2018-11-13 00:40:13 +02:00
David Seifert 69ec001b06 Use enum instead of `int` for compiler variants
* Enums are strongly typed and make the whole
  `gcc_type`/`clang_type`/`icc_type` distinction
  redundant.
* Enums also allow extending via member functions,
  which makes the code more generalisable.
2018-09-16 00:47:32 +03:00
Jussi Pakkanen 3d86a24b55 Remove unnecessary -lquadmath from FORTRAN flags. 2018-09-02 18:25:09 +03:00
Nirbheek Chauhan bb5f2ca3da find_library: Allow undefined symbols while linking
Shared libraries may not always be linkable without the use of other
libraries, so don't make it a linker error.
2018-08-22 12:24:43 -07:00
Bruce Richardson 8c9296e8e6 find_library: Use _build_wrapper to get library dirs
This means that we will take into account all the flags set in the
cross file when fetching the list of library dirs, which means we
won't incorrectly look for 64-bit libraries when building for 32-bit.

Signed-off-by: Nirbheek Chauhan <nirbheek@centricular.com>

Closes https://github.com/mesonbuild/meson/issues/3881
2018-08-22 12:24:43 -07:00
Jussi Pakkanen d83f77109a
Convert buildtype to optimization and debug options (#3489) 2018-08-18 20:39:47 +03:00
Nirbheek Chauhan 8cfb8fd02c
Fix searching of shared libraries on OpenBSD (#3851)
* get_library_naming: Use templates instead of suffix/prefix pairs

This commit does not change functionality, and merely sets the
groundwork for a more flexibly naming implementation.

* find_library: Fix manual searching on OpenBSD

On OpenBSD, shared libraries are called libfoo.so.X.Y where X is the
major version and Y is the minor version. We were assuming that it's
libfoo.so and not finding shared libraries at all while doing manual
searching, which meant we'd link statically instead.

See: https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs

Now we use file globbing to do searching, and pick the first one
that's a real file.

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

* find_library: Fix priority of library search in OpenBSD

Also add unit tests for the library naming function so that it's
absolutely clear what the priority list of naming is.

Testing is done with mocking on Linux to ensure that local testing
is easy
2018-07-09 09:45:02 -07:00
Nirbheek Chauhan 96b7fdb723 macos: Rewrite install_name for dependent built libraries on install
On macOS, we set the install_name for built libraries to
@rpath/libfoo.dylib, and when linking to the library, we set the RPATH
to its path in the build directory. This allows all built binaries to
be run as-is from the build directory (uninstalled).

However, on install, we have to strip all the RPATHs because they
point to the build directory, and we change the install_name of all
built libraries to the absolute path to the library. This causes the
install name in binaries to be out of date.

We now change that install name to point to the absolute path to each
built library after installation.

Fixes https://github.com/mesonbuild/meson/issues/3038
Fixes https://github.com/mesonbuild/meson/issues/3077

With this, the default workflow on macOS matches what everyone seems
to do, including Autotools and CMake. The next step is providing a way
for build files to override the install_name that is used after
installation for use with, f.ex., private libraries when combined with
the install_rpath: kwarg on targets.
2018-06-18 06:33:23 +00:00
Nirbheek Chauhan 186eed2dc6 find_library: Add a cache for library searching
Otherwise we can end up searching for the same library tens of times,
because pkg-config does not de-duplicate -lfoo args before returning
them.

We use -Wl,--start-group/end-group, so we do not need to worry about
ordering issues in static libraries.
2018-06-07 12:57:56 +00:00
Xavier Claessens aa879b7f0c Fix issues found by flake8 2018-06-06 20:02:37 +00:00
Matthew Krupcale 45cc001a40 Add support for finding libraries in Fortran projects
* mesonbuild/compilers/c.py: Make the `find_library` method more generic by allowing the user to supply the `code` for compiling and linking.
 * mesonbuild/compilers/fortran.py: Use the methods inherited from `Compiler` base class where appropriate. Also reuse `CComiler` methods where applicable. This should be sufficient to get various compiler/linker arguments as well as to compile and link Fortran programs. This was tested with `gfortran` compiler, and while the other compilers ought to work for simple cases, their methods are primarily inherited from the base `FortranCompiler` class.
 * test cases/fortran/10 find library/gzip.f90: Fortran module with some basic Fortran wrapper interfaces to `gzopen`, `gzwrite`, and `gzclose` C `zlib` functions.
 * test cases/fortran/10 find library/main.f90: Fortran program using the `gzip` Fortran interface module to write some data to a gzip file.
 * test cases/fortran/10 find library/meson.build: Meson build file for this test case. This demonstrates the ability to link the Fortran program against an external library.
2018-05-21 23:17:02 +03:00
Nirbheek Chauhan ed701b5cb0 Revert "Add macOS linker versioning information"
This reverts commit fa6ca16054.

Closes https://github.com/mesonbuild/meson/issues/3550
2018-05-09 23:11:15 +02:00
Jussi Pakkanen a2fdaa9ea0 Can use C++ and FORTRAN in a single target. Closes #2685. 2018-05-02 22:58:07 +03:00
Elliott Sales de Andrade dbb025a175 Add an OpenMP dependency.
This works similarly to the thread dependency which stores the various
inconsistent flags in each compiler.
2018-04-17 02:04:37 -04:00
Tom Schoonjans fa6ca16054 Add macOS linker versioning information
This patch exploits the information residing in ltversion to set the
-compatibility_version and -current_version flags that are passed to the
linker on macOS.
2018-04-16 22:26:16 +03:00
makise-homura 7cc41baa98 Added Elbrus lcc compilers support as inheritance from gcc ones 2018-03-19 23:30:00 +03:00
Aleksey Filippov 2cf85ae16f Use os.path: basename() and dirname() instead of split()
According to Python documentation[1] dirname and basename
are defined as follows:
    os.path.dirname() = os.path.split()[0]
    os.path.basename() = os.path.split()[1]
For the purpose of better readability split() is replaced
by appropriate function if only one part of returned tuple
is used.

[1]: https://docs.python.org/3/library/os.path.html#os.path.split
2018-01-30 07:08:22 +11:00
Jussi Pakkanen b6dd50db31
Merge pull request #2791 from behlec/compiler-version
Add more version information to compiler
2017-12-20 20:42:01 +02:00
Jussi Pakkanen 8eaa0a2732 Use -MD instead of -MMD for reliability. 2017-12-18 21:19:18 +02:00
Christoph Behle 1f3b41021d More version information for Fortran. 2017-12-16 15:38:31 +01:00
Nirbheek Chauhan 5764a26a4c gfortran: Add coverage arguments 2017-08-15 01:38:01 +05:30
Elliott Sales de Andrade 17b051c8b1 Add info on module include flag for Fortran compilers. 2017-08-04 20:07:08 -04:00
Jussi Pakkanen 2269b7f60b Add build_rpath as new property allowing people to specify rpath entries that are used in the build tree but will be removed on install. 2017-07-21 19:40:54 +03:00
Alistair Thomas 117f4ab8b5 Split out languages from compilers.py 2017-06-23 00:42:41 +01:00