Ada No Longer Depends on gnat_envp for Environment Variables
The Ada runtime no longer relies on the non-standard `gnat_envp` global for accessing environment variables, improving compatibility and correctness.
The Ada runtime’s handling of environment variables has been updated to use the standard environ mechanism (or its equivalent on other platforms) instead of the GNAT-specific gnat_envp. This eliminates potential null pointer dereferences and linking failures, especially in mixed C/Ada projects. The change also ensures consistency across platforms with respect to putenv calls.
In Details
This commit removes the dependency on the gnat_envp global variable within the Ada runtime (argv.c, bindgen.adb). This variable, used by Ada.Command_Line.Environment, required manual initialization and caused issues in mixed-language projects and dynamic linking scenarios. Switching to the standard environ mechanism simplifies the runtime and improves compatibility.
For Context
Accessing environment variables (like PATH) is a common task for programs. Historically, the Ada runtime used a custom mechanism (gnat_envp) to access these variables, which could lead to problems when mixing Ada with other languages like C, especially in complex build setups. This change makes the Ada runtime more robust by using the standard way of accessing environment variables, leading to fewer potential bugs and a more consistent experience across different platforms.