Commit graph

18265 commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
33f33c5f41 Simplify (and fix?) build.rs HAVE_XXX detection
Since none of the compiles(xxx) calls are to particularly complex code, we can
just use `rsconf` directly to test for the presence of the symbols or headers as
needed.

Note that it seems at least some of the previous detection was not working
correctly; in particular HAVE_PIPE2 was evaluating to false on my WSL install
where pipe2(2) was available (caught because it revealed some compilation errors
in that conditional compilation path after porting).

I kept the cfg names and the tests themselves mostly as-is, though we might want
to change that to conform with the rust convention of lowercase cfg names and
decide whether we want to prefix all these with have_, fish_, or nothing at all.
Also the posix_spawn() test should probably check for the symbol `posix_spawn()`
rather than the header `spawn.h` since we don't use it via the header but rather
via the symbol (but in reality they're almost certainly going to give the same
result).
2024-01-13 15:45:42 -06:00
Mahmoud Al-Qudsi
e02c572738 Fix build error when HAVE_PIPE2 is true
NB: I only encountered this when rewriting the cfg detection, which means that
the previous detection wasn't correct since I have pipe2 on Linux but didn't run
into this build error before.
2024-01-13 15:44:03 -06:00
Mahmoud Al-Qudsi
6e002b6d80 Use cfg directly instead of going through features
Features should be for user-specifiable build configurations but our dynamic,
target-based conditional compilation is something else.
2024-01-13 15:16:47 -06:00
Mahmoud Al-Qudsi
4f8265db47 Inline the localconv_l test
It's just one line.
2024-01-13 14:58:58 -06:00
ridiculousfish
8554eb5f80 Further cleanup of FdMonitor 2024-01-13 12:51:36 -08:00
ridiculousfish
d8da79717e Remove some FFI bits from FdMonitor 2024-01-13 12:51:36 -08:00
Mahmoud Al-Qudsi
30f70f02de Feature-detect localeconv_l() presence 2024-01-13 14:21:14 -06:00
Mahmoud Al-Qudsi
195852b562 Use locale::LOCALE_LOCK for all setlocale() calls
I had originally created a safe `set_locale()` wrapper and clippy-disallowed
`libc::setlocale()` but almost all our uses of `libc::setlocale()` are in a loop
where it makes much more sense to just obtain the lock outright then call
`setlocale()` repeatedly rather than lock it in the wrapper function each time.
2024-01-13 13:50:31 -06:00
Mahmoud Al-Qudsi
a138d74688 Fix unused code warning on cannot-be-WSL platforms
No need to use cfg_attr and have to worry about syncing the preconditions for
the cfg_attr with the preconditions for where `slice_contains_slice()` is used
in the codebase, just mark it as `allow(unused)` with a comment.
2024-01-13 13:15:31 -06:00
David Adam
a533d836dd bump minimum CMake version 2024-01-13 22:55:13 +08:00
David Adam
f65ed782e8 Drop unused CMake module CheckIncludeFiles
This was only needed for certain configure checks, now elided, and for
CMake < 3.11.
2024-01-13 22:55:13 +08:00
David Adam
c9712aeda2 Drop additional unused CMake directives 2024-01-13 22:55:12 +08:00
David Adam
d418cce493 correct workflow name for static PCRE2 2024-01-13 21:23:37 +08:00
David Adam
e59d164658 Drop unused configure checks
All of these checks are handled in external crates now.
2024-01-13 21:15:24 +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
Fabian Boehm
0a92d03498 Remove L! from sprintf calls
Remove unnecessary L!
2024-01-13 08:52:54 +01:00
Fabian Boehm
1da9af781c Delete widestring-suffix 2024-01-13 08:52:54 +01:00
Fabian Boehm
507d634cfa Remove widestring-suffix from Cargo 2024-01-13 08:52:54 +01:00
Fabian Boehm
fae780d666 clippy
There are a bunch more now that widestrs is gone
2024-01-13 08:52:54 +01:00
Fabian Boehm
09cd7c7ad9 Remove widestring-suffix uses
This removes both the `#[widestrs]` annotation as well as all `"foo"L`
suffixes, and does a `cargo fmt` run on the result
2024-01-13 08:52:54 +01:00
David Adam
ca972f6e0f fix permissions on source file 2024-01-13 11:12:02 +08:00
David Adam
5e8a7fb862 Drop unused C++ fishlib 2024-01-13 11:12:02 +08:00
Johannes Altmanninger
3ae20bdba0 Move fish-rust to project root 2024-01-13 03:58:33 +01:00
Johannes Altmanninger
22873cacf4 Enable tests that were accidentally disabled 2024-01-13 03:58:33 +01:00
Johannes Altmanninger
a707cd09c4 Enable clippy::unnecessary_unwrap lint 2024-01-13 03:58:33 +01:00
Johannes Altmanninger
fd7f76c180 Enable clippy::unnecessary_to_owned lint
Meh
2024-01-13 03:58:33 +01:00
Johannes Altmanninger
65064ac976 Remove dead code, enable dead_code lint 2024-01-13 03:58:33 +01:00
Johannes Altmanninger
5512f44899 Enable doctests
They are probably not terribly useful for us but let's see what happens.

Unfortunately cargo does not properly forward the combination of "RUSTFLAGS"
and "--target" that is currently required to build with ASan [1].  Hence doctests
will fail to link on ASan builds. Let's disable doctests when ASan is active.

[1]: https://github.com/rust-lang/cargo/issues/10666 et al
2024-01-13 03:58:33 +01:00
Johannes Altmanninger
07e3459fb0 Address clippy lints on 1.67.0 2024-01-13 03:07:29 +01:00
Johannes Altmanninger
4bae1f3de9 Address clippy lints on stable Rust 2024-01-13 03:07:29 +01:00
Johannes Altmanninger
6896898769 Add [lints] table to suppress lints across all our crates
This was stabilized in 1.74.  Until that's our MSRV, keep the warnings also in
"lib.rs", to prevent warning spew on old builds (CI logs etc.).
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
36b7723a93 Remove stale lint suppression
Feature fish-ffi-tests is no more so we don't need this warning.
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
d6c96a0a68 Fix some minor warnings 2024-01-13 03:07:29 +01:00
Johannes Altmanninger
793fb8f8f6 Minor cleanup in fish.rs
For now we always define FISH_BUILD_DIR though we could reconsider.
2024-01-13 03:07:29 +01:00
David Adam
d6cb049aff fish.rs: use some bare returns 2024-01-13 03:07:29 +01: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
David Adam
4a2edbf97e Disable doc tests temporarily
None of the existing code blocks compile, so disable them running as tests
for now.
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
5a570f187a Remove obsolete LSAN workaround 2024-01-13 03:07:29 +01:00
Johannes Altmanninger
26d359b071 Ubuntu ASAN Dockerfile 2024-01-13 03:07:29 +01:00
Johannes Altmanninger
e89a4f6cb4 Suppress _nc_doalloc memory leak
With the next commit, if I run

    docker/docker_run_tests.sh --shell-after docker/jammy-asan-clang.Dockerfile

I get this in test_string.fish and test_git.fish:

    =================================================================
    ==8339==ERROR: LeakSanitizer: detected memory leaks
    Direct leak of 72 byte(s) in 1 object(s) allocated from:
        #0 0x55a8a637eb45 in realloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:85:3
        #1 0x7facb841b6cc in _nc_doalloc (/lib/x86_64-linux-gnu/libtinfo.so.6+0x106cc) (BuildId: e22ba7829a55a0dec2201a0b6dac7ba236118561)
    SUMMARY: AddressSanitizer: 72 byte(s) leaked in 1 allocation(s).

Strangely there is no tparm in the call stack.  It does not seem to happen
in CI.
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
2871f5070f CMake: re-enable cargo-test under ASAN
With autocxx/cxx gone, this seems to work fine now.
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
e98a794d1c Fix memory leak in inotify tests 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
6c2271a6da cargo test: change directory to the build directory again
Some tests create files like "./test/test-home".  Traditionally the did so
in the first parent directory that contained tests/test.fish; so either a
build directory or the root.

The new rust version always changes directory to the root.  This blows up
when running with our docker/ files, which mount the source as read-only.

Fix this by always changing directory to the build directory.

In future we could extend this to not chdir if FISH_BUILD_DIR was not
specified, to match traditional behavior. No strong opinions here.
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
a20525c44f build.rs: deduplicate the build-dir heuristic 2024-01-13 03:07:29 +01:00
Johannes Altmanninger
67de32fe2d Enable pexpect tests in ASAN CI again 2024-01-13 03:07:29 +01:00
Johannes Altmanninger
6ab74c6b09 Human-readable ASAN stack traces CI
Show file names, line numbers and function names in ASAN stack traces
(instead of object file + raw memory address).
2024-01-13 03:07:29 +01:00
Johannes Altmanninger
537e3cb9e1 CI: remove UBSAN_OPTIONS
Rust does not support  UBSan today.
2024-01-13 03:07:29 +01:00
Peter Collingbourne
0b3e9609f1 completions/fastboot: declare -s as taking an argument, add argument completions 2024-01-12 20:45:56 +01:00