ref: b379ffb5538031f6bc18b5e18c4f7292fd624627
parent: ab6baaad01837cda74039cf85019aaf789d1f5cc
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Oct 13 18:08:00 EDT 2021
driver/posix: Install Qbe in libexec Having Qbe in libexec makes possible for the user to have a system version and the scc version.
--- a/scripts/proto.all
+++ b/scripts/proto.all
@@ -2,7 +2,6 @@
f 755 bin/ld
f 755 bin/cpp
f 755 bin/cc
-f 755 bin/qbe
f 755 bin/nm
f 755 bin/objdump
f 755 bin/addr2line
@@ -25,6 +24,7 @@
f 755 libexec/scc/cc2-amd64-sysv
f 755 libexec/scc/cc2-z80-scc
f 755 libexec/scc/as-z80
+f 755 libexec/qbe
d 755 include
f 644 include/string.h
f 644 include/wchar.h
--- a/src/cmd/Makefile
+++ b/src/cmd/Makefile
@@ -18,7 +18,7 @@
$(BINDIR)/objdump\
$(BINDIR)/objcopy\
$(BINDIR)/addr2line\
- $(BINDIR)/qbe\
+ $(LIBEXEC)/scc/qbe\
all: $(TARGET) $(DIRS)
@@ -30,7 +30,7 @@
qbe/obj/qbe: qbe
-$(BINDIR)/qbe: qbe/obj/qbe
+$(LIBEXEC)/scc/qbe: qbe/obj/qbe
cp qbe/obj/qbe $@
$(BINDIR)/nm: nm.o $(LIBMACH) $(LIBSCC)
--- a/src/cmd/cc/posix/cc.c
+++ b/src/cmd/cc/posix/cc.c
@@ -57,7 +57,7 @@
[TEEIR] = {.bin = "tee", .cmd = "tee"},
[CC2] = {.cmd = "cc2"},
[TEEQBE] = {.bin = "tee", .cmd = "tee"},
- [QBE] = {.bin = "qbe", .cmd = "qbe"},
+ [QBE] = {.bin = "qbe"},
[TEEAS] = {.bin = "tee", .cmd = "tee"},
[AS] = {.bin = "as", .cmd = "as"},
[LD] = {.bin = "ld", .cmd = "ld"},
@@ -183,12 +183,12 @@
case CC2:
fmt = cc12fmt(tool);
n = snprintf(t->bin, sizeof(t->bin), fmt, t->cmd, arch, abi);
- if (n < 0 || n >= sizeof(t->bin))
+ if (n >= sizeof(t->bin))
die("cc: target tool name is too long");
-
+ case QBE:
n = snprintf(t->cmd, sizeof(t->cmd),
"%s/libexec/scc/%s", prefix, t->bin);
- if (n < 0 || n >= sizeof(t->cmd))
+ if (n >= sizeof(t->cmd))
die("cc: target tool path is too long");
break;
case LD:
@@ -242,7 +242,7 @@
newsz = pathln + 1 + strlen(type) + 1;
new = xmalloc(newsz);
n = snprintf(new, newsz, "%.*s%c%s", (int)pathln, path, sep, type);
- if (n < 0 || n >= newsz)
+ if (n >= newsz)
die("cc: wrong output filename");
if (sep == '/') {
if ((tmpfd = mkstemp(new)) < 0)