Skip to content

Commit

Permalink
vault backup: 2025-02-17 00:57:55
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanamiiiii committed Feb 16, 2025
1 parent fde7713 commit 98076a4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
51 changes: 50 additions & 1 deletion blogs/Footprints/2025-02.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,58 @@ description: 2025-02の足跡
tags:
- Footprints
created: 2025-02-14T02:38:17+09:00
updated: 2025-02-14T02:54:45+09:00
updated: 2025-02-17T00:57:38+09:00
publish: true
---
# 2025-02-15
## Clangd with cross compile toolchain
職業柄よくC/C++クロスコンパイラを使うのだが,Language ServerのClangdを使うと適切な型エイリアス等が解決されず困っていた.
VSCodeのIntelli Senseのノリで,`compile_commands.json`にクロスコンパイラを渡してあげたら勝手にincludeディレクトリ等を解決してくれると思っていたのだが,そうではなかったらしい.

クロスコンパイラから適切なヘッダを読み込むには,`--query-driver`オプションを`clangd`の呼び出し時に与える必要があるとのこと.
[System headers](https://clangd.llvm.org/guides/system-headers#query-driver)

自分はNeoVimにMasonを導入してLSPを管理しているので,`mason-lspconfig`で設定する.
環境によってコンパイラのパスが違うので,上手いこと動的にフルパスを引っ張ってくるようにした(ロードが遅くなるのには目をつぶり…).

```lua
require("mason-lspconfig").setup_handlers({
...
["clangd"] = function()
-- Get cross compiler path for query driver
local cross_compilers = {
"riscv64-unknown-linux-gnu-gcc",
"riscv64-unknown-linux-gnu-g++",
}
local cross_compilers_path = {}
for _, val in ipairs(cross_compilers) do
local res = h.binary_path(val)
if res ~= nil then
table.insert(cross_compilers_path, res)
end
end

-- consruct clangd command args
local clangd_cmd = { "clangd" }
if next(cross_compilers_path) ~= nil then
local query_drivers = table.concat(cross_compilers_path, ",")
table.insert(clangd_cmd, "--query-driver=" .. query_drivers)
end

require("lspconfig").clangd.setup({
on_attach = on_attach,
capabilities = capabilities,
handlers = handlers,
cmd = clangd_cmd,
})
end,
})
```

ドキュメントによると`--query-driver`はあくまでAllow Listで,`compile_commands.json`内でマッチするコンパイラが指定されていた場合に発動するらしい.

ポインタサイズが正しくとれてなくて,キャストするたびに警告吐かれてたのが消えてスッキリした.

# 2025-02-14
## Wezterm on wayland with NVIDIAの描画遅延
それなりに前からだが,weztermをNVIDIA GPU下のwayland環境で使用すると,描画遅延がひどくて使い物にならないケースがあった.
Expand Down
2 changes: 1 addition & 1 deletion blogs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ description: 日々の戯れ言
# Recently Modified
| Note | Modified |
| ---------------------------------------------------------------------------------------------- | ------------------- |
| [[Footprints/2025-02.md\|2025-02]] | 2025/02/14 02:54:45 |
| [[Footprints/2025-02.md\|2025-02]] | 2025/02/17 00:57:38 |
| [[Footprints/2025-01.md\|2025-01]] | 2025/02/14 02:37:54 |
| [[Articles/systemd-resolvedを使わない場合のkubeletでのおまじない.md\|systemd-resolvedを使わない場合のkubeletでのおまじない]] | 2025/01/06 18:48:24 |
| [[Articles/yabaiとskhdでマウスから解放されよう.md\|yabaiとskhdでマウスから解放されよう]] | 2025/01/06 18:47:56 |
Expand Down

0 comments on commit 98076a4

Please sign in to comment.