allow make install to work for module#72
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the CMake build/install logic so that when the TRACE kernel module is enabled, make install places the built TRACE.ko into a kernel-module directory and triggers module dependency refresh.
Changes:
- Adds a top-level
WANT_KMODCMake option to control whether the kernel module is built. - Changes kernel module installation to install
TRACE.kointo/lib/modules/<kver>/...and runsdepmodafter install.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
CMakeLists.txt |
Introduces the WANT_KMOD option so module build logic can be toggled from the top-level configuration. |
src_module/CMakeLists.txt |
Installs the built kernel module to a module directory and invokes depmod at install time. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src_module/CMakeLists.txt:29
- The install step currently hard-codes
/sbin/depmodand runsdepmod -aunconditionally. This can unintentionally modify the host module dependency files during staged installs (e.g., whenDESTDIRis set) and may fail on systems wheredepmodisn’t in/sbin. Consider locatingdepmodviafind_programand only running it for real system installs (e.g.,CMAKE_INSTALL_PREFIXis/andDESTDIRis not set). Also, the cache help text mentions/lib/modules/...but the destination is relative toCMAKE_INSTALL_PREFIX.
set(TRACE_KMOD_INSTALL_DIR "extra/TRACE" CACHE STRING "Subdir under /lib/modules/<kver>/ for TRACE.ko")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../module/${KVERS}/TRACE.ko
DESTINATION "lib/modules/${KVERS}/${TRACE_KMOD_INSTALL_DIR}")
install(CODE "execute_process(COMMAND /sbin/depmod -a ${KVERS})")
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src_module/CMakeLists.txt:38
depmod -ais executed on every non-DESTDIR install, even when installing the module under a non-system prefix (e.g.,CMAKE_INSTALL_PREFIX=/opt/...). That can unexpectedly modify the host system’s module dependency files under/lib/moduleseven though the module wasn’t installed there. Gate the depmod step to system installs (prefix/or/usr) in addition to the existing DESTDIR check.
install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\")\n
execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()")
| install(PROGRAMS bitN_to_mask trace_envvars trace_delta trace-cmd-merge trace_color trace-cmd-merge trace_bash trace_bash_example.sh DESTINATION bin) | ||
| install(PROGRAMS trace_functions.sh DESTINATION etc/profile.d) | ||
| install(PROGRAMS trace_functions.sh DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d) | ||
| install(PROGRAMS trace_functions.sh DESTINATION bin) # OK of DUNE patch (to this file) causes double bin install |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src_module/CMakeLists.txt:38
depmod -ais currently run wheneverDESTDIRis empty, even for non-system prefixes where the module is installed under<prefix>/lib/modules/.... In that case, runningdepmodwill operate on the host’s/lib/modulestree (and may fail or unexpectedly modify the system), which can breakmake installfor local-prefix installs. Gate thedepmodstep on system prefixes (e.g.,/and/usr), and consider capturing failures so they don’t silently pass.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../module/${KVERS}/TRACE.ko
DESTINATION "${TRACE_KMOD_INSTALL_DEST}")
install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\")\n
execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()")
Before the change: ``` $ rm -fr ../build/*; cmake -DWANT_KMOD=ON -DCMAKE_INSTALL_PREFIX=/ .. 2>/dev/null | grep 'source tree' -- TRACE source tree: install=ON, dir=share/TRACE, effective=/share/TRACE ``` Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
script/CMakeLists.txt:30
- Using
CMAKE_INSTALL_FULL_SYSCONFDIRmakes this install destination absolute (prefix baked in at configure time), which breakscmake --install ... --prefix <new>relocatable installs and is inconsistent with how other install destinations are specified. Use the relativeCMAKE_INSTALL_SYSCONFDIRhere so the effective prefix can still be overridden at install time.
install(PROGRAMS trace_functions.sh DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d)
src_module/CMakeLists.txt:38
- Running
depmodunconditionally (when DESTDIR is empty) can fail the install ifdepmodis not on PATH (often under/sbin//usr/sbin) or if it returns a non-zero status. Make this step best-effort by locatingdepmodand warning (not failing) on errors somake installremains robust.
install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\")\n
execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()")
| install(FILES ${CMAKE_CURRENT_BINARY_DIR}/etc/compiler_info | ||
| DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}) | ||
| DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src_module/CMakeLists.txt:38
- The
depmodinstall step runs wheneverDESTDIRis empty, even for non-system prefixes where the module is installed under<prefix>/lib/modules/.... In that casedepmod -a ${KVERS}will update the host system’s/lib/modulesinstead of the install tree (and may fail without root), which is incorrect for prefix installs.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../module/${KVERS}/TRACE.ko
DESTINATION "${TRACE_KMOD_INSTALL_DEST}")
install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\")\n
execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()")
|
I did test this in the dbt-create -s environment, and it (including python) seems to be OK. |
|
Wait - there seems to be a problem with PYTHONPATH |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
script/CMakeLists.txt:30
- Using ${CMAKE_INSTALL_FULL_SYSCONFDIR} here installs to /usr/etc/profile.d when CMAKE_INSTALL_PREFIX=/usr, but the README and typical system integration expect /etc/profile.d. This makes the system install layout inconsistent depending on whether the prefix is / or /usr.
install(PROGRAMS trace_functions.sh DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d)
src_module/CMakeLists.txt:38
- The install-time depmod invocation can cause
make installto fail (e.g., depmod not in PATH, insufficient privileges, or depmod returning non-zero). Since this runs as part of install, it's safer to locate depmod and treat failures as warnings so installation of TRACE.ko still succeeds.
install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\" AND (\"${CMAKE_INSTALL_PREFIX}\" STREQUAL \"/\" OR \"${CMAKE_INSTALL_PREFIX}\" STREQUAL \"/usr\"))\n
execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()")
More robust, but more involved/complex Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
script/CMakeLists.txt:30
- When configuring with -DCMAKE_INSTALL_PREFIX=/usr, GNUInstallDirs typically sets CMAKE_INSTALL_FULL_SYSCONFDIR to /usr/etc, so this installs trace_functions.sh under /usr/etc/profile.d rather than the expected system-wide /etc/profile.d. That makes the "system install" behavior differ between prefix=/ and prefix=/usr and can break system shell integration.
install(PROGRAMS trace_functions.sh DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
script/CMakeLists.txt:31
- For CMAKE_INSTALL_PREFIX=/usr, GNUInstallDirs typically sets CMAKE_INSTALL_FULL_SYSCONFDIR to /usr/etc (since SYSCONFDIR defaults to "etc"), so this will install to /usr/etc/profile.d rather than the intended /etc/profile.d for system integration (also described in README.md). Consider special-casing system prefixes (/ and /usr) to install directly under /etc, while keeping prefix-relative installs for non-system prefixes.
install(PROGRAMS trace_functions.sh DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d)
install(PROGRAMS trace_functions.sh DESTINATION bin) # OK if DUNE patch (to this file) causes double bin install
| install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\" AND (\"${CMAKE_INSTALL_PREFIX}\" STREQUAL \"/\" OR \"${CMAKE_INSTALL_PREFIX}\" STREQUAL \"/usr\"))\n | ||
| execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()") |
README.md Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
src_module/CMakeLists.txt:38
depmodis executed during installation but its exit status is ignored, so failures (missing depmod, insufficient permissions, etc.) will be silent and can leave the module unregistered even thoughmake installsucceeds. Capture the result and emit a warning (or make it fatal if desired) so operators can detect install-time issues.
install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\" AND (\"${CMAKE_INSTALL_PREFIX}\" STREQUAL \"/\" OR \"${CMAKE_INSTALL_PREFIX}\" STREQUAL \"/usr\"))\n
execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()")
script/CMakeLists.txt:30
- Using
CMAKE_INSTALL_FULL_SYSCONFDIRhard-codes an absolute destination computed at configure time, which can breakcmake --install --prefix …and is inconsistent with the other install rules that use relative destinations. UsingCMAKE_INSTALL_SYSCONFDIRstill supports both relative (etc) and absolute (/etc) sysconf dirs while preserving install-time prefix overrides.
install(PROGRAMS trace_functions.sh DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d)
CMakeLists.txt:229
- Installing to
CMAKE_INSTALL_FULL_SYSCONFDIRbakes in the configure-time prefix. UsingCMAKE_INSTALL_SYSCONFDIRkeeps the destination relative (or absolute if the user sets it to/etc) and continues to work with install-time prefix overrides (cmake --install --prefix …).
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/etc/compiler_info
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR})
after cmake -DWANT_KMOD=ON -DCMAKE_INSTALL_PREFIX=/ ..
make install should install utilities and module in expected locations.