diff --git a/Makefile b/Makefile index 05f04cf..e2ffd60 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,8 @@ all: $(TARGETs) demo test: so bpf: $(if $(filter 1,$(USE_SUBMODULE)),bpf.gitsubmodule) -observe filter policy so: bpf +observe filter policy: bpf tools +so: observe filter policy $(TARGETs): $(MAKE) -C $@ diff --git a/filter/Makefile b/filter/Makefile index fef525b..576d658 100644 --- a/filter/Makefile +++ b/filter/Makefile @@ -69,9 +69,8 @@ $(BPF_PREPROCESS): $(BUILD_DIR)/%.skel.h: $(BPF_DIR)/%.bpf.o $(BPF_PREPROCESS) | $(BUILD_DIR) $(BPF_PREPROCESS) $< $(BUILD_DIR)/$*.bpf.o - bpftool gen skeleton $(BUILD_DIR)/$*.bpf.o > $(dir $@).tmp.$$$$.$(notdir $@) && \ - python3 $(PROJ_ROOT)/script/patch_skel.py --obj-dir $(BUILD_DIR) $(dir $@).tmp.$$$$.$(notdir $@) && \ - mv $(dir $@).tmp.$$$$.$(notdir $@) $@ + bpftool gen skeleton $(BUILD_DIR)/$*.bpf.o > $@ + python3 $(PROJ_ROOT)/script/patch_skel.py --obj-dir $(BUILD_DIR) $@ $(BUILD_DIR)/log.o: $(PROJ_ROOT)/so/log.cpp | $(BUILD_DIR) $(CXX) $(CXXFLAGS) -c $< -o $@ diff --git a/observe/Makefile b/observe/Makefile index a4de5ac..7a50516 100644 --- a/observe/Makefile +++ b/observe/Makefile @@ -78,9 +78,8 @@ $(BPF_PREPROCESS): $(BUILD_DIR)/%.skel.h: $(BPF_DIR)/%.bpf.o $(BPF_PREPROCESS) | $(BUILD_DIR) $(BPF_PREPROCESS) $< $(BUILD_DIR)/$*.bpf.o - bpftool gen skeleton $(BUILD_DIR)/$*.bpf.o > $(dir $@).tmp.$$$$.$(notdir $@) && \ - python3 $(PROJ_ROOT)/script/patch_skel.py --obj-dir $(BUILD_DIR) $(dir $@).tmp.$$$$.$(notdir $@) && \ - mv $(dir $@).tmp.$$$$.$(notdir $@) $@ + bpftool gen skeleton $(BUILD_DIR)/$*.bpf.o > $@ + python3 $(PROJ_ROOT)/script/patch_skel.py --obj-dir $(BUILD_DIR) $@ clean: rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/*.d $(TARGETs) $(BUILD_DIR)/.tmp.*.skel.h diff --git a/policy/Makefile b/policy/Makefile index 1f19cd3..cc31cd8 100644 --- a/policy/Makefile +++ b/policy/Makefile @@ -56,9 +56,8 @@ $(BPF_PREPROCESS): $(BUILD_DIR)/%.skel.h: $(BPF_DIR)/%.bpf.o $(BPF_PREPROCESS) | $(BUILD_DIR) $(BPF_PREPROCESS) $< $(BUILD_DIR)/$*.bpf.o - bpftool gen skeleton $(BUILD_DIR)/$*.bpf.o > $(dir $@).tmp.$$$$.$(notdir $@) && \ - python3 $(PROJ_ROOT)/script/patch_skel.py --obj-dir $(BUILD_DIR) $(dir $@).tmp.$$$$.$(notdir $@) && \ - mv $(dir $@).tmp.$$$$.$(notdir $@) $@ + bpftool gen skeleton $(BUILD_DIR)/$*.bpf.o > $@ + python3 $(PROJ_ROOT)/script/patch_skel.py $@ clean: rm -f $(BUILD_DIR)/*.skel.h $(BUILD_DIR)/*.o $(BUILD_DIR)/*.d $(TARGETs) $(BUILD_DIR)/.tmp.*.skel.h diff --git a/script/gen-source-pkg.sh b/script/gen-source-pkg.sh index 0972136..49cf2f4 100755 --- a/script/gen-source-pkg.sh +++ b/script/gen-source-pkg.sh @@ -91,8 +91,8 @@ echo -e "${YELLOW}Collecting main repo source files...${NC}" cd "${PROJECT_ROOT}" git ls-files --cached | while IFS= read -r f; do case "$f" in - bpf|bpf/*|googletest|googletest/*|test/*|tools/*|.gitmodules|*.spec) - # bpf/ handled separately; googletest/test/tools not needed for RPM + bpf|bpf/*|googletest|googletest/*|test/*|.gitmodules|*.spec) + # bpf/ handled separately; googletest/test not needed for RPM continue ;; *) @@ -226,8 +226,12 @@ if [ -f bpf/build/include/vmlinux.h ]; then VMLINUX_OVERRIDE="VMLINUX=bpf/build/include/vmlinux.h" fi +# Build extern-prep once to avoid parallel build race across modules +make -C tools extern-prep + make %{?_smp_mflags} USE_SUBMODULE=0 \\ \${VMLINUX_OVERRIDE} \\ + BPF_PREPROCESS=\$(pwd)/build/tools/extern-prep \\ KHEADERS_DIR="\${KHEADERS_DIR}" \\ bpf \\ observe BPF_DIR_PATCH=/usr/lib/dkapture \\ diff --git a/script/patch_skel.py b/script/patch_skel.py index cf66f6a..e5c94c5 100644 --- a/script/patch_skel.py +++ b/script/patch_skel.py @@ -275,7 +275,7 @@ def patch_header(header_path: str, dry_run: bool = False, obj_dir: str | None = # Infer the corresponding object file path and ensure it exists if obj_dir: stem = os.path.basename(header_path)[:-len('.skel.h')] - stem = re.sub(r'^\.tmp\.\d+\.', '', stem) + stem = re.sub(r'^\.tmp\.(\d+\.)?', '', stem) obj_path = os.path.join(obj_dir, stem + '.bpf.o') else: obj_path = header_path[:-len('.skel.h')] + '.bpf.o'