Issue with `gettid` in macOS
### Setup
- MacOS Sequoia 15.3
- NVIM v0.10.4
- Build type: Release
- LuaJIT 2.1.1736781742
### Summary
When I start neovim with `NVIM_PROFILE=1`, there's a long trace with basically this piece of information:
```
Error executing lua callback: ....local/share/nvim/lazy/profile.nvim/lua/profile/util.lua:33: dlsym(RTLD_DEFAULT, gettid): symbol not found
```
Here we can see the failing call.
https://github.com/stevearc/profile.nvim/blob/f2d2cf5eae9ba3b9ca6bc148507d153f3e6ae282/lua/profile/util.lua#L33
### Workaround
In case there's someone else with the same problem reading this, I was able to fix this by creating a `gettid.c` file with the following contents:
```c
#include <sys/types.h>
#include <pthread.h>
#include <stdint.h>
pid_t gettid(void) {
uint64_t tid;
pthread_threadid_np(NULL, &tid);
return (pid_t)tid;
}
```
Compiling it with
```bash
gcc -shared -fPIC gettid.c -o libgettid.so
```
And using it like:
```bash
DYLD_INSERT_LIBRARIES=$PWD/libgettid.so NVIM_PROFILE=1 nvim
```
This is not a permanent solution, that's why I haven't submitted a PR for this issue. I've been trying different solutions in `util.lua` using `vim.loop.getpid()` and `pthread_self`, but I haven't found a definitive solution so far.
关闭于 2025-02-14 1 条评论