ref: c435ace1e7d11f4db85989b764021b5e701ddf53
parent: 685c15128166e0388a3658d430f36caa6cf2de34
author: Quentin Rameau <quinq@fifth.space>
date: Mon Jan 23 09:31:04 EST 2017
[driver] add support for custom runtime libexec path Now scc will lookup the env for SCCEXECPATH and search there for exec lib tools.
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -38,9 +38,9 @@
int in, out, init;
pid_t pid;
} tools[] = {
- [CC1] = { .bin = "cc1", .cmd = PREFIX "/libexec/scc/", },
+ [CC1] = { .bin = "cc1" },
[TEEIR] = { .bin = "tee", .cmd = "tee", },
- [CC2] = { .bin = "cc2", .cmd = PREFIX "/libexec/scc/", },
+ [CC2] = { .bin = "cc2" },
[TEEQBE] = { .bin = "tee", .cmd = "tee", },
[QBE] = { .bin = "qbe", .cmd = "qbe", },
[TEEAS] = { .bin = "tee", .cmd = "tee", },
@@ -50,7 +50,7 @@
};
char *argv0;
-static char *arch, *objfile, *outfile;
+static char *arch, *execpath, *objfile, *outfile;
static char *tmpdir;
static size_t tmpdirln;
static struct items objtmp, objout;
@@ -114,9 +114,11 @@
die("scc: target tool bin too long");
binln = strlen(t->bin);
- if (strlen(t->cmd) + binln + 1 > sizeof(t->cmd))
+ if (!execpath)
+ execpath = PREFIX "/libexec/scc";
+ n = snprintf(t->cmd, sizeof(t->cmd), "%s/%s", execpath, t->bin);
+ if (n < 0 || n >= sizeof(t->cmd))
die("scc: target tool path too long");
- strcat(t->cmd, t->bin);
break;
case LD:
addarg(tool, "-no-pie");
@@ -425,6 +427,7 @@
atexit(terminate);
arch = getenv("ARCH");
+ execpath = getenv("SCCEXECPATH");
ARGBEGIN {
case 'D':