From 72bb22495f39b798e86c0de26cc945369b0ccdc7 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Fri, 8 Nov 2024 18:14:41 +0000
Subject: [PATCH] misc: improve clangd compile_flags.txt flags

This patch improves the compile_flags.txt config used to power clangd
for the rts C codebase. The flags in the file are sampled & deduped
from a real stage1 build with clang-19 and vastly improves the IDE
accuracy when hacking the rts.

For maximum code coverage under the default settings,
compile_flags.txt defaults to threaded+profiled+dynamic+debug way.
This does not mean profdyn needs to be actually built in _build/stage1
for IDE to work. To activate IDE for other RTS ways, simply remove one
of the -D flags at the end of compile_flags.txt and restart clangd.

(cherry picked from commit 59e0a77021e26c550fde39bf3b67a03dda497633)
(cherry picked from commit 222a08aec5da56862c176202dc5d5f2d20e7cae2)
(cherry picked from commit 039e2086454438e597f0e2eec11ec0c47de4f94f)
---
 compile_flags.txt | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/compile_flags.txt b/compile_flags.txt
index 2433bd243b6..21c4180e732 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -1,5 +1,29 @@
--xc
--Irts
+-Wimplicit
+-include
+rts/include/ghcversion.h
 -Irts/include
--I.hie-bios/stage0/lib
--I_build/stage1/rts/build/include/
+-I_build/stage1/rts/build
+-I_build/stage1/rts/build/include
+-Irts
+-Ilibraries/ghc-internal/include
+-I_build/stage1/libraries/ghc-internal/build/include
+-Ilibraries/ghc-bignum/include
+-I_build/stage1/libraries/ghc-bignum/build/include
+-Wno-unknown-pragmas
+-Wall
+-Wextra
+-Wstrict-prototypes
+-Wmissing-prototypes
+-Wmissing-declarations
+-Winline
+-Wpointer-arith
+-Wmissing-noreturn
+-Wnested-externs
+-Wredundant-decls
+-Wundef
+-DFS_NAMESPACE=rts
+-DCOMPILING_RTS
+-DTHREADED_RTS
+-DDEBUG
+-DDYNAMIC
+-DPROFILING
-- 
GitLab