Check if building on Android through the ANDROID_DATA environment variable, then set
SWIFT_ANDROID_NATIVE_SYSROOT to the default layout for the Termux app, and key all the
include, lib, and other SDK paths off of that. The system libc and a few other libraries
are linked against from /system/lib[64]. Finally, check if lit is running natively on
Android and don't use adb if so.
This implements commandline access on Windows by using the Windows Shell
API to access the commandline information and making it available in
Swift. This is needed for the correct invocation of the child process
in the unit tests.
* Unify the capitalization across all user-visible error messages (fatal errors, assertion failures, precondition failures) produced by the runtime, standard library and the compiler.
* Update some more tests to the new expectations.
When building for a pure windows environment, we build against a newer CRT which
does not provide direct access to __argc, __argv. They are hidden behind
macros which use a function call. Use the header (stdlib) to get access to
these rather than declaring them extern. This also makes the swift runtime more
portable across various Windows environments.
From stdlib.h in ucrt 10.0.10586.0:
#ifdef _CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
extern int __argc;
extern char** __argv;
#else
#define __argc (*__p___argc())
#define __argv (*__p___argv())
#endif
The indirection is particularly nice on COFF where all module external variables
are indirectly addressed.
Provides a new fallback for Process arguments for those instances where we do
not own main (e.g. Frameworks, Objective-C owns main.m or main.c, etc.). This
includes a number of platform-specific specializations of argument grabbing
logic and a new thread-safe interface to Process.unsafeArgv.
main() | _NSGetArgc/_NSGetArgv | /proc/self/cmdline | __argc/__argv
--------|--------------------------|------------------------|---------------
Scripts | OS X, iOS, tvOS, watchOS | Linux, FreeBSD, Cygwin | Windows
For interpreted Swift where we must filter out the arguments we now do so by
loading the standard library and calling into new SPI to override the arguments
that would have been grabbed by the runtime. This implementation completely
subsumes the use of the entry point '_stdlib_didEnterMain' and it will be
removed in a future commit.