Unified · Split
| @@ -140,6 +140,11 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv) · 139 unmodified lines | |||
| 140 | #ifdef CONFIG_TCC_BACKTRACE | 140 | #ifdef CONFIG_TCC_BACKTRACE |
| 141 | rt_context *rc = &g_rtctxt; | 141 | rt_context *rc = &g_rtctxt; |
| 142 | #endif | 142 | #endif |
| 143 | # if defined(__APPLE__) | ||
| 144 | char **envp = NULL; | ||
| 145 | #else | ||
| 146 | char **envp = environ; | ||
| 147 | #endif | ||
| 143 | 148 | ||
| 144 | s1->runtime_main = s1->nostdlib ? "_start" : "main"; | 149 | s1->runtime_main = s1->nostdlib ? "_start" : "main"; |
| 145 | if ((s1->dflag & 16) && !find_c_sym(s1, s1->runtime_main)) | 150 | if ((s1->dflag & 16) && !find_c_sym(s1, s1->runtime_main)) |
| @@ -184,12 +189,12 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv) · 38 unmodified lines | |||
| 184 | fflush(stdout); | 189 | fflush(stdout); |
| 185 | fflush(stderr); | 190 | fflush(stderr); |
| 186 | /* These aren't C symbols, so don't need leading underscore handling. */ | 191 | /* These aren't C symbols, so don't need leading underscore handling. */ |
| 187 | run_cdtors(s1, "__init_array_start", "__init_array_end", argc, argv, environ); | 192 | run_cdtors(s1, "__init_array_start", "__init_array_end", argc, argv, envp); |
| 188 | #ifdef CONFIG_TCC_BACKTRACE | 193 | #ifdef CONFIG_TCC_BACKTRACE |
| 189 | if (!rc->do_jmp || !(ret = setjmp(rc->jmp_buf))) | 194 | if (!rc->do_jmp || !(ret = setjmp(rc->jmp_buf))) |
| 190 | #endif | 195 | #endif |
| 191 | { | 196 | { |
| 192 | ret = prog_main(argc, argv, environ); | 197 | ret = prog_main(argc, argv, envp); |
| 193 | } | 198 | } |
| 194 | run_cdtors(s1, "__fini_array_start", "__fini_array_end", 0, NULL, NULL); | 199 | run_cdtors(s1, "__fini_array_start", "__fini_array_end", 0, NULL, NULL); |
| 195 | if ((s1->dflag & 16) && ret) | 200 | if ((s1->dflag & 16) && ret) |