blob: ebb4f7e5b7c2a29ab22903a0a9c98b9ecc55324a [file] [log] [blame]
developerc1ecc212023-11-03 09:27:38 +08001--- a/include/kernel.mk
2+++ b/include/kernel.mk
3@@ -98,7 +98,13 @@ else
4 LINUX_KARCH := $(ARCH)
5 endif
6
7-KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
8+KERNEL_VARS = \
9+ LD_PRELOAD="$(STAGING_DIR_HOST)/lib/ldlogger.so" \
10+ CC_LOGGER_GCC_LIKE="gcc:g++:clang:clang++:cc:c++" \
11+ CC_LOGGER_FILE="$(LINUX_DIR)/compile_commands.json" \
12+ CC_LOGGER_KEEP_LINK=true
13+
14+KERNEL_MAKE = $(KERNEL_VARS) $(MAKE) $(KERNEL_MAKEOPTS)
15
16 KERNEL_MAKE_FLAGS = \
17 KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) $(call qstrip,$(CONFIG_KERNEL_CFLAGS))" \
18--- a/include/package-defaults.mk
19+++ b/include/package-defaults.mk
developera557a002023-11-07 09:40:16 +080020@@ -128,6 +128,12 @@ MAKE_VARS = \
developerc1ecc212023-11-03 09:27:38 +080021 CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
developera557a002023-11-07 09:40:16 +080022 LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
23
24+BUILD_LOGGER_VARS = \
developerc1ecc212023-11-03 09:27:38 +080025+ LD_PRELOAD="$(STAGING_DIR_HOST)/lib/ldlogger.so" \
26+ CC_LOGGER_GCC_LIKE="gcc:g++:clang:clang++:cc:c++" \
27+ CC_LOGGER_FILE="$(PKG_BUILD_DIR)/compile_commands.json" \
28+ CC_LOGGER_KEEP_LINK=true
developera557a002023-11-07 09:40:16 +080029+
developerc1ecc212023-11-03 09:27:38 +080030 MAKE_FLAGS = \
31 $(TARGET_CONFIGURE_OPTS) \
developera557a002023-11-07 09:40:16 +080032 CROSS="$(TARGET_CROSS)" \
33@@ -140,12 +146,25 @@ MAKE_INSTALL_FLAGS = \
34 MAKE_PATH ?= .
35
36 define Build/Compile/Default
37- +$(MAKE_VARS) \
38+ +$(MAKE_VARS) $(BUILD_LOGGER_VARS) \
39 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
40 $(MAKE_FLAGS) \
41 $(1);
42 endef
43
44+GCC_LIB_INC := $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/$(shell $(TARGET_CC) -dumpmachine)/$(shell $(TARGET_CC) --version | head -1 | rev | cut -d ' ' -f 1 | rev)/include)
45+ifneq ($(GCC_LIB_INC),)
46+define Build/WriteClangdConfig/GccLibInc
47+ echo " Add: -I$(GCC_LIB_INC)" >> $(PKG_BUILD_DIR)/.clangd
48+endef
49+endif
50+
51+define Build/WriteClangdConfig
52+ echo "CompileFlags:" > $(PKG_BUILD_DIR)/.clangd
53+ $(Build/WriteClangdConfig/GccLibInc)
54+ echo " Remove: -mabi=*" >> $(PKG_BUILD_DIR)/.clangd
55+endef
56+
57 define Build/Install/Default
58 $(MAKE_VARS) \
59 $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
60--- a/include/package.mk
61+++ b/include/package.mk
62@@ -216,6 +216,7 @@ define Build/CoreTargets
63 $(foreach hook,$(Hooks/Compile/Pre),$(call $(hook))$(sep))
64 $(Build/Compile)
65 $(foreach hook,$(Hooks/Compile/Post),$(call $(hook))$(sep))
66+ $(Build/WriteClangdConfig)
67 $(Build/Install)
68 $(foreach hook,$(Hooks/Install/Post),$(call $(hook))$(sep))
69 touch $$@