Skip to content

kmod/patch: simplify patch-hook.o build dependencies - #1473

Closed
georgejguo wants to merge 1 commit into
dynup:masterfrom
georgejguo:master-patch-hook
Closed

kmod/patch: simplify patch-hook.o build dependencies#1473
georgejguo wants to merge 1 commit into
dynup:masterfrom
georgejguo:master-patch-hook

Conversation

@georgejguo

Copy link
Copy Markdown
Contributor

The build dependencies for patch-hook.o are duplicated. The conditional inclusion of kpatch-patch-hook.c and livepatch-patch-hook.c is already managed in patch-hook.c via #if IS_ENABLED(CONFIG_LIVEPATCH).

The build dependencies for patch-hook.o are duplicated.
The conditional inclusion of kpatch-patch-hook.c and livepatch-patch-hook.c
is already managed in patch-hook.c via #if IS_ENABLED(CONFIG_LIVEPATCH).

Signed-off-by: george <guodongtai@kylinos.cn>
@joe-lawrence

joe-lawrence commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

Hi @georgejguo ,

While it may seem like this is a reasonable optimization, providing the two hook implementation files directly as Make dependencies is important to mark them as such in the build process. GNU Make itself does not automatically include header files in the dependency tree for source files.

For example:

A - Setup a test directory with skeleton Makefile and dummy source files

$ mkdir /tmp/test
 $cd /tmp/test

# Create dummy kpatch/livepatch hook implementations
$ touch kpatch-patch-hook.c livepatch-patch-hook.c

# Create a simple patch-hook that always includes livepatch-hook
$ cat << 'EOF' > patch-hook.c
#include "livepatch-hook.c"
EOF

# Skeleton Makefile with full dependencies as per HEAD
$ cat << 'EOF' > Makefile
patch-hook.o: patch-hook.c kpatch-patch-hook.c livepatch-patch-hook.c
	touch patch-hook.o
clean:
	rm patch-hook.o
EOF

B - Verify how the Make dependencies currently work:

# Initial "build"
$ make
touch patch-hook.o

# Second make invocation = dependencies are older = no build
$ make
make: 'patch-hook.o' is up to date.

# Third build = patch-hook.c is updated = build
$ touch patch-hook.c && make
touch patch-hook.o

# Fourth build = dependencies are older = no build
$ make
make: 'patch-hook.o' is up to date.

# Fifth build = livepatch-patch-hook.c is updated = build
$ touch livepatch-patch-hook.c && make
touch patch-hook.o
$ make clean

C - See how we lose the fifth build test case when dropping them from the dependency list:

# Skeleton Makefile with single dependency
$ cat << 'EOF' > Makefile
patch-hook.o: patch-hook.c
	touch patch-hook.o
clean:
	rm patch-hook.o
EOF

# Previous test cases match
$ make
touch patch-hook.o
$ make
make: 'patch-hook.o' is up to date.
$ touch patch-hook.c && make
touch patch-hook.o
$ make
make: 'patch-hook.o' is up to date.

# Fifth build = livepatch-patch-hook.c is updated, but no build!
$ touch livepatch-patch-hook.c && make
make: 'patch-hook.o' is up to date.

@github-actions

Copy link
Copy Markdown

This PR has been open for 60 days with no activity and no assignee. It will be closed in 7 days unless a comment is added.

@github-actions github-actions Bot added the stale label Oct 25, 2025
@github-actions

github-actions Bot commented Nov 1, 2025

Copy link
Copy Markdown

This PR was closed because it was inactive for 7 days after being marked stale.

@github-actions github-actions Bot closed this Nov 1, 2025
@georgejguo
georgejguo deleted the master-patch-hook branch January 13, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants