scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 0e40771ad18251665afbef90eaaeeb28bfaa1522
parent 813bc56a038cc8699ebe923e19cf09caaf51eb5a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 13 Oct 2021 22:08:00 +0200

driver/posix: Install Qbe in libexec

Having Qbe in libexec makes possible for the user
to have a system version and the scc version.

Diffstat:
Mscripts/proto.all | 2+-
Msrc/cmd/Makefile | 4++--
Msrc/cmd/cc/posix/cc.c | 10+++++-----
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/scripts/proto.all b/scripts/proto.all @@ -2,7 +2,6 @@ d 755 bin 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/as-amd64 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 diff --git a/src/cmd/Makefile b/src/cmd/Makefile @@ -18,7 +18,7 @@ TARGET =\ $(BINDIR)/objdump\ $(BINDIR)/objcopy\ $(BINDIR)/addr2line\ - $(BINDIR)/qbe\ + $(LIBEXEC)/scc/qbe\ all: $(TARGET) $(DIRS) @@ -30,7 +30,7 @@ qbe/.git: 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) diff --git a/src/cmd/cc/posix/cc.c b/src/cmd/cc/posix/cc.c @@ -57,7 +57,7 @@ static struct tool { [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 @@ inittool(int tool) 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 @@ outfname(char *path, char *type) 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)