summaryrefslogtreecommitdiff
path: root/test cases/rust
AgeCommit message (Collapse)Author
2024-07-15test/rust: Replace gcc -m argument with a -f argumentDylan Baker
-m arguments aren't portable across architectures. -fipa-pta will hopefully be portable for GCC, but also not implemented by clang. Fixes: #13417
2024-07-10tests: Clean up leftover files from source dirs.Jussi Pakkanen
2024-06-14cargo: Load Cargo.lockXavier Claessens
Cargo.lock is essentially identical to subprojects/*.wrap files. When a (sub)project has a Cargo.lock file this allows automatic fallback for its cargo dependencies.
2024-05-24Revert "rust: recursively pull proc-macro dependencies as well"Sam James
This reverts commit aee941559c4b88a062e88186819a820c69c200ae. The commit being reverted breaks compilation of a major Meson consumer (Mesa). As a result, various distros are either pinning to <1.4.0 (before the commit) or performing this same revert downstream. Fixing a regression takes priority, so let's revert. Fixes: https://github.com/mesonbuild/meson/issues/12973
2024-04-15tests: fix missing dependency causing flaky build failureEli Schwartz
We have two copies of other.h, one of which is generated. If we don't include the include/ directory then building fails unless the custom_target which copies it over, happens to run early enough. On parallel builds this may fall on its face.
2024-03-15compilers: Every compiler can run codeXavier Claessens
Compiling and linking code is part of the Compiler base class, there is no reason it cannot also run executables.
2024-03-15cargo: Add API version into dependency nameXavier Claessens
2024-03-05rust: Link with rlib external dependenciesXavier Claessens
When linking with a Rust rlib, we should also link with its external system dependencies. This was currently done only for C ABI crates, do it for both rlib and staticlib now.
2024-02-29rust: recursively pull proc-macro dependencies as wellXavier Claessens
When the proc-macro rlib is in a different subdir, it would miss the needed -L argument and rustc would not find it. Meson was assuming that proc-macros are only needed when building libraries that uses it, but it turns out that was wrong, as show by the unit test.
2024-02-27cargo: support lib.path in Cargo.tomlAlyssa Ross
Cargo implements this configuration option to override the entry point of the library. To get test coverage, I've modified one of the two Cargo subprojects in the test to use a non-default library entrypoint. The other still uses the default.
2024-02-26cargo: Call into meson subdir if it existsXavier Claessens
This allows projects to manually add extra rust args and deps. This is intended to replace build.rs logic.
2024-02-26cargo: Expose features as Meson boolean optionsXavier Claessens
2024-02-24add test for generating static inline wrappersKarol Herbst
2024-02-23modules/rust: allow setting a version constraint on bindgenDylan Baker
This allows us to ensure that the bindgen we're using is suitable for our purpose.
2024-02-23modules/rust: inject a C/C++ standard for bindgenDylan Baker
Especially for C++ this is very important.
2024-02-23modules/rust: Allow explicitly setting the language to bindDylan Baker
This may be of particular use when a header is .h but should be treated as a C++ header instead of a C header.
2024-02-23rust/bindgen: Use Meson rules for C++ headersDylan Baker
Bindgen natively only considers .hpp to be C++ headers, but Meson considers some additional extensions including .hh and .hxx to be C++.
2024-01-17rust: fix linking static executablesAlyssa Ross
For the same reason as for static libraries, we have to use -l when generating static executables. Fixes: https://github.com/mesonbuild/meson/issues/12585
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
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-11-13rust: Add transitive dependencies to ninja rulesXavier Claessens
In the case r1 -> s1 -> s2 where s1 and s2 are uninstalled C static libraries, the libs1.a rule does not depend on libs2.a. That means that r1 rule must depend on both s1 and s2.
2023-11-12Renumber test dirs for rc3.Jussi Pakkanen
2023-11-09rust: Fix linking with C libraries (again)Xavier Claessens
Pass link arguments directly down to linker by using `-C link-args=` instead of letting rustc/linker resolve `-l` arguments. This solves problems with e.g. +verbatim not being portable. Note that we also pass `-l` args as `-Clink-args=-l` because rustc would otherwise reorder arguments and put `-lstdc++` before `-Clink-args=libfoo++.a`. However, when building a rlib/staticlib we should still use `-l` arguments because that allows rustc to bundle static libraries we link-whole. In that case, since there is no platform specific dynamic linker, +verbatim works. This also fix installed staticlib that now bundle uninstalled static libraries it links to (recursively). This is done by putting them all into self.link_whole_targets instead of putting their objects into self.objects, and let rustc do the bundling. This has the extra advantage that rustc can bundle static libries built with CustomTarget. Disable bundling in all other cases, otherwise we could end up with duplicated objects in static libraries, in diamond dependency graph case. Fixes: #12484
2023-11-02rust: proc-macro should be ignored in transitive dependenciesXavier Claessens
Fixes: #12459
2023-11-02rust: Add unit test for transitive rust dependenciesSebastian Dröge
2023-10-20modules/rust: Add a test that bindgen drops arguments it shouldn't useDylan Baker
This does require hacking up the test pretty badly, since we need to not ever pass GCC these invalid values. But it's preferable to writing another project test I think. Co-Authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
2023-10-16modules/rust: remove rust_crate_type for test() methodDylan Baker
This is required to test non-executable targets when they set an explicit type.
2023-10-09interpreter: Add support for cargo subprojectXavier Claessens
2023-09-25rust: apply global, project, and environment C args to bindgenDylan Baker
This means that arguments set via `add_global_arguments`, `add_project_arguments` and by either the `-Dc_args` or `CFLAGS` are applied to bindgen as well. This can be important when, among other things, #defines are set via these mechanisms. Fixes: #12065
2023-09-19Rust: Prevent linking Rust ABI with C library/executableXavier Claessens
2023-09-19Rust: Replace rust_crate_type with rust_abiXavier Claessens
Meson already knows if it's a shared or static library, user only need to specify the ABI (Rust or C).
2023-09-19Rust: Add a rust.proc_macro() methodDylan Baker
2023-08-07Error when an installed static library links to internal custom targetXavier Claessens
When an installed static library A links to an internal static library B built using a custom_target(), raise an error instead of a warning. This is because to be usable, A needs to contain B which would require to extract the archive to get its objects files. This used to work, but was printing a warning and was installing a broken static library, because we used to overlink in many cases, and that got fixed in Meson 1.2.0. It now fails at link time with symbols from the custom target not being defined. It's better to turn the warning into a hard error at configure time. While at it, noticed this situation can happen for any internal custom or rust target we link to, recursively. get_internal_static_libraries_recurse() could be called on CustomTarget objects which do not implement it, and even if we did not call that method, it would still fail when trying to call extract_all_objects() on it. Fixes: #12006
2023-07-15rust: disable overflow-checks by defaultDylan Baker
These result in very large binaries when linked, and are not generally useful. A user can turn them back on by passing `-C overflow-checks=yes` manually via `-Drust_args` or the `RUSTFLAGS` environment variable fixes: #11785
2023-07-05Merge pull request #11742 from xclaesse/link-whole-casesJussi Pakkanen
Fix niche cases when linking static libs
2023-06-27rust: Override the default MSVCRT when linking Rust and !rust togetherDylan Baker
Rust by default links with the default MSVCRT, (dynamic, release). MSVCRT's cannot be mixed, so if Meson compiles a C or C++ library and links it with the debug MSVCRT, then tries to link that with the Rust library there will be failures. There is no built-in way to fix this for rustc, so as a workaround we inject the correct arguments early in the linker line (before any libs at least) to change the runtime. This seems to work and is recommended as workaround in the upstream rust bug report: https://github.com/rust-lang/rust/issues/39016. Given that this bug report has been opened since 2017, it seems unlikely to be fixed anytime soon, and affects all (currently) released versions of Rust.
2023-06-27rust: get stdlib arguments for non-rust languages when linkingDylan Baker
Otherwise we might not get things like libstdc++, which we need.
2023-06-27modules/rust: Add a keyword argument to pass extra args to the rust compilerDylan Baker
This may be necessary to, for example, stop rustc complaining about unused functions
2023-06-27modules/rust: Add a `link_with` kwarg to the test methodDylan Baker
This was requested by Mesa, where a bunch of `declare_dependency` objects are being created as a workaround for the lack of this keyword
2023-06-21rust: fix -C prefer-dynamic behaviorAlyssa Ross
I noticed when building a project that uses a proc macro that Meson passed -C prefer-dynamic for the executable, and not the proc macro, while cargo passed -C prefer-dynamic for the proc macro, but not for the executable. Meson's behavior broke setting -C panic=abort on the executable. As far as we can tell, because we explicitly pass each library path to rustc, the only thing -C prefer-dynamic affects in Meson is how the standard libraries are linked. Generally, one does not want the standard libraries to be dynamically linked, because if the Rust compiler is ever updated, anything linked against the old standard libraries will likely break, due to the lack of a stable Rust ABI. Therefore, I've reorganised Meson's behavior around the principle that the standard libraries should only be dynamically linked when Rust dynamic linking has already been opted into in some other way. The details of how this manifests are now explained in the documentation.
2023-05-20rust: Add system libs used by rust std to staticlib external depsXavier Claessens
2023-05-13Make `dependency('foo', static: true, method: 'cmake') link staticallyVolker Weißmann
Fixes #1709
2023-05-01Rust: C static library cannot link_whole Rust static libraryXavier Claessens
2023-04-21rust: Add new `rust_dependency_map` target configurationSebastian Dröge
This allows changing the crate name with which a library ends up being available inside the Rust code, similar to cargo's dependency renaming feature or `extern crate foo as bar` inside Rust code.
2023-04-21rust: add support for b_ndebugDylan Baker
Rust has a `debug_assert!()` macro, which is designed to be toggled on the command line. It is on by default in debug builds, and off by default in release builds, in cargo. This matches what meson's b_ndebug option does in `if-release` mode.
2023-04-14rust: Don't pass dependency compile arguments to the compilerSebastian Dröge
Rust doesn't have a concept of dependency compile arguments, i.e. something like headers. Dependencies are linked in and all required metadata is provided by the linker flags.
2023-04-11fix various spelling issuesJosh Soref
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-04propagate the most accurate node to error messagesEli Schwartz
During evaluation of codeblocks, we start off with an iteration of nodes, and then while evaluating them we may update the global self.current_node context. When catching and formatting errors, we didn't take into account that the node might be updated from the original top-level iteration. Switch to formatting errors using self.current_node instead, to ensure we can point at the likely most-accurate actual cause of an error. Also update the current node in a few more places, so that function calls always see the function call as the current node, even if the most recently parsed node was an argument to the function call. Fixes #11643
2023-03-28test cases: make various things werror-safeEli Schwartz
Allows getting closer to `./run_project_tests.py -- -Dwerror=true`. - when argc and argv are not *both* used, there's a standard, compliant mechanism to mark the variable as unused - generated code should not build as -Werror - more thoroughly comment out some commented code
2023-03-04typed_kwargs: Extend since_values and deprecated_values for typesXavier Claessens
2023-02-22Implement rustc controlled whole-archive linkingDylan Baker
Rustc as of version 1.61.0 has support for controlling when whole-archive linking takes place, previous to this it tried to make a good guess about what you wanted, which worked most of the time. This is now implemented. Additionally, rustc makes some assumptions about library names (specifically static names), that meson does not keep. This can be fixed with rustc 1.67, where a new +verbatim modifier has been added. We can then force rustc to use the name we give it. Before that, we can sneak through `/WHOELARCHIVE:` in cases of dynamic linking (into a dll or exe), but we can't force the archiver to do what we want (rustc considers the archiver to be an implementation detail). The only solution I can come up with is to copy the library to the format that rustc expects. I've run into some issues with that as well, so we warn in that case. The decisions to leave static into static broken on MSVC for 1.61–1.66 was made because: 1) The work around is non-trivial, and we would have to support that workaround for a long time 2) The number of users of Rust in Meson is small 3) The number of users of Rust in Meson on Windows, with MSVC is tiny 4) Using rustup to update rustc on windows is trivial, and solves the problem completely Fixes: #10723 Fixes: #11247 Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>