Skip to content

Commit

Permalink
Kbuild: Use absolute paths for symbolic links
Browse files Browse the repository at this point in the history
Command to create a symbolic link, explicitly resolving the symlink target
to an absolute path to abstract away the difference between Linux < 6.13,
where the CWD is the Linux kernel source tree for Kbuild extmod builds, and
Linux >= 6.13, where the CWD is the external module source tree.

This is used to create the nv*-kernel.o -> nv*-kernel.o_binary symlinks for
kernel modules which use precompiled binary object files

Signed-off-by: Eric Naim <[email protected]>
  • Loading branch information
1Naim committed Jan 5, 2025
1 parent 7a35555 commit 27504e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 14 additions & 0 deletions kernel-open/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ ifeq ($(NV_UNDEF_BEHAVIOR_SANITIZER),1)
UBSAN_SANITIZE := y
endif

#
# Command to create a symbolic link, explicitly resolving the symlink target
# to an absolute path to abstract away the difference between Linux < 6.13,
# where the CWD is the Linux kernel source tree for Kbuild extmod builds, and
# Linux >= 6.13, where the CWD is the external module source tree.
#
# This is used to create the nv*-kernel.o -> nv*-kernel.o_binary symlinks for
# kernel modules which use precompiled binary object files.
#

quiet_cmd_symlink = SYMLINK $@
cmd_symlink = ln -sf $(abspath $<) $@


$(foreach _module, $(NV_KERNEL_MODULES), \
$(eval include $(src)/$(_module)/$(_module).Kbuild))

Expand Down
5 changes: 1 addition & 4 deletions kernel-open/nvidia-modeset/nvidia-modeset.Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ NV_KERNEL_MODULE_TARGETS += $(NVIDIA_MODESET_KO)
NVIDIA_MODESET_BINARY_OBJECT := $(src)/nvidia-modeset/nv-modeset-kernel.o_binary
NVIDIA_MODESET_BINARY_OBJECT_O := nvidia-modeset/nv-modeset-kernel.o

quiet_cmd_symlink = SYMLINK $@
cmd_symlink = ln -sf $< $@

targets += $(NVIDIA_MODESET_BINARY_OBJECT_O)

$(obj)/$(NVIDIA_MODESET_BINARY_OBJECT_O): $(NVIDIA_MODESET_BINARY_OBJECT) FORCE
Expand Down Expand Up @@ -81,7 +78,7 @@ $(call ASSIGN_PER_OBJ_CFLAGS, $(NVIDIA_MODESET_OBJECTS), $(NVIDIA_MODESET_CFLAGS

NVIDIA_MODESET_INTERFACE := nvidia-modeset/nv-modeset-interface.o

# Linux kernel v5.12 and later looks at "always-y", Linux kernel versions
# Linux kernel v5.12 and later looks at "always-y", Linux kernel versions
# before v5.6 looks at "always"; kernel versions between v5.12 and v5.6
# look at both.

Expand Down
5 changes: 1 addition & 4 deletions kernel-open/nvidia/nvidia.Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ NVIDIA_KO = nvidia/nvidia.ko
NVIDIA_BINARY_OBJECT := $(src)/nvidia/nv-kernel.o_binary
NVIDIA_BINARY_OBJECT_O := nvidia/nv-kernel.o

quiet_cmd_symlink = SYMLINK $@
cmd_symlink = ln -sf $< $@

targets += $(NVIDIA_BINARY_OBJECT_O)

$(obj)/$(NVIDIA_BINARY_OBJECT_O): $(NVIDIA_BINARY_OBJECT) FORCE
Expand Down Expand Up @@ -95,7 +92,7 @@ clean-files += $(NV_COMPILER_VERSION_HEADER)

NVIDIA_INTERFACE := nvidia/nv-interface.o

# Linux kernel v5.12 and later looks at "always-y", Linux kernel versions
# Linux kernel v5.12 and later looks at "always-y", Linux kernel versions
# before v5.6 looks at "always"; kernel versions between v5.12 and v5.6
# look at both.

Expand Down

0 comments on commit 27504e1

Please sign in to comment.