more efficient builtin library code generation

* introduce --disable-pic option which can generally be allowed to be
   the default. compiler_rt.a and builtin.a get this option when you
   build a static executable.
 * compiler_rt and builtin libraries are not built for build-lib
   --static
 * posix_spawn instead of fork/execv
 * disable the error limit on LLD. Fixes the blank lines printed
This commit is contained in:
Andrew Kelley
2018-10-09 12:18:09 -04:00
parent 5a3c02137e
commit 6b93495792
5 changed files with 44 additions and 28 deletions

View File

@@ -46,6 +46,7 @@ typedef SSIZE_T ssize_t;
#include <sys/wait.h>
#include <fcntl.h>
#include <limits.h>
#include <spawn.h>
#endif
@@ -88,25 +89,22 @@ static void populate_termination(Termination *term, int status) {
}
static void os_spawn_process_posix(const char *exe, ZigList<const char *> &args, Termination *term) {
pid_t pid = fork();
if (pid == -1)
zig_panic("fork failed: %s", strerror(errno));
if (pid == 0) {
// child
const char **argv = allocate<const char *>(args.length + 2);
argv[0] = exe;
argv[args.length + 1] = nullptr;
for (size_t i = 0; i < args.length; i += 1) {
argv[i + 1] = args.at(i);
}
execvp(exe, const_cast<char * const *>(argv));
zig_panic("execvp failed: %s", strerror(errno));
} else {
// parent
int status;
waitpid(pid, &status, 0);
populate_termination(term, status);
const char **argv = allocate<const char *>(args.length + 2);
argv[0] = exe;
argv[args.length + 1] = nullptr;
for (size_t i = 0; i < args.length; i += 1) {
argv[i + 1] = args.at(i);
}
pid_t pid;
int rc = posix_spawn(&pid, exe, nullptr, nullptr, const_cast<char *const*>(argv), environ);
if (rc != 0) {
zig_panic("posix_spawn failed: %s", strerror(rc));
}
int status;
waitpid(pid, &status, 0);
populate_termination(term, status);
}
#endif