Commit Graph

1034 Commits

Author SHA1 Message Date
Gijs Peskens 5a4168c410 Fix nasm when target has threads as added dependency 2023-01-18 10:05:33 -05:00
Luke Elliott d573db77bc clang-cl: supports /std:c++20 now.
See https://github.com/llvm/llvm-project/commit/a8f75d49
2023-01-04 09:47:13 -08:00
Dylan Baker f7cde8d3f6 Add fatal=False to many mlog.warnings()
There are lots of warnings that become fatal, that are simply unfixable
by the end user. Things like using old versions of software (because
they're using some kind of LTS release), warnings about compilers not
supporting certain kinds of checks, or standards being upgraded due to
skipped implementations (MSVC has c++98 and c++14, but not c++11). None
of these should be fatal, they're informative, and too important to
reduce to notices, but not important enough to stop meson if they're
printed.
2023-01-03 14:49:02 -05:00
Dylan Baker b9ef662926 reformat some warnings for better code readability 2023-01-03 14:49:02 -05:00
Kleis Auke Wolthuizen 18d2431685 emscripten: remove no longer relevant comment
This was fixed in Emscripten 1.39.16, see:
d4fabf3da4
2022-12-27 06:59:55 -05:00
Kleis Auke Wolthuizen cd6b67dea8 emscripten: enforce version 1.39.19 or higher 2022-12-27 06:59:55 -05:00
Kleis Auke Wolthuizen 4e1d0e4784 emscripten: remove redundant `thread_flags` implementation
Since it's the same as the one in `CLikeCompiler`.
2022-12-27 06:59:55 -05:00
Kleis Auke Wolthuizen 51ac9ed317 emscripten: use single arguments when specifying options
i.e. without a space between the "-s" and option name. See:
https://github.com/emscripten-core/emscripten/issues/11463

This is supported since Emscripten 1.39.19, see:
f45bea21f3
2022-12-27 06:59:55 -05:00
Kleis Auke Wolthuizen 898e85d847 emscripten: prefer `-pthread` over `-s USE_PTHREADS=1`
See: https://github.com/emscripten-core/emscripten/issues/12346

This is supported since Emscripten 1.38.33, see:
24350798a8
2022-12-27 06:59:55 -05:00
Nirbheek Chauhan 5dd3413b71 meson: Cache os.path.realpath in CLikeCompilerArgs
Profiling showed that we were spending 25s inside os.path.realpath()
on Windows while generating compile lines for build.ninja, inside
NinjaBackend.generate()

The real path for these will not (should not) change during a single
meson invocation, so cache all these.

Brings build.ninja generation from 73s to 47s on my machine.
2022-12-22 23:14:25 +05:30
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).

Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
2022-11-30 16:23:29 -05:00
Axel Ricard 23fcea16e5 Don't ignore documentation-related flags for D compilers
Fixes #11085
2022-11-29 01:45:23 +02:00
David Robillard 81d7c24a59 Add warning_level=everything
Adds a new maximum warning level that is roughly equivalent to "all warnings".
This adds a way to use `/Wall` with MSVC (without the previous broken warning),
`-Weverything` with clang, and almost all general warnings in GCC with
strictness roughly equivalent to clang's `-Weverything`.

The GCC case must be implemented by meson since GCC doesn't provide a similar
option.  To avoid maintenance headaches for meson, this warning level is
defined objectively: all warnings are included except those that require
specific values or are specific to particular language revisions.  This warning
level is mainly intended for new code, and it is expected (nearly guaranteed)
that projects will need to add some suppressions to build cleanly with it.

More commonly, it's just a handy way to occasionally take a look at what
warnings are present with some compiler, in case anything interesting shows up
you might want to enable in general.

Since the warnings enabled at this level are inherently unstable with respect
to compiler versions, it is intended for use by developers and not to be set as
the default.
2022-11-27 16:50:48 -05:00
Eli Schwartz 0404ad5601
compilers: remove opinionated c++ warning flag
-Wnon-virtual-dtor is not what people think of as a standard warning
flag. It was previously removed from -Wall in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16190 on the grounds that
people didn't like it and were refusing to use -Wall at all because it
forced this warning. Instead, it is enabled by -Weffc++ which is
typically not enabled and even comes with GCC documentation warnings
stating that the standard library doesn't obey it, and you might need to
`grep -v` and filter out warnings. (!!!)

It doesn't fit into the typical semantics of Meson's warning_level
option, which usually aligns with compiler standard warning levels
rather than a niche ideological warning level.

It was originally added in commit 22af56e05a,
but without any specific rationale included, and has gone unquestioned
since then -- except by the Meson users who see it, assume there is a
finely crafted design behind it, and quietly opt out by rolling their own
warning options with `add_project_arguments('-Wall', ...)`.

Furthermore a GCC component maintainer for the C++ standard library
opened a Meson bug report specially to tell us that this warning flag is
a "dumb option" and "broken by design" and "doesn't warn about the right
thing anyway", thus it should not be used. This is a reasonably
authoritative source that maybe, just maybe, this flag... is too
opinionated to force upon Meson users without recourse. It's gone beyond
opinionated and into the realm of compiler vendors seem to think that
the state of the language would be better if the flag did not exist at
all, whether default or not.

Fixes #11096
2022-11-22 23:27:33 -05:00
Ole André Vadla Ravnås fa86a9d96d nasm: Fix get_optimization_args() 2022-11-05 19:02:27 -04:00
Xavier Claessens 64a6969def nasm: Implement get_crt_compile_args()
This fix a crash when using NASM on Windows.
2022-11-01 18:51:10 +02:00
Xavier Claessens e68fcac919 compilers: Make sure to not use ccache in compiler checks
ccache was used in all command lines but disabled using CCACHE_DISABLE
in Compiler.compile() method. Wrapping invokations still has a cost,
especially on Windows.

With sccache things are even worse because CCACHE_DISABLE was not
respected at all, making configure *extremely* slow on Windows when
sccache is installed.
2022-10-25 17:24:56 -04:00
Xavier Claessens 2961adb8c8 Compilers: Keep ccache and exelist separated
Only combine them in the Compiler base class, this will make easier to
run compiler without ccache.
2022-10-25 17:24:56 -04:00
Tristan Partin 5a7427cebb Fix mismatched param names between Compiler and BasicLinkerIsCompilerMixin 2022-10-24 21:43:25 +03:00
Tristan Partin e05a88835a Use f-strings in JavaCompiler 2022-10-24 21:43:25 +03:00
Tristan Partin e87259f4a7 Add missing compiler functions to JavaCompiler
Fixes #2571
2022-10-24 21:43:25 +03:00
Robert Cohn 1939e567d6 basic support for oneapi compilers 2022-10-24 18:55:22 +03:00
Xavier Claessens 942aea230f Add MASM compiler
ml and armasm are Microsoft's Macro Assembler, part of MSVC.
2022-10-24 14:52:13 +02:00
Xavier Claessens e04bce3f04 Not all compilers support depfile 2022-10-24 14:52:13 +02:00
Xavier Claessens 4f4076bfc0 nasm: Harcode default path on Windows
NASM's installer does not add itself into PATH, even when installed by
choco.
2022-10-24 11:06:57 +02:00
Xavier Claessens d29ef2b128 Add yasm as fallback for nasm language 2022-10-24 11:06:57 +02:00
Xavier Claessens 01ee141339 Add NASM compiler 2022-10-24 11:06:57 +02:00
Xavier Claessens ebbaeec51b gnulike: Fix preprocessing files with any extension 2022-10-23 12:21:46 +02:00
Xavier Claessens 5e0f22896f Compilers: Add a preprocessor mode for clike compilers
A compiler object can now return a list of "modes", they are new
compiler object specialized for a specific task.
2022-10-23 12:21:46 +02:00
Tatsuyuki Ishi 673dca5c07 Add b_thinlto_cache for automatically configuring incremental ThinLTO 2022-10-13 04:18:13 -04:00
Tatsuyuki Ishi a0032480d6 clang: Support ThinLTO with mold 2022-10-13 04:18:13 -04:00
Jan Tojnar a590cfde0c compilers: Add optimization=plain option
https://github.com/mesonbuild/meson/pull/9287 changed the `optimization=0`
to pass `-O0` to the compiler. This change is reasonable by itself
but unfortunately, it breaks `buildtype=plain`, which promises
that “no extra build flags are used”.

`buildtype=plain` is important for distros like NixOS,
which manage compiler flags for optimization and hardening
themselves.

Let’s introduce a new optimization level that does nothing
and set it as the default for `buildtype=plain`.
2022-10-09 14:43:18 +03:00
Dylan Baker 676e66f853
pylint: enable consider-using-(min|max)-builtin
There's only one case of each, in the same function, so I've handled
both in the same commit.
2022-10-03 00:02:20 -04:00
Eli Schwartz 56a6ee1e5d find_library with argument beginning in "lib" is a bad idea, warn about it
We need to support cases where the library might be called "foo.so" and
therefore we check for exact matches too. But this also allows
`cc.find_library('libfoo')` to find libfoo.so, which is strange and
won't work in many cases. Emit a warning when this happens.

Fixes #10838
2022-09-28 12:53:46 +03:00
Xavier Claessens e1db50d4d9 compilers: Cleanup a bit languages/suffixes lists
Use set where order does not matter, fix is_source() to really mean only
source suffixes.
2022-09-27 11:15:07 -04:00
Eli Schwartz 30b1774628 compilers: unify fortran sanity check with its parent Clike handling
We *mostly* just need to do the same thing. Plug in one utility method
to make sanity_check_impl find the right compile args, and plug in
DEVNULL to the test run. It's that simple.

This solves a few inconsistencies. The main one is that fortran never
logged the sanity checks to the Meson debug log, making it hard to
debug.

There's also some interesting quirks we built up in the dedicated
fortran handling. For example:

- in commit 5b109c9ad2 we added cwd to
  building the fortran executable, with a wordy comment about how the
  compiler has defects. But the clike base has always done that on
  general principle anyway, so we would never have had that bug in the
  first place.

- in commit d6be7822a0 we added special
  deletion of an old "bad existing exe file" just for fortran. Looking
  at the PR discussion for this odd requirement, it turns out that the
  real problem is mixing WSL and native Windows without deleting the
  build directory. This is apparently fortran specific simply because
  "contemporary Windows 10 Fortran users" switch between the two?

  The actual problem is that this never used .exe as the output name, so
  Windows thinks you want to run something other than the thing you
  asked to run, because it's not even a Window executable. But... the
  common clike handling could have fixed that without needing special
  cases.
2022-09-22 18:15:25 -04:00
Eli Schwartz 332968da1b use simpler subprocess.run interface instead of manual Popen
This code dates back to 2012 and probably has no specific reason...
2022-09-22 18:15:25 -04:00
Eli Schwartz 0d354588ca compilers: make sanity checks log commands using join_args
It is more correct to join commands with a command joiner than a
whitespace joiner.
2022-09-22 18:15:25 -04:00
Dylan Baker 4da14918cd pylint: enable consider-using-in 2022-09-19 20:57:52 -04:00
Dylan Baker 188c552dcf pylint: enable use-maxsplit-arg
This finds a bunch of places where we can do more efficient string
splitting.
2022-09-19 20:57:52 -04:00
Eli Schwartz edc3e26369
fix odd mypy issue in unreachable code
This used to be fine, until imports were removed from this file. Now a
function annotated as T.NoReturn doesn't actually tell mypy that it
cannot return, though, so we manually do it.
2022-09-19 15:19:01 -04:00
Eli Schwartz 8277a1aba8
simplify type annotation 2022-09-19 15:19:00 -04:00
Eli Schwartz ab20eb5bbc
compilers: avoid importing compilers upfront for detect
We no longer need these upfront at all, since we now import the ones we
need for the language we are detecting, at the time of actual detection.

This avoids importing 28 files, consisting of just under 9,000 lines of
code, at interpreter startup. Now, it is only imported depending on
which languages are invoked by add_languages, which may not even be
anything. And even if we do end up importing a fair chunk of it for
C/C++ projects, spreading the import cost around the interpreter runtime
helps responsiveness.
2022-09-19 15:19:00 -04:00
Eli Schwartz cc5ef6478f
compilers: perform targeted imports for detect
Only import the ones we need for the language we are detecting, once we
actually detect that language.

This will allow finally dropping the main imports of these files in a
followup commit.
2022-09-19 15:19:00 -04:00
Eli Schwartz f6f876481f
compilers: use more direct checks for what kind of compiler we have
Instead of comparing against specific compiler classes, check the
logical compiler id or language etc.

In a couple cases, we seem to be missing a couple things by being a bit
too strict about the exact class type.
2022-09-19 15:19:00 -04:00
Eli Schwartz 775b67c5c1
compilers/detect: rename potentially conflicting name
Preparation for future commit.
2022-09-19 15:19:00 -04:00
Eli Schwartz 2b90152fe5
compilers: use consistent function signature for objc
e.g. for detect_c_or_cpp we just take the language itself as an
argument.
2022-09-19 15:19:00 -04:00
Eli Schwartz 4487a256e0
compilers: remove dead code
It doesn't matter whether the language is c or cpp, xc16 only has a C
compiler so that's what this has to be.
2022-09-19 15:19:00 -04:00
Eli Schwartz 5c4cd9162e
compilers: single-source compiler class as cls, consistently
It's the style for most, but not all, of this file.
2022-09-19 15:19:00 -04:00
Eli Schwartz d3dac3cfb2
compilers: don't export every compiler as a top-level property
This is wasteful and generally unneeded, since code can just use the
compiler they detected instead of manually poking at the internals of
this subpackage.

It also avoids importing an absolute ton of code the instant one runs
`from . import compilers`
2022-09-19 15:19:00 -04:00