~mpu/qbe

add extern linkage v1 REJECTED

dangermouseb: 1
 add extern linkage

 3 files changed, 33 insertions(+), 12 deletions(-)
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/41213/mbox | git am -3
Learn more about email & git

[PATCH] add extern linkage Export this patch

Patch for potential extern linkage keyword for macOS aarch64


diff --git a/all.h b/all.h
index 3c68bbc..b6bf733 100644
--- a/all.h
+++ b/all.h
@@ -276,7 +276,8 @@ struct Use {
struct Sym {
	enum {
		SGlo,
		SThr,
        SThr,
        SExt,
	} type;
	uint32_t id;
};
@@ -363,7 +364,8 @@ struct Addr { /* amd64 addressing */

struct Lnk {
	char export;
	char thread;
    char thread;
    char ext;
	char align;
	char *sec;
	char *secf;
diff --git a/arm64/emit.c b/arm64/emit.c
index ee1593f..5183a0f 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -269,6 +269,13 @@ loadaddr(Con *c, char *rn, E *e)
			    "\tadd\tR, R, #:tprel_hi12:SO, lsl #12\n"
			    "\tadd\tR, R, #:tprel_lo12_nc:SO\n";
		break;
    case SExt:
        if (T.apple)
            s = "\tadrp\tR, S@gotpage\n"
                "\tldr\tR, [R, S@gotpageoff]\n";
        else
            die("nyi");
        break;
	}

	l = str(c->sym.id);
@@ -436,7 +443,7 @@ emitins(Ins *i, E *e)
		if (c->type != CAddr
		|| c->sym.type != SGlo
		|| c->bits.i)
			die("invalid call argument");
			die("invalid call argument %d, %d, %d", c->type, c->sym.type, c->bits.i);
		l = str(c->sym.id);
		p = l[0] == '"' ? "" : T.assym;
		fprintf(e->f, "\tbl\t%s%s\n", p, l);
diff --git a/parse.c b/parse.c
index c54448f..d38acea 100644
--- a/parse.c
+++ b/parse.c
@@ -47,7 +47,8 @@ enum Token {
	Tret,
	Thlt,
	Texport,
	Tthread,
    Tthread,
    Textern,
	Tfunc,
	Ttype,
	Tdata,
@@ -104,7 +105,8 @@ static char *kwmap[Ntok] = {
	[Tret] = "ret",
	[Thlt] = "hlt",
	[Texport] = "export",
	[Tthread] = "thread",
    [Tthread] = "thread",
    [Textern] = "extern",
	[Tfunc] = "function",
	[Ttype] = "type",
	[Tdata] = "data",
@@ -423,11 +425,16 @@ parseref()
		c.bits.d = tokval.fltd;
		c.flt = 2;
		break;
	case Tthread:
		c.sym.type = SThr;
		expect(Tglo);
		/* fall through */
    case Tthread:
        c.sym.type = SThr;
        expect(Tglo);
        goto glo;
    case Textern:
        c.sym.type = SExt;
        expect(Tglo);
        /* fall through */
	case Tglo:
    glo:
		c.type = CAddr;
		c.sym.id = intern(tokval.str);
		break;
@@ -1136,9 +1143,12 @@ parselnk(Lnk *lnk)
		case Texport:
			lnk->export = 1;
			break;
		case Tthread:
			lnk->thread = 1;
			break;
        case Tthread:
            lnk->thread = 1;
            break;
        case Textern:
            lnk->ext = 1;
            break;
		case Tsection:
			if (lnk->sec)
				err("only one section allowed");
@@ -1205,6 +1215,8 @@ printcon(Con *c, FILE *f)
	case CAddr:
		if (c->sym.type == SThr)
			fprintf(f, "thread ");
        if (c->sym.type == SExt)
            fprintf(f, "extern ");
		fprintf(f, "$%s", str(c->sym.id));
		if (c->bits.i)
			fprintf(f, "%+"PRIi64, c->bits.i);