Commit Graph

26 Commits

Author SHA1 Message Date
David Adam
2bc197fe74 cmake: add -g to existing RUSTFLAGS if required
Makes it possible to use the sanitizers again.

Note that this requires RUSTFLAGS to be set when running CMake, and will not be
updated when running the build system if the environment variable changes.
2024-02-08 00:28:30 +08:00
David Adam
cb46396b67 cmake: build executables by driving cargo directly
Drops the requirement for Corrosion, as almost none of its extensive features
are required.
2024-01-30 18:18:55 +08:00
David Adam
db9bb96910 Drop CMake PCRE2 download/linking and allow statically-linked PCRE2 crate
pcre2-sys includes a vendored copy of PCRE2, which allows for
statically-linked PCRE2. Hook this up to the CMake build variable, and
remove the C++ integration for PCRE2.
2024-01-13 20:43:12 +08:00
David Adam
1683e720a8 Use Rust for executables
Use Rust for executables

Drops the C++ entry points and restructures the Rust package into a
library and three binary crates.

Renames the fish-rust package to fish.

At least on Ubuntu, "fish_indent" is built before "fish".
Make sure export CURSES_LIBRARY_LIST to all binaries to make sure
that "cached-curses-libnames" is populated.

Closes #10198
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
2d493621f4 test_cargo-test: use Corrosion target dir
This makes "ninja test" write only to the build directory, not to the source
tree. This enables our docker script which mounts the source as read-only.
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
7686c39d76 test_cargo-test: inherit same variables as Corrosion build targets
In particular, pass the build directory, which is required in some test
scenarios (see next commit).
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
29bd6eebd0 Remove cxx and autocxx
Notably this gets rid of the Cargo target directory inside build directories,
in favor of "target/" at workspace root.
2024-01-07 22:19:56 +01:00
Johannes Altmanninger
77550a2f0d Turn FFI tests into native Rust tests
Keep running tests serially to avoid breaking assumptions.

I think many of these tests can run in parallel and/or don't need test_init().
Use the safe variant everywhere, to get it done faster.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
b2d4619125 Link against curses in build.rs too
This will allow to use "cargo test" for unit tests that depend on our
curses.rs.

This means that Rust.cmake depends on ConfigureChecks, so move that one to
the front.
2024-01-07 12:12:09 +01:00
Johannes Altmanninger
3e3441429a Port wgettext wrapper from wutil.cpp
This introduces a string allocations on lookups of strings that are not
known at compile time; we should get rid of these allocations in future.
2024-01-07 12:12:09 +01:00
Fabian Boehm
35baa88334 cmake: Canonicalize binary dir
This would otherwise fail to set $fish_function_path to
share/functions etc if run through a symlink.
2023-09-28 17:34:10 +02:00
Fabian Boehm
d6a6d77429 cmake: Fix SYSCONFDIR and friends 2023-09-06 09:49:24 +02:00
Henrik Hørlück Berg
e4df340f43 Forward CMake configs to Cargo 2023-09-05 11:38:59 +02:00
Henrik Hørlück Berg
5db08e1126 Make CARGO_MANIFEST_DIR for fish-rust equal to src 2023-09-05 11:38:59 +02:00
Henrik Hørlück Berg
c23f419af1 Use the workspace from CMake
- Make CMake use the correct target-path
- Make build.rs use the correct target dir

Workspaces place it in the project root by default, the alternative to making
this change is to add a `.cargo/config.toml` file with

```toml
[build]
target-dir = "fish-rust/target"
```

Which I think is unnecessary, as we likely want to use the new location anyways.
2023-08-19 15:18:38 +02:00
Henrik Hørlück Berg
55b6d7cd74 Revert "Fix built for newer than linked macOS warning"
This reverts commit 69ed2d1ca7. It was never meant
to be merged.
2023-08-02 22:42:52 +08:00
Henrik Hørlück Berg
69ed2d1ca7 Fix built for newer than linked macOS warning 2023-07-04 13:27:53 -07:00
Mahmoud Al-Qudsi
b17124d8d2 Add rsconf build system and check for gettext symbols
This is more complicated than it needs to be thanks to the presence of CMake and
the C++ ffi in the picture. rsconf can correctly detect the required libraries
and instruct rustc to link against them, but since we generate a static rust
library and have CMake link it against the C++ binaries, we are still at the
mercy of CMake picking up the symbols we want.

Unfortunately, we could detect the gettext symbols but discover at runtime that
they weren't linked in because CMake was compiled with `-DWITH_GETTEXT=0` or
similar (as the macOS CI runner does). This means we also need to pass state
between CMake and our build script to communicate which CMake options were
enabled.
2023-05-25 16:54:03 -05:00
Mahmoud Al-Qudsi
3651e0e9d8 Actually report ASAN memory leaks
The new asan exit handlers are called to get proper ASAN leak reports (as
calling _exit(0) skips the LSAN reporting stage and exits with success every
time).

They are no-ops when not compiled for ASAN.
2023-05-02 11:52:41 -05:00
Johannes Altmanninger
ec176dc07e Port path.h 2023-04-21 13:57:29 +02:00
Johannes Altmanninger
454009d13e Rust.cmake: break up long line 2023-04-21 13:57:29 +02:00
David Adam
1c978f7ec5 cmake: add support for vendored cmake
Use a "cmake-vendored" directory if it exists, to avoid accessing the
network if it's available, and a target to create an appropriate tarball
to create that directory.
2023-03-30 12:01:25 +08:00
Mahmoud Al-Qudsi
1bdb7dffaf Use cargo build -Z build-std for ASAN
This is recommended and increases coverage.
2023-03-08 11:27:15 -06:00
Mahmoud Al-Qudsi
91cf526d23
Enable rust address sanitizer for asan ci job (#9643)
Rust has multiple sanitizers available (with llvm integration).
-Zsanitizer=address catches the most likely culprits but we may want to set up a
separate job w/ -Zsanitizer=memory to catch uninitialized reads.

It might be necessary to execute `cargo build` as `cargo build -Zbuild-std` to
get full coverage.

When we're linking against the hybrid C++ codebase, the sanitizer library is
injected into the binary by also include `-fsanitize=address` in CXXFLAGS - we
do *not* want to manually opt-into `-lasan`. We also need to manually specify
the desired target triple as a CMake variable and then explicitly pass it to all
`cargo` invocations if building with ASAN.

Corrosion has been patched to make sure it follows these rules.

The `cargo-test` target is failing to link under ASAN. For some reason it has
autocxx/ffi dependencies even though only rust-native, ffi-free code should be
tested (and one would think the situation wouldn't change depending on the
presence of the sanitizer flag). It's been disabled under ASAN for now.
2023-03-06 18:15:36 -06:00
ridiculousfish
681a165721 Add an FFI test facility
This allow testing Rust functions (from fish_tests.cpp) which need to
cross the FFI. See the example in smoke.rs.
2023-02-02 19:34:48 -07:00
ridiculousfish
d843b67d2d Initial Rust commit 2023-02-02 19:34:47 -07:00