GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
driver

amdgcn, nvptx: Use read_collect_gcc_options in mkoffload [PR111527]

Offload compiler drivers now safely read environment options.

The mkoffload utility for amdgcn and nvptx targets now uses read_collect_gcc_options instead of getenv to read COLLECT_GCC_OPTIONS. This change ensures safer handling of environment variables used to pass compiler options, consistent with recent driver modifications that spill long option strings to response files. While these specific instances only checked for the variable’s existence, the update prevents potential future issues and maintains uniformity.

In Details

The mkoffload scripts for GCN and NVPTX offloading targets have been updated to use read_collect_gcc_options from libcpp/env.c instead of a direct getenv call for COLLECT_GCC_OPTIONS. This aligns with a recent change in the main driver (r17-1526-g619a5e5586759a) that introduced response file support for COLLECT_GCC_OPTIONS, making raw getenv calls unsafe if the variable is not set or if its content has changed. This change ensures the offload driver consistently and safely accesses this information.

For Context
COLLECT_GCC_OPTIONS
An environment variable used by GCC's driver to pass compiler options and configurations, especially when they are too numerous for the command line. It may be read directly or spilled to a response file.
mkoffload
A utility or script used by GCC's offloading infrastructure to manage and invoke the compilation process for target devices (e.g., GPUs).
getenv
A C standard library function that retrieves the value of an environment variable.
Filed Under: driveroffloading