Skip to content

allow make install to work for module#72

Open
ron003 wants to merge 11 commits into
developfrom
ron/module_cleanup
Open

allow make install to work for module#72
ron003 wants to merge 11 commits into
developfrom
ron/module_cleanup

Conversation

@ron003

@ron003 ron003 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

after cmake -DWANT_KMOD=ON -DCMAKE_INSTALL_PREFIX=/ ..
make install should install utilities and module in expected locations.

Copilot AI review requested due to automatic review settings July 21, 2026 21:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_KMOD CMake option to control whether the kernel module is built.
  • Changes kernel module installation to install TRACE.ko into /lib/modules/<kver>/... and runs depmod after 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.

Comment thread src_module/CMakeLists.txt Outdated
Comment thread src_module/CMakeLists.txt Outdated
ron003 and others added 2 commits July 22, 2026 11:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 22, 2026 16:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/depmod and runs depmod -a unconditionally. This can unintentionally modify the host module dependency files during staged installs (e.g., when DESTDIR is set) and may fail on systems where depmod isn’t in /sbin. Consider locating depmod via find_program and only running it for real system installs (e.g., CMAKE_INSTALL_PREFIX is / and DESTDIR is not set). Also, the cache help text mentions /lib/modules/... but the destination is relative to CMAKE_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})")

Copilot AI review requested due to automatic review settings July 23, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -a is 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/modules even 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()")

Comment thread script/CMakeLists.txt Outdated
Comment on lines 29 to 31
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
Copilot AI review requested due to automatic review settings July 23, 2026 21:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -a is currently run whenever DESTDIR is empty, even for non-system prefixes where the module is installed under <prefix>/lib/modules/.... In that case, running depmod will operate on the host’s /lib/modules tree (and may fail or unexpectedly modify the system), which can break make install for local-prefix installs. Gate the depmod step 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()")

Comment thread CMakeLists.txt Outdated
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>
Copilot AI review requested due to automatic review settings July 23, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_SYSCONFDIR makes this install destination absolute (prefix baked in at configure time), which breaks cmake --install ... --prefix <new> relocatable installs and is inconsistent with how other install destinations are specified. Use the relative CMAKE_INSTALL_SYSCONFDIR here 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 depmod unconditionally (when DESTDIR is empty) can fail the install if depmod is not on PATH (often under /sbin//usr/sbin) or if it returns a non-zero status. Make this step best-effort by locating depmod and warning (not failing) on errors so make install remains robust.
    install(CODE "if(\"\$ENV{DESTDIR}\" STREQUAL \"\")\n
    execute_process(COMMAND depmod -a \"${KVERS}\")\nendif()")

Comment thread CMakeLists.txt
Comment on lines 201 to +202
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/etc/compiler_info
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR})
Copilot AI review requested due to automatic review settings July 23, 2026 23:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 depmod install step runs whenever DESTDIR is empty, even for non-system prefixes where the module is installed under <prefix>/lib/modules/.... In that case depmod -a ${KVERS} will update the host system’s /lib/modules instead 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()")

@ron003
ron003 requested a review from eflumerf July 24, 2026 03:00
@ron003

ron003 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

I did test this in the dbt-create -s environment, and it (including python) seems to be OK.

@ron003

ron003 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Wait - there seems to be a problem with PYTHONPATH

Copilot AI review requested due to automatic review settings July 24, 2026 04:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 install to 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()")

Comment thread CMakeLists.txt Outdated
More robust, but more involved/complex

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 04:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread README.md
Copilot AI review requested due to automatic review settings July 24, 2026 05:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src_module/CMakeLists.txt
Comment on lines +37 to +38
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>
Copilot AI review requested due to automatic review settings July 24, 2026 05:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • depmod is 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 though make install succeeds. 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_SYSCONFDIR hard-codes an absolute destination computed at configure time, which can break cmake --install --prefix … and is inconsistent with the other install rules that use relative destinations. Using CMAKE_INSTALL_SYSCONFDIR still 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_SYSCONFDIR bakes in the configure-time prefix. Using CMAKE_INSTALL_SYSCONFDIR keeps 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})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋 Triage

Development

Successfully merging this pull request may close these issues.

3 participants