mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-19 05:13:44 +08:00
7b7d16da48
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 commit55196ee2a0
. This reverts commit4992f88966
. This reverts commit46c8ba2c9f
. This reverts commit3a9b4149da
. This reverts commit5f9e9cbe74
. This reverts commit338579b78c
. This reverts commitd19e5508d7
. This reverts commitb64045dc18
. Closes #10634
183 lines
2.8 KiB
C
183 lines
2.8 KiB
C
#include <locale.h>
|
|
#include <paths.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/resource.h>
|
|
#include <unistd.h>
|
|
|
|
#define UNUSED(x) (void)(x)
|
|
|
|
size_t C_MB_CUR_MAX() { return MB_CUR_MAX; }
|
|
|
|
uint64_t C_ST_LOCAL() {
|
|
#if defined(ST_LOCAL)
|
|
return ST_LOCAL;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
// confstr + _CS_PATH is only available on macOS with rust's libc
|
|
// we could just declare extern "C" confstr directly in Rust
|
|
// that would panic if it failed to link, which C++ did not
|
|
// therefore we define a backup, which just returns an error
|
|
// which for confstr is 0
|
|
#if defined(_CS_PATH)
|
|
#else
|
|
size_t confstr(int name, char* buf, size_t size) {
|
|
UNUSED(name);
|
|
UNUSED(buf);
|
|
UNUSED(size);
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
int C_CS_PATH() {
|
|
#if defined(_CS_PATH)
|
|
return _CS_PATH;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
uint64_t C_MNT_LOCAL() {
|
|
#if defined(MNT_LOCAL)
|
|
return MNT_LOCAL;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
const char* C_PATH_BSHELL() { return _PATH_BSHELL; }
|
|
|
|
int C_PC_CASE_SENSITIVE() {
|
|
#ifdef _PC_CASE_SENSITIVE
|
|
return _PC_CASE_SENSITIVE;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
FILE* stdout_stream() { return stdout; }
|
|
|
|
int C_RLIMIT_CORE() { return RLIMIT_CORE; }
|
|
int C_RLIMIT_DATA() { return RLIMIT_DATA; }
|
|
int C_RLIMIT_FSIZE() { return RLIMIT_FSIZE; }
|
|
int C_RLIMIT_NOFILE() { return RLIMIT_NOFILE; }
|
|
int C_RLIMIT_STACK() { return RLIMIT_STACK; }
|
|
int C_RLIMIT_CPU() { return RLIMIT_CPU; }
|
|
|
|
int C_RLIMIT_SBSIZE() {
|
|
#ifdef RLIMIT_SBSIZE
|
|
return RLIMIT_SBSIZE;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_NICE() {
|
|
#ifdef RLIMIT_NICE
|
|
return RLIMIT_NICE;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_SIGPENDING() {
|
|
#ifdef RLIMIT_SIGPENDING
|
|
return RLIMIT_SIGPENDING;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_MEMLOCK() {
|
|
#ifdef RLIMIT_MEMLOCK
|
|
return RLIMIT_MEMLOCK;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_RSS() {
|
|
#ifdef RLIMIT_RSS
|
|
return RLIMIT_RSS;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_MSGQUEUE() {
|
|
#ifdef RLIMIT_MSGQUEUE
|
|
return RLIMIT_MSGQUEUE;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_RTPRIO() {
|
|
#ifdef RLIMIT_RTPRIO
|
|
return RLIMIT_RTPRIO;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_NPROC() {
|
|
#ifdef RLIMIT_NPROC
|
|
return RLIMIT_NPROC;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_AS() {
|
|
#ifdef RLIMIT_AS
|
|
return RLIMIT_AS;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_SWAP() {
|
|
#ifdef RLIMIT_SWAP
|
|
return RLIMIT_SWAP;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_RTTIME() {
|
|
#ifdef RLIMIT_RTTIME
|
|
return RLIMIT_RTTIME;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_KQUEUES() {
|
|
#ifdef RLIMIT_KQUEUES
|
|
return RLIMIT_KQUEUES;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_NPTS() {
|
|
#ifdef RLIMIT_NPTS
|
|
return RLIMIT_NPTS;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|
|
|
|
int C_RLIMIT_NTHR() {
|
|
#ifdef RLIMIT_NTHR
|
|
return RLIMIT_NTHR;
|
|
#else
|
|
return -1;
|
|
#endif
|
|
}
|