From c74e4d0c80cd5241f7892f9afcec3338214e26bb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 12 Sep 2019 21:43:32 +0200 Subject: [PATCH] LibC: Pass the environment as third argument to main() After some very confused debugging, I discovered that GNU make has a main() function with this signature: int main(int argc, char** argv, char** envp) Apparently this is a non-standard but widely supported thing, so let's do the same in Serenity so make works as expected. This fixes an issue where you had to do "make PATH=..." instead of make just picking up PATH from the environment. :^) --- Libraries/LibC/crt0.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibC/crt0.cpp b/Libraries/LibC/crt0.cpp index 9136539ae73..8466abefdf3 100644 --- a/Libraries/LibC/crt0.cpp +++ b/Libraries/LibC/crt0.cpp @@ -4,7 +4,7 @@ extern "C" { -int main(int, char**); +int main(int, char**, char**); __thread int errno; char** environ; @@ -36,7 +36,7 @@ int _start(int argc, char** argv, char** env) for (size_t i = 0; i < size; i++) (*__init_array_start[i])(argc, argv, env); - int status = main(argc, argv); + int status = main(argc, argv, environ); exit(status);