[process] Don't use the constructor attribute on Linux

Using `__attribute__((constructor))` doesn't seem to get argc and argv
as arguments with certain versions of the libc. On the other hand, using
the `.init_array` section works so use that as a workaround until we can
find a cleaner fix.

h/t to @sas for this fix. This is a minimal fix for my problems when
using xcbuild tools on my Linux machine.

Fixes issue#138.
This commit is contained in:
Kellie Medlin 2016-10-06 23:50:56 -07:00 committed by Stephane Sezer
parent f9c9cebacb
commit 54a136e588

View File

@ -128,13 +128,19 @@ executablePath() const
static int commandLineArgumentCount = 0;
static char **commandLineArgumentValues = NULL;
#if !defined(__linux__)
__attribute__((constructor))
#endif
static void CommandLineArgumentsInitialize(int argc, char **argv)
{
commandLineArgumentCount = argc;
commandLineArgumentValues = argv;
}
#if defined(__linux__)
__attribute__((section(".init_array"))) auto commandLineArgumentInitializer = &CommandLineArgumentsInitialize;
#endif
std::vector<std::string> const &DefaultContext::
commandLineArguments() const
{