~mpu/qbe

qbe: fix build on FreeBSD v2 REJECTED

Lorenz (xha): 2
 fix build on FreeBSD
 fix build on FreeBSD

 5 files changed, 8 insertions(+), 8 deletions(-)
Roberto E. Vargas Caballero <k0ga@shike2.com>
Hi,
Next
Hi,
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mpu/qbe/patches/47323/mbox | git am -3
Learn more about email & git

[PATCH qbe v2] fix build on FreeBSD Export this patch

Signed-off-by: Lorenz (xha) <me@xha.li>
---
right, it's the freebsd build that's broken and not the openbsd one, sorry :D

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 3266c76..1ff1a60 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ OBJ      = $(COMMOBJ) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)

SRCALL   = $(OBJ:.o=.c)

CFLAGS   = -std=c99 -g -Wall -Wextra -Wpedantic
CFLAGS   = -g

qbe: $(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) -o $@
-- 
2.43.0
this breaks openbsd and linux builds. should've tested that.

i think my original diff is the best solution.

any ideas how to fix this?
Hi guys, I'm a bit late to the party as always.

Re: [PATCH qbe v2] fix build on FreeBSD Export this patch

On Wed, Dec 06, 2023 at 08:05:33AM +0100, Roberto E. Vargas Caballero wrote:
> In the case of OpenBSD I verified that it fails because it does
> not use c99 as value of CC and then it fails (that makes sense
> because OpenBSD does not ship a c99 tool). It is funny that while
> I checked this I realized that scc was also broken in OpenBSD
> for a similar problem.
> 
> Maybe it is a good moment to fix this issue in OpenBSD and get
> make does the correct thing when .POSIX is defined and include
> a c99 tool in the system.

yeah this should also be fixed but also FreeBSD seems to be the only
system actually following POSIX here. Linux and the other BSD's seem to
do the same. whatever.

the problem is not that the default standard is not c99, the problem is
that the symbol "asm" seems to be reserved (i think it's a OpenBSD
extension). the following should fix the build on FreeBSD while not
breaking it on OpenBSD. what do you think?

diff --git a/Makefile b/Makefile
index 3266c76..1ff1a60 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ OBJ      = $(COMMOBJ) $(AMD64OBJ) $(ARM64OBJ) $(RV64OBJ)

SRCALL   = $(OBJ:.o=.c)

CFLAGS   = -std=c99 -g -Wall -Wextra -Wpedantic
CFLAGS   = -g

qbe: $(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) -o $@
diff --git a/amd64/emit.c b/amd64/emit.c
index 297cc76..d77b193 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -60,7 +60,7 @@ enum {
static struct {
	short op;
	short cls;
	char *asm;
	char *asmb;
} omap[] = {
	{ Oadd,    Ka, "+add%k %1, %=" },
	{ Osub,    Ka, "-sub%k %1, %=" },
@@ -393,7 +393,7 @@ emitins(Ins i, Fn *fn, FILE *f)
			|| (omap[o].cls == Ka))
				break;
		}
		emitf(omap[o].asm, &i, fn, f);
		emitf(omap[o].asmb, &i, fn, f);
		break;
	case Onop:
		/* just do nothing for nops, they are inserted
diff --git a/arm64/emit.c b/arm64/emit.c
index 78a0358..ce1dafe 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -37,7 +37,7 @@ enum {
static struct {
	short op;
	short cls;
	char *asm;
	char *asmb;
} omap[] = {
	{ Oadd,    Ki, "add %=, %0, %1" },
	{ Oadd,    Ka, "fadd %=, %0, %1" },
@@ -374,7 +374,7 @@ emitins(Ins *i, E *e)
			|| (omap[o].cls == Ki && KBASE(i->cls) == 0))
				break;
		}
		emitf(omap[o].asm, i, e);
		emitf(omap[o].asmb, i, e);
		break;
	case Onop:
		break;
diff --git a/rv64/emit.c b/rv64/emit.c
index 23a8be8..a8bb5f0 100644
--- a/rv64/emit.c
+++ b/rv64/emit.c
@@ -8,7 +8,7 @@ enum {
static struct {
	short op;
	short cls;
	char *asm;
	char *asmb;
} omap[] = {
	{ Oadd,    Ki, "add%k %=, %0, %1" },
	{ Oadd,    Ka, "fadd.%k %=, %0, %1" },
@@ -326,7 +326,7 @@ emitins(Ins *i, Fn *fn, FILE *f)
			|| (omap[o].cls == Ki && KBASE(i->cls) == 0))
				break;
		}
		emitf(omap[o].asm, i, fn, f);
		emitf(omap[o].asmb, i, fn, f);
		break;
	case Ocopy:
		if (req(i->to, i->arg[0]))