You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "junrushao (via GitHub)" <gi...@apache.org> on 2026/02/05 22:30:10 UTC

[PR] doc: Merge C++ tooling and C++ packaging [tvm-ffi]

junrushao opened a new pull request, #429:
URL: https://github.com/apache/tvm-ffi/pull/429

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] doc: Merge C++ tooling and C++ packaging [tvm-ffi]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #429:
URL: https://github.com/apache/tvm-ffi/pull/429#issuecomment-3856700129

   ## Summary of Changes
   
   Hello @junrushao, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
   
   This pull request streamlines the documentation by integrating the C++ packaging and distribution guidelines directly into the existing C++ tooling guide. This consolidation aims to provide a single, comprehensive resource for developers working with C++ in the project, covering everything from build integration and ABI compatibility to editor setup, thereby improving the overall clarity and discoverability of essential information.
   
   ### Highlights
   
   * **Documentation Consolidation**: The C++ packaging and distribution guide (`cpp_packaging.md`) has been merged into the C++ tooling guide (`cpp_tooling.rst`) to create a single, comprehensive resource.
   * **Enhanced C++ Tooling Guide**: The `cpp_tooling.rst` document now includes detailed sections on library distribution, ABI compatibility (manylinux approach), direct compilation with GCC/NVCC, and improved editor setup instructions.
   * **Improved Structure and Clarity**: Documentation sections have been re-organized, re-titled, and re-worded for better flow and conciseness, including new 'Build with TVM-FFI' and 'Library Distribution' sections.
   * **New Further Reading Section**: A dedicated section with links to related documentation has been added for deeper dives into specific topics.
   
   🧠 **New Feature in Public Preview:** You can now enable **Memory** to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
   
   <details>
   <summary><b>Changelog</b></summary>
   
   * **docs/index.rst**
       * Removed the direct reference to `packaging/cpp_packaging.md` from the table of contents.
   * **docs/packaging/cpp_packaging.md**
       * This file, which detailed C++ packaging and distribution, has been removed as its content was integrated into `cpp_tooling.rst`.
   * **docs/packaging/cpp_tooling.rst**
       * Updated the introductory description to reflect the expanded scope, now including library distribution.
       * Reorganized and clarified the 'C++ Headers' section, using bullet points for extra features.
       * Introduced new top-level sections for 'Build with TVM-FFI' (including CMake and GCC/NVCC usage) and 'Library Distribution' (incorporating manylinux guidance).
       * Refined the 'Install Target' and 'Set `tvm_ffi_ROOT`' explanations.
       * Renamed 'VSCode/Cursor' to 'Editor Setup' and improved clangd configuration details.
       * Added a 'Further Reading' section with links to related guides.
   </details>
   
   
   
   <details>
   <summary><b>Activity</b></summary>
   
   * There has been no human activity on this pull request since its creation.
   </details>
   
   
   <details>
   <summary><b>Using Gemini Code Assist</b></summary>
   <br>
   
   The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
   
   <b>Invoking Gemini</b>
   
   You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
   
   Feature | Command | Description
   --- | --- | ---
   Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
   Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
   Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
   Help | `/gemini help` | Displays a list of available commands.
   
   <b>Customization</b>
   
   To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   <b>Limitations & Feedback</b>
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   
   <b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>
   </details>
   
   
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] doc: Merge C++ tooling and C++ packaging [tvm-ffi]

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao merged PR #429:
URL: https://github.com/apache/tvm-ffi/pull/429


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] doc: Merge C++ tooling and C++ packaging [tvm-ffi]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #429:
URL: https://github.com/apache/tvm-ffi/pull/429#discussion_r2771441186


##########
docs/packaging/cpp_tooling.rst:
##########
@@ -190,19 +249,14 @@ The following settings help CMake Tools integrate with TVM-FFI and generate the
        }
    }
 
-
 .. important::
 
   Make sure ``Python_EXECUTABLE`` and ``tvm_ffi_ROOT`` match the virtual
   environment you intend to use.
 
-
-clangd
-------
-
-Create a ``.clangd`` file at your project root and point it to the CMake
-compilation database. The snippet below also removes NVCC flags that clangd
-does not understand:
+**clangd.** Create a ``.clangd`` file at the project root pointing to the CMake
+compilation database. The snippet below also strips NVCC flags that clangd
+does not recognize:

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   For better document structure and consistency, consider using a level 3 subheading for 'clangd' instead of bolded text.
   
   ```suggestion
   clangd
   ~~~~~~
   
   Create a ``.clangd`` file at the project root pointing to the CMake
   compilation database. The snippet below also strips NVCC flags that clangd
   does not recognize:
   ```



##########
docs/packaging/cpp_tooling.rst:
##########
@@ -135,47 +137,104 @@ On non-Apple platforms, this is currently a no-op.
 :DESTINATION: Install destination directory relative to ``CMAKE_INSTALL_PREFIX``.
 
 
-CMake Example
-~~~~~~~~~~~~~
+Set ``tvm_ffi_ROOT``
+""""""""""""""""""""
 
-.. code-block:: cmake
+If ``find_package(tvm_ffi CONFIG REQUIRED)`` fails because CMake cannot locate
+the package, pass ``tvm_ffi_ROOT`` explicitly:
 
-  find_package(tvm_ffi CONFIG REQUIRED)  # requires tvm_ffi_ROOT
-  tvm_ffi_configure_target(my-shared-lib)  # configure TVM-FFI linkage
-  install(TARGETS my-shared-lib DESTINATION .)
-  tvm_ffi_install(my-shared-lib DESTINATION .)  # install extra artifacts
+.. code-block:: bash
 
+   cmake -S . -B build \
+     -Dtvm_ffi_ROOT="$(tvm-ffi-config --cmakedir)"
 
-Set ``tvm_ffi_ROOT``
-~~~~~~~~~~~~~~~~~~~~
+.. note::
+
+   When packaging Python wheels with scikit-build-core, ``tvm_ffi_ROOT`` is
+   discovered automatically from the active Python environment.
 
-For a pure C++ build, CMake may fail when it reaches
 
-.. code-block:: cmake
+GCC/NVCC
+~~~~~~~~
+
+For quick prototyping or CI scripts without CMake, invoke ``g++`` or ``nvcc``
+directly with flags from ``tvm-ffi-config``.
+The examples below are from the :doc:`Quick Start <../get_started/quickstart>` tutorial:
 
-  find_package(tvm_ffi CONFIG REQUIRED)
+.. tabs::
 
-if it cannot locate the TVM-FFI package. In that case, set
-``tvm_ffi_ROOT`` to the TVM-FFI CMake package directory.
+  .. group-tab:: C++
+
+    .. literalinclude:: ../../examples/quickstart/raw_compile.sh
+      :language: bash
+      :start-after: [cpp_compile.begin]
+      :end-before: [cpp_compile.end]
+
+  .. group-tab:: CUDA
+
+    .. literalinclude:: ../../examples/quickstart/raw_compile.sh
+      :language: bash
+      :start-after: [cuda_compile.begin]
+      :end-before: [cuda_compile.end]
+
+The three ``tvm-ffi-config`` flags provide:
+
+:``--cxxflags``: Include paths and compile definitions (``-I...``, ``-D...``)
+:``--ldflags``: Library search paths (``-L...``, ``-Wl,-rpath,...``)
+:``--libs``: Libraries to link (``-ltvm_ffi``)
+
+**RPATH handling.** The resulting shared library links against ``libtvm_ffi.so``,
+so the dynamic linker must be able to find it at load time:
+
+- **Python distribution.** ``import tvm_ffi`` preloads ``libtvm_ffi.so`` into the
+  process before any user library is loaded, so the RPATH requirement is already
+  satisfied without additional linker flags.
+- **Pure C++ distribution.** You must ensure ``libtvm_ffi.so`` is on the library
+  search path. Either set ``-Wl,-rpath,$(tvm-ffi-config --libdir)`` at link time,
+  or place ``libtvm_ffi.so`` alongside your binary.
+
+
+Library Distribution
+--------------------
+
+When distributing pre-built shared libraries on Linux, glibc symbol versioning
+can cause load-time failures on systems with a different glibc version.
+The standard solution is the `manylinux <https://github.com/pypa/manylinux>`_
+approach: **build on old glibc, run on new**.
+
+**Build environment.** Use a manylinux Docker image:
 
 .. code-block:: bash
 
-   cmake -S . -B build \
-     -Dtvm_ffi_ROOT="$(tvm-ffi-config --cmakedir)"
+   docker pull quay.io/pypa/manylinux2014_x86_64
 
+Build host and device code inside the container. For CUDA:
 
-.. note::
+.. code-block:: bash
 
-   When packaging Python wheels with scikit-build-core, ``tvm_ffi_ROOT`` is
-   discovered automatically from the active Python environment, so you usually
-   do not need to set it explicitly.
+   nvcc -shared -Xcompiler -fPIC your_kernel.cu -o kernel.so \
+       $(tvm-ffi-config --cxxflags) \
+       $(tvm-ffi-config --ldflags) \
+       $(tvm-ffi-config --libs)
+
+**Verify glibc requirements.** Inspect the minimum glibc version your binary requires:
+
+.. code-block:: bash
+
+   objdump -T your_kernel.so | grep GLIBC_
+
+The ``apache-tvm-ffi`` wheel is already manylinux-compatible, so linking against
+it inside a manylinux build environment produces portable binaries.
 
 
-VSCode/Cursor
--------------
+Editor Setup
+------------
 
-The following settings help CMake Tools integrate with TVM-FFI and generate the
-``compile_commands.json`` used by clangd:
+The following configuration enables code completion and diagnostics in
+VSCode, Cursor, or any editor backed by clangd.
+
+**CMake Tools (VSCode/Cursor).** Add these workspace settings so CMake Tools
+can locate TVM-FFI and generate ``compile_commands.json``:

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   For better document structure and consistency with other sections, consider using a level 3 subheading for 'CMake Tools (VSCode/Cursor)' instead of bolded text.
   
   ```suggestion
   CMake Tools (VSCode/Cursor)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   
   Add these workspace settings so CMake Tools
   can locate TVM-FFI and generate ``compile_commands.json``:
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org