blob: ebb4f7e5b7c2a29ab22903a0a9c98b9ecc55324a [file] [log] [blame]
--- a/include/kernel.mk
+++ b/include/kernel.mk
@@ -98,7 +98,13 @@ else
LINUX_KARCH := $(ARCH)
endif
-KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS)
+KERNEL_VARS = \
+ LD_PRELOAD="$(STAGING_DIR_HOST)/lib/ldlogger.so" \
+ CC_LOGGER_GCC_LIKE="gcc:g++:clang:clang++:cc:c++" \
+ CC_LOGGER_FILE="$(LINUX_DIR)/compile_commands.json" \
+ CC_LOGGER_KEEP_LINK=true
+
+KERNEL_MAKE = $(KERNEL_VARS) $(MAKE) $(KERNEL_MAKEOPTS)
KERNEL_MAKE_FLAGS = \
KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) $(call qstrip,$(CONFIG_KERNEL_CFLAGS))" \
--- a/include/package-defaults.mk
+++ b/include/package-defaults.mk
@@ -128,6 +128,12 @@ MAKE_VARS = \
CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
+BUILD_LOGGER_VARS = \
+ LD_PRELOAD="$(STAGING_DIR_HOST)/lib/ldlogger.so" \
+ CC_LOGGER_GCC_LIKE="gcc:g++:clang:clang++:cc:c++" \
+ CC_LOGGER_FILE="$(PKG_BUILD_DIR)/compile_commands.json" \
+ CC_LOGGER_KEEP_LINK=true
+
MAKE_FLAGS = \
$(TARGET_CONFIGURE_OPTS) \
CROSS="$(TARGET_CROSS)" \
@@ -140,12 +146,25 @@ MAKE_INSTALL_FLAGS = \
MAKE_PATH ?= .
define Build/Compile/Default
- +$(MAKE_VARS) \
+ +$(MAKE_VARS) $(BUILD_LOGGER_VARS) \
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
$(MAKE_FLAGS) \
$(1);
endef
+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)
+ifneq ($(GCC_LIB_INC),)
+define Build/WriteClangdConfig/GccLibInc
+ echo " Add: -I$(GCC_LIB_INC)" >> $(PKG_BUILD_DIR)/.clangd
+endef
+endif
+
+define Build/WriteClangdConfig
+ echo "CompileFlags:" > $(PKG_BUILD_DIR)/.clangd
+ $(Build/WriteClangdConfig/GccLibInc)
+ echo " Remove: -mabi=*" >> $(PKG_BUILD_DIR)/.clangd
+endef
+
define Build/Install/Default
$(MAKE_VARS) \
$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
--- a/include/package.mk
+++ b/include/package.mk
@@ -216,6 +216,7 @@ define Build/CoreTargets
$(foreach hook,$(Hooks/Compile/Pre),$(call $(hook))$(sep))
$(Build/Compile)
$(foreach hook,$(Hooks/Compile/Post),$(call $(hook))$(sep))
+ $(Build/WriteClangdConfig)
$(Build/Install)
$(foreach hook,$(Hooks/Install/Post),$(call $(hook))$(sep))
touch $$@