Commit Graph

108 Commits

Author SHA1 Message Date
Paolo Bonzini 2c10d77c3c compilers: introduce get_exe() and get_exe_args()
This will be used by rustdoc tests because the Test objects takes a
single string for the command and everything else goes in the args.
But apart from this, the need to split the executable from the
arguments is common so create new methods to do it.

While at it, fix brokenness in the handling of the zig compiler, which
is checking against "zig" but failing to detect e.g. "/usr/bin/zig".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02 08:44:37 -07:00
Andrei Horodniceanu 77dd0429cf mesonbuild/compilers/detect.py: Support Open D ldc and dmd
Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
2025-03-12 09:09:35 -07:00
Dylan Baker 5d648a112f compilers/detect: Split -beta and -nightly suffixes from rustc
Store both a full version with the nightly and beta suffixes, and the
version as just X.Y.Z. This sort of distinction is why full_version
exists.

This fixes an issue with the bindgen module where we pass invalid
version of X.Y.Z-beta and X.Y.Z-nightly.
2025-02-27 15:27:42 -05:00
Dylan Baker 1eaab0253b compilers: Check if GCC has support for ObjC and/or ObjC++
Since this is optional, we should not accept that GCC is a valid ObjC or
G++ is a valid ObjC++ Compiler unless we've tested that they can
actually do a basic compile.

This requires fixing a number of tests that have broken assumptions. In
some cases I've split tests where issues with one language would hide
the other. It would be great if we had a competent test framework that
allowed subtests to skip, unfortunately we have python's unittest
instead. Because of that we can't avoid extra tests by use of subtests.
2025-01-27 09:38:53 -08:00
Wu, Zhenyu 910db36e38 Add Linear ASM compiler
Fix #13670
2025-01-09 14:52:09 +02:00
gerioldman b95e1777dd First draft version of Tasking MIL linking with b_lto and prelinking 2025-01-08 01:52:03 +01:00
gerioldman 62c5db2cb3 Add TASKING compiler support 2025-01-08 01:52:03 +01:00
Paolo Bonzini 1f1a6d3a45 rust: raise a warning if clippy is used instead of rustc
clippy-driver is not meant to be a general-purpose compiler front-end.
Since Meson can now provide natively the ability to invoke clippy,
raise a warning if someone uses it that way.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-12-19 09:25:20 -08:00
Raul Tambre 5399d3de02 compilers/detect: remove unsupported -cpp flag for Clang preprocessor detection
Clang's resource files, e.g. /usr/share/clang/clang++.cfg, can be used to bump the default standard level across the system.
However due to llvm/llvm-project#61641 `clang++ -std=c++17 -E -dM -` doesn't work. The workaround is to pass the language explicitly.
4ad792e158 fixed the issue by passing the language explicitly, but started passing the `-cpp` flag, which Clang doesn't support.
Basically Clang would always fallback to the second detection attempt as a result. Remove the unsupported flag and the above scenarios works now too. 🙂

See-also: https://github.com/llvm/llvm-project/issues/61641
Fixes: 4ad792e158
2024-09-30 09:21:01 -07:00
Andrew McNulty 050b788ed8 Fix various incorrect uses of `its` vs `it's`.
These errors can make reading comments and documentation
unnecessarily confusing for users and contributors who
do not speak English as their first language.
2024-09-14 20:20:38 +03:00
spaette 4179996fef Fix typos 2024-09-11 15:51:04 -07:00
Zihua Wu e940d58677
fix LDFLAGS for cuda
LDFLAGS may contain flags that nvcc is unable to handle and these flags
need to be processed before we pass them to nvcc
2024-09-06 16:00:19 -04:00
Jussi Pakkanen 0bd45b3676 Use proper array form in swiftc. 2024-08-23 15:36:33 -07:00
slimeuniverse 45db23394f Discard swiftc linker detect output
"swiftc -Xlinker -v tmp.swift" command used to detect swift linker
creates junk files in working directory. This fix forwards output to
/dev/null
2024-08-23 22:45:26 +03:00
Jonathan Schleifer 81b151f611 Fix compiling ObjC/ObjC++ on Windows/MinGW
Co-Authored-By: L. E. Segovia <amy@amyspark.me>
2024-08-08 15:56:43 -07:00
H. Vetinari 1e26a88481
add initial support for llvm-flang 2024-07-28 18:57:57 -04:00
Sam James 2a9f40ff7a
compilers: make lang_map public 2024-06-24 00:36:40 +01:00
Sam James 4ad792e158
compilers: detect: fix pre-processor scraping by defining language
_get_gnu_compiler_defines and _get_clang_compiler_defines were broken
by not defining the language they used.

Neither GCC nor Clang infer the language based on the driver name which means
`self.defines` isn't populated correctly in compilers/cpp.py.

e.g.
```
 $ echo "" | g++ -E -dM - | grep -i cplus

 $ echo "" | g++ -x c++ -E -dM - | grep -i cplus
 #define __cplusplus 201703L
```

Fix that by passing '-cpp -x LANGUAGE' as a first pass. If it fails, try
again without '-cpp -x LANGUAGE' as before, as its portability isn't
certain. We do '-cpp' because during testing, I found Fortran needs this,
although per below, I had to drop Fortran in the end and leave it to the
fallback (existing) path.

Without this change, a63739d394 is only
partially effective. It works if the system has injected Clang options
via /etc/clang configuration files, but not by e.g. patching the driver
(or for GCC there too).

Unfortunately, we have to wimp out for Fortran and fallback to the
old method because you need the language standard (e.g. -x f95).
2024-06-24 00:36:06 +01:00
Sam James b56a3198b4
compilers: detect: fix comment/error string in _get_gnu_compiler_defines
Make the debug & error message strings consistent between the GCC and Clang probes.

Copy-paste error. Here, we're scraping pre-processor tokens, not checking
for the compiler type.
2024-06-24 00:32:24 +01:00
Sam James 4cebb77e1e
compilers: detect: fix typo in comment 2024-06-24 00:32:24 +01:00
Axel Ricard 4c6d370a0e add cross-compile argument for ldc linker guessing 2024-05-22 23:53:09 +03:00
Axel Ricard 8d7ffe6e86 fix sanity check for d cross-compilation 2024-05-22 23:53:09 +03:00
Jussi Pakkanen f24307e559
Merge pull request #11421 from mon/ti-armclang
Basic support for TI Arm Clang toolchain
2024-05-15 22:53:58 +03:00
Jonathan Schleifer 205f09e1b0 Prefer Clang over GCC for Objective-C(++)
GCC only has very limited support for Objective-C and doesn't support
any of the modern features, so whenever Clang is available, it should be
used instead. Essentially, the only reason to ever use GCC for
Objective-C is that Clang simply does not support the target system.
2024-04-28 03:14:29 -04:00
Xavier Claessens 6a1732a29d nasm: Fallback to native compiler when cross compiling
If nasm is not defined in cross file binaries we can fallback to build
machine nasm.

When cross compiling C code we need a different gcc binary for native
and cross targets, e.g. `gcc` and `x86_64-w64-mingw32-gcc`. But when
cross compiling NASM code the compiler is the same, it is the source
code that has to be made for the target platform. We can thus use nasm
from build machine's PATH to cross compile for Windows on Linux for
example. The difference is the arguments Meson will pass when invoking
nasm e.g. `-fwin64`. That is already handled by NasmCompiler class.
2024-04-26 23:09:30 +05:30
William D. Jones 886836a69b Don't sanitize a None path when checking for, but could not find, unsupported cl clones. 2024-04-15 07:25:19 -07:00
Will Toohey 456d879ff4 Fix regression in TI CGT support
When C6000 support was added in #12246, TI compilers were given the correct version argument.
This broke the previous check which relied on an error being thrown by the compiler.
2024-04-03 13:47:23 +10:00
Xavier Claessens c1076241af compilers: No need to pass exe_wrapper everywhere
Places where compiler needs it already have access to Environment object
and can use it directly.

This fixes mypy complaining that not all compilers have self.exe_wrapper
in run() method that got moved to base class.
2024-03-15 11:38:54 -04:00
Petr Machacek eb74bb8dbf Added support for Texas Instruments C6000 compiler. 2024-03-12 20:38:30 +02:00
Charles Brunet f9479787a0 fix reconfigure subproject base options 2024-03-10 13:09:32 -07:00
Charles Brunet 76f6874e48 Fix base and compiler options not reconfigurable.
Fixes #12920.
2024-03-01 12:09:22 -08:00
dragonmux a234c001a0 compilers/detect: Implemented logic for checking suffixed LLVM tools before non 2024-02-24 11:35:02 -08:00
H. Vetinari 6fcf8632c6 fix UnboundLocalError if guess_win_linker fails in detect_fortran_compiler 2024-02-02 09:24:41 -08:00
Dylan Baker 314d9f0c74 Differentiate message between dynamic linker and archiver
Currently both print `Detecting linker via`, which can be confusing.
Clarifying this by printing "archiver" instead of "linker" for the
static linker/archiver
2024-01-26 15:04:58 -05:00
Dylan Baker e991c4d454 Use SPDX-License-Identifier consistently
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.

This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.

SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field
2023-12-13 15:19:21 -05:00
H. Vetinari cc5a95a56a detect windows linkers for flang in detect_fortran_compiler 2023-12-11 21:54:47 +02:00
Will Toohey 8c70ce466b More robust linker detection for armar (TI vs non-TI) 2023-12-01 22:11:41 +02:00
Filipe Laíns 025bcc0d9d compilers: fix compiler detection when the "ccache" string is in the path
Signed-off-by: Filipe Laíns <lains@riseup.net>
2023-09-01 02:09:21 -04:00
Eli Schwartz 90ce084144
treewide: automatic rewriting of all comment-style type annotations
Performed using https://github.com/ilevkivskyi/com2ann

This has no actual effect on the codebase as type checkers (still)
support both and negligible effect on runtime performance since
__future__ annotations ameliorates that. Technically, the bytecode would
be bigger for non function-local annotations, of which we have many
either way.

So if it doesn't really matter, why do a large-scale refactor? Simple:
because people keep wanting to, but it's getting nickle-and-dimed. If
we're going to do this we might as well do it consistently in one shot,
using tooling that guarantees repeatability and correctness.

Repeat with:

```
com2ann mesonbuild/
```
2023-08-11 13:41:03 -04:00
Eli Schwartz e2ce53b6b4
compilers: detect cython version on stdout for newer cython versions
Cython historically, when asked to print the version and exit
successfully, would do so on stderr, which is weird and inconsistent.
Recently, it fixed this UX bug by printing on stdout instead:

https://github.com/cython/cython/issues/5504

This then broke meson detection because we assumed it was on stderr due
to historically being there:

https://github.com/scipy/scipy/issues/18865

Cython is right, and shouldn't have to revert this reasonable change for
backwards compatibility. Instead, check both.
2023-07-12 15:56:51 -04:00
Eli Schwartz a1ef957e34
linkers: delay implementations import until detect is run
This saves on a 1500-line import at startup and may be skipped entirely
if no compiled languages are used. In exchange, we move the
implementation to a new file that is imported instead.

Followup to commit ab20eb5bbc.
2023-06-26 13:10:33 -04:00
Alyssa Ross 8c766f5b5b compilers: don't recommend deprecated env var
RUST_LD was deprecated in Meson 0.54 in favor of RUSTC_LD.
2023-06-19 15:19:41 -04:00
Eli Schwartz d87d912e5d
compilers: fix detection of ifx compiler
The version output scraping for identifying strings checked for "IFORT"
in parentheses after the executable name, which is probably a mistake by
Intel. Current versions of ifx have "IFX" in parentheses there.

Detect both.

Fixes #11873
2023-06-14 01:04:55 -04:00
Eli Schwartz a6bf2c1e2c
compilers: add logging for non c_or_cpp language detection 2023-06-14 01:04:55 -04:00
Eli Schwartz aa13c46822
WIP: refactor loggable popen calls for consistency 2023-06-14 01:04:55 -04:00
Volker Weißmann 2699fd4b8a During reconfigure, show that no compiler was found, if compiler fails sanity check. 2023-05-13 11:06:24 +03:00
Nomura c1fce8f60f Initial support for Metrowerks Assembler 2023-05-06 19:57:06 +03:00
Nomura 18cfa545f0 Initial support for Metrowerks C/C++ compiler 2023-04-24 09:07:37 -04:00
Sebastian Dröge 22960758aa rust: Use the corresponding rustc version when clippy-driver is chosen as Rust compiler
By default clippy-driver will report its own version, which is not very
useful to check the toolchain version. Instead make sure to extract the
actual toolchain version here.
2023-04-14 15:52:54 +05:30
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -04:00