Contents Menu Expand Light mode Dark mode Auto light/dark mode
Clang
Logo
Clang
  • Clang (In-Progress) Release Notes
  • Clang Compiler User’s Manual
  • Assembling a Complete Toolchain
  • Clang Language Extensions
    • Objective-C Literals
    • Language Specification for Blocks
    • Block Implementation Specification
    • Objective-C Automatic Reference Counting (ARC)
    • Pointer Authentication
    • Matrix Types
    • C++ Type Aware Allocators
  • Clang command line argument reference
  • Attributes in Clang
  • Diagnostic flags in Clang
  • AMDGPU Builtins
  • Warning suppression mappings
  • Cross-compilation using Clang
  • Clang Static Analyzer
    • 1. Available Checkers
    • 2. User Docs
      • 2.1. Command Line Usage: scan-build and CodeChecker
      • 2.2. Configuring the Analyzer
      • 2.3. Running the analyzer within Xcode
      • 2.4. Filing Bugs and Feature Requests
      • 2.5. Cross Translation Unit (CTU) Analysis
      • 2.6. Taint Analysis Configuration
      • 2.7. Source Annotations
      • 2.8. FAQ and How to Deal with Common False Positives
    • 3. Developer Docs
      • 3.1. Debug Checks
      • 3.2. Inlining
      • 3.3. Initializer List
      • 3.4. Nullability Checks
      • 3.5. Region Store
      • 3.6. Performance Investigation
      • 3.7. Analysis Statistics
  • Thread Safety Analysis
  • Lifetime Safety Analysis
  • C++ Safe Buffers
  • Scalable Static Analysis Framework
    • 1. Source Edit Generation
    • 2. Summary Extraction
    • Developer Documentation
      • 1. Force-Linker Headers
      • 2. How to Extend the Framework
      • 3. Summary Extraction Internals
  • Data flow analysis: an informal introduction
  • Function Effect Analysis
  • AddressSanitizer
  • ThreadSanitizer
  • MemorySanitizer
  • UndefinedBehaviorSanitizer
  • DataFlowSanitizer
    • DataFlowSanitizer Design Document
  • LeakSanitizer
  • TypeSanitizer
  • RealtimeSanitizer
  • SanitizerCoverage
  • SanitizerStats
  • Sanitizer special case list
  • Allocation Tokens
  • OverflowBehaviorTypes
  • -fbounds-safety: Enforcing bounds safety for C
  • Adoption Guide for -fbounds-safety
  • Implementation plans for -fbounds-safety
  • Control Flow Integrity
    • Control Flow Integrity Design Documentation
  • LTO Visibility
  • Pointer Authentication
  • SafeStack
  • ShadowCallStack
  • Structure Protection
  • Source-based Code Coverage
  • Standard C++ Modules
  • Modules
  • MSVC compatibility
  • Misexpect
  • OpenCL Support
  • OpenMP Support
  • SYCL Compiler and Runtime architecture design
  • HIP Support
  • Clang HLSL Documentation
    • HLSL Support
  • HLSL Design and Implementation
    • Expected Differences vs DXC and FXC
    • HLSL IR Reference
    • HLSL Resource Types
    • HLSL Entry Functions
    • HLSL Function Calls
    • HLSL Availability Diagnostics
  • ThinLTO
  • API Notes: Annotations Without Modifying Headers
  • Debugging C++ Coroutines
  • AMDGPU Support
  • RISC-V Support
  • C++ Type Aware Allocators
  • ClangIR
    • 1. ClangIR ABI Lowering Design Document
    • 2. ClangIR Cleanup and Exception Handling Design
    • 3. ClangIR Code Duplication Roadmap
  • Clang “man” pages
    • clang - the Clang C, C++, and Objective-C compiler
    • diagtool - clang diagnostics tool
  • Frequently Asked Questions (FAQ)
  • Choosing the Right Interface for Your Application
  • External Clang Examples
  • Introduction to the Clang AST
  • LibTooling
  • Libclang tutorial
  • LibFormat
  • Clang Plugins
  • How to write RecursiveASTVisitor based ASTFrontendActions.
  • Tutorial for building tools using LibTooling and LibASTMatchers
  • Matching the Clang AST
  • Clang Transformer Tutorial
  • ASTImporter: Merging Clang ASTs
  • How To Setup Clang Tooling For LLVM
  • JSON Compilation Database Format Specification
  • Clang’s refactoring engine
  • Overview
  • ClangCheck
  • ClangFormat
  • Clang-Format Style Options
  • Clang Linker Wrapper
  • Clang nvlink Wrapper
  • Clang Offload Bundler
  • Clang-Repl
  • Clang SYCL Linker
  • Clang Maintainers
  • Active Maintainers
  • Inactive Maintainers
  • “Clang” CFE Internals Manual
  • Driver Design & Internals
  • Multilib
  • Offloading Design & Internals
  • Precompiled Header and Modules Internals
  • ABI tags
  • Control Flow Integrity Design Documentation
  • Hardware-assisted AddressSanitizer Design Documentation
  • Constant Interpreter
  • LLVM IR Generation for EH and Cleanups
Back to top
Edit this page

Clang nvlink Wrapper#

Introduction#

This tool works as a wrapper around the NVIDIA nvlink linker. The purpose of this wrapper is to provide an interface similar to the ld.lld linker while still relying on NVIDIA’s proprietary linker to produce the final output.

nvlink has a number of known quirks that make it difficult to use in a unified offloading setting. For example, it does not accept .o files as they must be named .cubin. Static archives do not work, so passing a .a will provide a linker error. nvlink also does not support link time optimization and ignores many standard linker arguments. This tool works around these issues.

Usage#

This tool can be used with the following options. Any arguments not intended only for the linker wrapper will be forwarded to nvlink.

OVERVIEW: A utility that wraps around the NVIDIA 'nvlink' linker.
This enables static linking and LTO handling for NVPTX targets.

USAGE: clang-nvlink-wrapper [options] <options to passed to nvlink>

OPTIONS:
  --arch <value>       Specify the 'sm_' name of the target architecture.
  --cuda-path=<dir>    Set the system CUDA path
  --dry-run            Print generated commands without running.
  --feature <value>    Specify the '+ptx' feature to use for LTO.
  -g                   Specify that this was a debug compile.
  -help-hidden         Display all available options
  -help                Display available options (--help-hidden for more)
  -L <dir>             Add <dir> to the library search path
  -l <libname>         Search for library <libname>
  -mllvm <arg>         Arguments passed to LLVM, including Clang invocations,
                       for which the '-mllvm' prefix is preserved. Use '-mllvm
                       --help' for a list of options.
  -o <path>            Path to file to write output
  --plugin-opt=jobs=<value>
                       Number of LTO codegen partitions
  --plugin-opt=lto-partitions=<value>
                       Number of LTO codegen partitions
  --plugin-opt=O<O0, O1, O2, or O3>
                       Optimization level for LTO
  --plugin-opt=thinlto<value>
                       Enable the thin-lto backend
  --plugin-opt=<value> Arguments passed to LLVM, including Clang invocations,
                       for which the '-mllvm' prefix is preserved. Use '-mllvm
                       --help' for a list of options.
  --save-temps         Save intermediate results
  --version            Display the version number and exit
  -v                   Print verbose information

Example#

This tool is intended to be invoked when targeting the NVPTX toolchain directly as a cross-compiling target. This can be used to create standalone GPU executables with normal linking semantics similar to standard compilation.

clang --target=nvptx64-nvidia-cuda -march=native -flto=full input.c
Next
Clang Offload Bundler
Previous
Clang Linker Wrapper
Copyright © 2007-2026, The Clang Team
Made with Sphinx and @pradyunsg's Furo
On this page
  • Clang nvlink Wrapper
    • Introduction
    • Usage
    • Example