https://gcc.gnu.org/g:bb42c397de7bde478a3c249a57f1af629e1a6772
commit r17-957-gbb42c397de7bde478a3c249a57f1af629e1a6772 Author: Ronan Desplanques <[email protected]> Date: Wed Mar 25 14:39:35 2026 +0100 ada: Fix light runtime configurations A recent changed added a dependency from the environment-related functions in argv.c to env.c. This broke some runtime configurations that provide command line support but no environment variable support. This fixes the issue by moving all of argv.c's environment-related code to env.c. It also tweaks a comment in passing. gcc/ada/ChangeLog: * argv.c (__gnat_env_count) (__gnat_len_env) (__gnat_fill_env): Move to... * env.c (__gnat_env_count) (__gnat_len_env) (__gnat_fill_env): ...here. Tweak comment. Diff: --- gcc/ada/argv.c | 42 ------------------------------------------ gcc/ada/env.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/gcc/ada/argv.c b/gcc/ada/argv.c index 6d670e1aa5dd..8eb7de4f2f84 100644 --- a/gcc/ada/argv.c +++ b/gcc/ada/argv.c @@ -61,17 +61,6 @@ extern "C" { int gnat_argc = 0; char **gnat_argv = NULL; -/* It used to be the case that users were required to forward the envp - parameter of main to the variable below when using a non-Ada main. The - consequences for failing to meet the requirement was improper operation of - Ada.Command_Line.Environment. - - Today, users are not required to do anything with gnat_envp and - Ada.Command_Line.Environment does not use it anymore. In fact it's not used - by anything, but we keep its definition so that programs that obey the old - requirement keep linking. */ -char **gnat_envp = NULL; - int __gnat_arg_count (void) { @@ -94,37 +83,6 @@ __gnat_fill_arg (char *a, int i) memcpy (a, gnat_argv[i], strlen (gnat_argv[i])); } -int -__gnat_env_count (void) -{ - int i; - char **envp = __gnat_environ(); - - for (i = 0; envp[i]; i++) - ; - return i; -} - -int -__gnat_len_env (int env_num) -{ - char **envp = __gnat_environ(); - - if (envp != NULL) - return strlen (envp[env_num]); - else - return 0; -} - -void -__gnat_fill_env (char *a, int i) -{ - char **envp = __gnat_environ(); - - if (envp != NULL) - memcpy (a, envp[i], strlen (envp[i])); -} - #ifdef __cplusplus } #endif diff --git a/gcc/ada/env.c b/gcc/ada/env.c index c4d9424c65ef..2931220f069b 100644 --- a/gcc/ada/env.c +++ b/gcc/ada/env.c @@ -256,6 +256,48 @@ void __gnat_clearenv (void) #endif } +/* It used to be the case that users were required to forward the envp + parameter of main to the variable below when using a non-Ada main. The + consequences for failing to meet the requirement was improper operation of + Ada.Command_Line.Environment. + + Nowadays, users are not required to do anything with gnat_envp and + Ada.Command_Line.Environment does not use it anymore. In fact it's not used + by anything, but we keep its definition so that programs that obey the old + requirement keep linking. */ +char **gnat_envp = NULL; + +int +__gnat_env_count (void) +{ + int i; + char **envp = __gnat_environ(); + + for (i = 0; envp[i]; i++) + ; + return i; +} + +int +__gnat_len_env (int env_num) +{ + char **envp = __gnat_environ(); + + if (envp != NULL) + return strlen (envp[env_num]); + else + return 0; +} + +void +__gnat_fill_env (char *a, int i) +{ + char **envp = __gnat_environ(); + + if (envp != NULL) + memcpy (a, envp[i], strlen (envp[i])); +} + #ifdef __cplusplus } #endif
