Commit Graph

19 Commits

Author SHA1 Message Date
Fabian Boehm
7b7d16da48 Revert libc time_t changes
This was based on a misunderstanding.

On musl, 64-bit time_t on 32-bit architectures was introduced in version 1.2.0,
by introducing new symbols. The old symbols still exist, to allow programs compiled against older versions
to keep running on 1.2.0+, preserving ABI-compatibility. (see musl commit 38143339646a4ccce8afe298c34467767c899f51)

Programs compiled against 1.2.0+ will get the new symbols, and will therefore think time_t is 64-bit.

Unfortunately, rust's libc crate uses its own definition of these types, and does not check for musl version.
Currently, it includes the pre-1.2.0 32-bit type.

That means:

- If you run on a 32-bit system like i686
- ... and compile against a C-library other than libc
- ... and pass it a time_t-containing struct like timespec or stat

... you need to arrange for that library to be built against musl <1.2.0.

Or, as https://github.com/ericonr/rust-time64 says:

> Therefore, for "old" 32-bit targets (riscv32 is supposed to default to time64),
> any Rust code that interacts with C code built on musl after 1.2.0,
> using types based on time_t (arguably, the main ones are struct timespec and struct stat) in their interface,
> will be completely miscompiled.

However, while fish runs on i686 and compiles against pcre2, we do not pass pcre2 a time_t.
Our only uses of time_t are confined to interactions with libc, in which case with musl we would simply use the legacy ABI.

I have compiled an i686 fish against musl to confirm and can find no issue.

This reverts commit 55196ee2a0.
This reverts commit 4992f88966.
This reverts commit 46c8ba2c9f.
This reverts commit 3a9b4149da.
This reverts commit 5f9e9cbe74.
This reverts commit 338579b78c.
This reverts commit d19e5508d7.
This reverts commit b64045dc18.

Closes #10634
2024-08-27 14:28:00 +02:00
Johannes Altmanninger
5f9e9cbe74 Replace clock_gettime/futimens with 64-bit wrappers
Part of #10634
2024-08-07 13:11:22 +02:00
Johannes Altmanninger
55196ee2a0 Replace pselect with a 64-bit-time_t wrapper
Part of #10634
2024-08-07 13:11:22 +02:00
Johannes Altmanninger
4992f88966 Replace getrusage with a 64-bit-time_t wrapper
Part of #10634
2024-08-07 13:11:22 +02:00
Johannes Altmanninger
46c8ba2c9f Replace select with a 64-bit-time_t wrapper
Part of #10634
2024-08-07 13:11:22 +02:00
Johannes Altmanninger
3a9b4149da Replace localtime_r with a 64-bit-time_t wrapper
Part of #10634
2024-08-07 13:11:22 +02:00
Johannes Altmanninger
70357c4f6e Add back .clang-format 2024-08-07 13:11:22 +02:00
Johannes Altmanninger
338579b78c Rename fstatat/readdir wrapper to match Linux equivalents 2024-08-07 13:11:22 +02:00
Johannes Altmanninger
d19e5508d7 Remove non-portable use of fstatat
Part of #10634
2024-08-06 14:16:01 +02:00
Johannes Altmanninger
b64045dc18 Remove non-portable use of ino_t
Part of #10634
2024-08-06 14:15:03 +02:00
Fabian Boehm
fc794bab4c Switch to the terminfo crate
This allows us to get the terminfo information without linking against curses.

That means we can get by without a bunch of awkward C-API trickery.

There is no global "cur_term" kept by a library for us that we need to invalidate.

Note that it still requires a "unhashed terminfo database", and I don't know how well it handles termcap.

I am not actually sure if there are systems that *can't* have terminfo, everything I looked at
has the ncurses terminfo available to install at least.
2024-02-22 20:10:16 +01:00
Fabian Boehm
67a3aaa66a Remove uses of LC_GLOBAL_LOCALE
We only use this

1. if we have localeconv_l
2. to get the decimal point / thousands separator for numbers

So we can ignore all this and directly create a purely LC_NUMERIC locale.

This *was* more useful when we were in C++ and the printing functions
all relied on locale, but we only use this in printf and that only
extracts the number stuff.
2024-02-01 22:15:24 +01:00
Mahmoud Al-Qudsi
c53a494f52 libc.c: Include xlocale.h under macOS 2024-02-01 13:45:11 -06:00
Mahmoud Al-Qudsi
5169302303 Make LC_GLOBAL_LOCALE shim less brittle
Make sure the function is defined on all platforms, and don't split conditional
compilation logic between C and rust.
2024-02-01 13:16:32 -06:00
Fabian Boehm
6877773fdd
Fix build on NetBSD (#10270)
* Fix build on NetBSD

Notably:

1. A typo in `f_flag` vs `f_flags` - this was probably never tested
2. Some pointless name differences  - `st_mtimensec` vs
`st_mtime_nsec`
3. The big one: This said that LC_GLOBAL_LOCALE() was -1 "everywhere".
   Well, not on NetBSD.

* ifdef for macos
2024-01-28 21:45:14 +01:00
Fabian Boehm
6be6890fa3 Remove config.h
We don't actually use anything in there anymore.

We keep the WCHAR_T_BITS define in cmake because that's
used to find pcre2.
2024-01-20 08:56:29 +01:00
ridiculousfish
9747ab19d1 Eliminate UVAR_FILE_SET_MTIME_HACK checks
This was previously limited to Linux predicated on the existence
of certain headers, but Rust just exposes those functions unconditionally. So
remove the check and just perform the mtime hack on Linux and Android.
2024-01-19 09:33:33 -08:00
ridiculousfish
70ed4806b4 Use libc O_EXLOCK instead of our own
Rust libc supports O_EXLOCK on supported platforms (BSD/macOS), use that instead
of re-exposing it.
2024-01-19 09:33:33 -08:00
Johannes Altmanninger
3ae20bdba0 Move fish-rust to project root 2024-01-13 03:58:33 +01:00