Skip to content

cmake: switch python linker flags to target_link_options - #346

Open
fallintoplace wants to merge 1 commit into
NVIDIA:developfrom
fallintoplace:fix/python-module-link-flags
Open

cmake: switch python linker flags to target_link_options#346
fallintoplace wants to merge 1 commit into
NVIDIA:developfrom
fallintoplace:fix/python-module-link-flags

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Why

_compiled_module set LINK_FLAGS three times in set_target_properties, which means earlier values can be overwritten and final exported flags may miss required linker options.

What changed

  • Replace repeated LINK_FLAGS assignments with a single target_link_options(_compiled_module PRIVATE ...) call.
  • Preserve LINK_WHAT_YOU_USE in its existing set_target_properties(...) call.

Verification

cmake configure/build in this environment is blocked by missing CUDA (nvcc not found).

Please validate with:

cmake -S . -B build-link-check -G Ninja \\\n  -DCUDNN_FRONTEND_BUILD_PYTHON_BINDINGS=ON \\\n  -DCUDNN_FRONTEND_BUILD_TESTS=OFF \\\n  -DCUDNN_FRONTEND_BUILD_SAMPLES=OFF
cmake --build build-link-check --target _compiled_module --verbose

Confirm the verbose link line contains all three flags:

  • -Wl,--no-as-needed
  • -Wl,--enable-new-dtags
  • -Wl,-rpath,\x27$ORIGIN\x27,-rpath,\x27$ORIGIN/../lib\x27,-rpath,\x27$ORIGIN/../nvidia/cudnn/lib\x27

Summary by CodeRabbit

  • Chores
    • Updated the Python build configuration to use a more standard linker options setup.
    • Preserved existing build behavior while improving how linker settings are applied during module compilation.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1334ec11-b245-4a23-bb63-d2a08e79baa0

📥 Commits

Reviewing files that changed from the base of the PR and between 52119ee and 448c810.

📒 Files selected for processing (1)
  • python/CMakeLists.txt

📝 Walkthrough

Walkthrough

This change modifies python/CMakeLists.txt to move linker flag configuration for the _compiled_module target from the LINK_FLAGS property in set_target_properties to a dedicated target_link_options call, preserving the same flag values.

Changes

CMake linker configuration

Layer / File(s) Summary
Migrate linker flags to target_link_options
python/CMakeLists.txt
--no-as-needed, --enable-new-dtags, and $ORIGIN-based rpath flags are moved from the LINK_FLAGS property in set_target_properties to a new target_link_options(_compiled_module PRIVATE ...) block.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: moving Python linker flags to target_link_options in CMake.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant