Commit Graph

41 Commits

Author SHA1 Message Date
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 bb3fe3c451 compilers/mixins/clike: fix mypy issues 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
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
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
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
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
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
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
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
Ole André Vadla Ravnås 859dc4255a Fix outdated cross-compilation checks 2020-05-13 15:51:54 +00:00
Christoph Reiter c4fa0fac3d Fix has_function() for clang on 64bit Windows
has_function() tries to link an example program using the function
to see if it is available, but with clang on 64bit Windows this
example always already failed at the compile step:

error: cast from pointer to smaller type 'long' loses information
            long b = (long) a;

This is due to long!=pointer with LLP64

Change from "long" to "long long" which is min 64bit and should always
fit a pointer. While "long long" is strictly a C99 feature every
non super ancient compiler should still support it.
2020-05-13 08:16:54 +00:00
Christoph Reiter d7e20b1543 Fix builtin check in has_function() with GCC 10 on Windows
The builtin check had a special case that if a header was provided and
the function wasn't defined, it would ignore the builtin to avoid
non-functional builtins (for example __builtin_posix_memalign in MSYS2).

GCC 10 gained support for __has_builtin() which now skipps this check
and because __has_builtin(__builtin_posix_memalign) returns true the
non functional builtin is now reported as available.

To get the old behaviour back move the special case in front of the actual
availability check.

Fixes #7113
2020-05-11 14:53:25 -07:00
Andrew Udvare 39ca178d21 compilers: fix type issue
mesonlib.darwin_get_object_archs() only accepts a string argument so convert
it.
2020-04-23 10:00:27 -07:00
Nirbheek Chauhan dc19b13202 compilers: Silence warning about gnu_inline with clang
The warning is due to a change in behaviour in Clang 10 and newer:

https://releases.llvm.org/10.0.0/tools/clang/docs/ReleaseNotes.html#c-language-changes-in-clang

This was already fixed for clang++, but not for clang for some reason.
It was also fixed incorrectly; by adding `extern` instead of moving
from `-Werror` to `-Werror=attributes`.
2020-04-20 19:30:57 +03:00
Ole André Vadla Ravnås c0a8abc580 compilers: Honor <lang>_ld when linking C-like outputs 2020-04-17 18:23:40 +03:00
Dylan Baker b5e077fce8 compilers: Move things out of clike
One method belongs in the base Compiler class, the other belongs in
the GnuLikeCompiler class.
2020-04-10 12:33:34 -07:00
Michael Hirsch, Ph.D 5b4ebb5641 quality / test: Fortran type hinting
enhance fortran args tests
2020-04-05 13:43:53 +03:00
Andrei Alexeyev 96ed64caa1 Make cc.has_function work on GCC/Clang __builtins 2020-04-04 20:51:35 +03:00
Richard Weinberger 12fa8d06e2 Fix exe_wrapper usage in EmptyExternalProgram case
If no exe_wrapper is set in the meson cross file the exe_wrapper
object will be an instance of EmptyExternalProgram.
So, found is True and prorgram is an empty list.

This will cause meson to tun the compiler sanity check because
it checks only for self.is_cross and self.exe_wrapper being
not None.

I ran into that situation while cross compiling for ia32 on a
x64_64 host. The host had no ia32 userspace installed, so the
self test failed.

As workaround I currently set exe_wrapper to 'true'.

Signed-off-by: Richard Weinberger <richard@nod.at>
2020-03-19 19:09:18 +02:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Daniel Mensinger e4a0ee205d lgtm: Fix redundant code 2019-12-05 00:22:10 +02:00
Xavier Claessens e4e5f981eb Fix compute_int() when the value is -1 2019-11-21 01:32:11 +02:00
Michael Hirsch, Ph.D 83b4e981c4 Use strict function prototypes 2019-11-18 22:21:36 +02:00
Aleksey Gurtovoy 6ac5db50c9 CUDA support on Windows 2019-09-24 14:22:20 -07:00
Jehan 179861ccd1 mesonbuild: fix exception name.
CrossNoRunException is in compilers module, not mesonlib.
2019-09-23 13:25:53 -04:00
Dylan Baker 06dcbd50ee compilers: Dispatch to dynamic linker class
Most of the cuda code is from Olexa Bilaniuk.
Most of the PGI code is from Michael Hirsc
2019-08-14 13:13:23 -07:00
Michael Hirsch, Ph.D 7eebb6749a
no special shared lib args for PGI 2019-07-30 15:29:51 -04:00
Martin Liska c1870889b1 Fix missing return statements that are seen with -Werror=return-type.
Error example:

Code:

        #include <locale.h>
        int main () {
            /* If it's not defined as a macro, try to use as a symbol */
            #ifndef LC_MESSAGES
                LC_MESSAGES;
            #endif
        }
Compiler stdout:

Compiler stderr:
 In file included from /usr/include/locale.h:25,
                 from /tmp/tmpep_i4iwg/testfile.c:2:
/usr/include/features.h:382:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  382 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~
/tmp/tmpep_i4iwg/testfile.c: In function 'main':
/tmp/tmpep_i4iwg/testfile.c:8:9: error: control reaches end of non-void function [-Werror=return-type]
    8 |         }
      |         ^
cc1: some warnings being treated as errors
2019-07-16 09:49:03 +02:00
Dylan Baker f574beffb4 compilers/mixins/elbrus: add type annotations and fix types
There is a pretty big error in here, trying to return a tuple
comperhension: (a for a in []) is not a tuple, it's a generator. This
has profound type annotations: generators don't support most tuple or
list methods, and they can only be iterated once. Beyond that tuples are
meant for heterogenous types, ie, position matters for types. I've
converted the output to a list in all cases.
2019-07-15 10:59:22 -07:00
Dylan Baker 214ab455d3 compilers: Move the VisualStudioLikeCompiler class into mixins 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