﻿# HIPRTC headers: the include name and supplied source are part of the compiled artifact

Package HIPRTC source, injected header contents, include names and compiler options together so runtime compilation does not depend on accidental host-build visibility.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-hiprtc-injected-header-include-name-manifest/
Language: en

## Separate the host build from the generated program

A C++ service includes a tensor-layout header and constructs a kernel as a string. That kernel cannot assume that the service's host preprocessor already supplied the same definitions. The [HIPRTC programming guide](https://rocmdocs.amd.com/projects/HIP/en/latest/how-to/hip_rtc.html) describes runtime program construction and provided headers. Treat the generated program as a separate compilation unit with declared inputs. Host executable build success is not evidence that the runtime source can resolve every dependency it mentions.

## Pair include names with actual contents

The [runtime compilation API](https://rocmdocs.amd.com/projects/HIP/en/latest/reference/hip_runtime_api/modules/runtime_compilation.html) exposes header-source and include-name arrays when creating a program. Preserve their correspondence. A supplied layout header under one virtual name does not automatically satisfy a different include spelling used by generated code. Build a manifest of source text, names and contents instead of debugging a missing definition solely through the application's filesystem. Check nested dependencies as well as the first directly included file.

## Do not inherit host configuration accidentally

A macro used when compiling the host service does not necessarily have the same value during runtime compilation. Record device compilation options, target selection and generated definitions explicitly. For example, a stride type or alignment constant that differs between host-generated arguments and device code can compile successfully while describing incompatible data. Keep the schema used to build arguments connected to the schema compiled into the kernel, rather than treating a common header filename as proof of identical contents.

## Preserve diagnostics and input identity

The [HIPRTC declarations](https://github.com/ROCm/HIP/blob/develop/include/hip/hiprtc.h) expose program creation, compilation and diagnostic-log operations. Save the log on failure alongside a non-sensitive input identity and options. A cache keyed only by the kernel string misses changes in injected header contents. Include every compilation-affecting dependency in the cache policy. This is a reproducibility requirement, not a recommendation to print proprietary source or request data into operational logs.

## Check a dependency change deliberately

Use a small generated kernel whose output depends on a declared header constant. Change that header and verify the cache selects the intended compiled artifact and checked output. Related guides cover [reproducible software stacks](/journal/software-stack-reproducibility/) and [HIP portability](/journal/learn-hip-launch-portability/). The specific boundary here is compilation input ownership: runtime source, provided headers and options form an artifact together, independently of what the host application happened to include during its own build.
