commit 631357bb9184f76227d82dab74144118aaca3ad0
parent d4f4e7c5a2f250095e5bb85c8e260d91475d3e32
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 16 Mar 2023 02:52:21 +0100
driver/posix: Add template for assembler cmd
Having a template for as allows to support non conforming assemblers
like for example clang using the option -x assembler.
Diffstat:
4 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/include/scc/scc/sys-musl.h b/include/scc/scc/sys-musl.h
@@ -1,3 +1,6 @@
+#define LDBIN "ld"
+#define ASBIN "as"
+
/* configure below your standard sys include paths */
char *sysincludes[] = {
"%p/include/",
@@ -25,3 +28,9 @@ char *ldcmd[] = {
"-lgcc_eh",
NULL
};
+
+/* configure below your system assembler command line */
+char *ascmd[] = {
+ "-o", "%o"
+ NULL
+};
diff --git a/include/scc/scc/sys-scc.h b/include/scc/scc/sys-scc.h
@@ -1,3 +1,6 @@
+#define LDBIN "ld"
+#define ASBIN "as"
+
/* configure below your standard sys include paths */
char *sysincludes[] = {
"%p/include/bits/%a/",
@@ -20,3 +23,9 @@ char *ldcmd[] = {
"-lcrt",
NULL
};
+
+/* configure below your system assembler command line */
+char *ascmd[] = {
+ "-o", "%o",
+ NULL
+};
diff --git a/include/scc/scc/sys-scc_clang.h b/include/scc/scc/sys-scc_clang.h
@@ -0,0 +1,34 @@
+#define LDBIN "ld"
+#define ASBIN "clang"
+
+/* configure below your standard sys include paths */
+char *sysincludes[] = {
+ "%p/include/bits/%a/",
+ "%p/include/bits/%s/",
+ "%p/include/bits/%s/%a/",
+ "%p/include/",
+ NULL
+};
+
+/* configure below your system linker command line */
+char *ldcmd[] = {
+ "-static",
+ "-z","nodefaultlib",
+ %NOPIE%
+ "-o","%o",
+ "-L","%p/lib/scc/%a-%s",
+ "%p/lib/scc/%a-%s/crt.o",
+ "%c",
+ "-lc",
+ "-lcrt",
+ NULL
+};
+
+/* configure below your system assembler command line */
+char *ascmd[] = {
+ "-x","assembler",
+ "-c",
+ "-o","%o",
+ "-",
+ NULL
+};
diff --git a/src/cmd/cc/posix/cc.c b/src/cmd/cc/posix/cc.c
@@ -56,8 +56,8 @@ static struct tool {
[TEEQBE] = {.bin = "tee"},
[QBE] = {.bin = "qbe"},
[TEEAS] = {.bin = "tee"},
- [AS] = {.bin = "as"},
- [LD] = {.bin = "ld"},
+ [AS] = {.bin = ASBIN},
+ [LD] = {.bin = LDBIN},
};
char *argv0;
@@ -139,7 +139,7 @@ addarg(int tool, char *arg)
p = abi;
break;
case 'o':
- p = outfile;
+ p = t->outfile;
break;
default:
buff[cnt++] = *arg;
@@ -244,6 +244,8 @@ settool(int tool, char *infile, int nexttool)
die("scc-cc: target tool path is too long");
break;
case LD:
+ if (!outfile)
+ outfile = "a.out";
t->outfile = xstrdup(outfile);
if (gflag)
addarg(tool, "-g");
@@ -274,8 +276,9 @@ settool(int tool, char *infile, int nexttool)
t->outfile = xstrdup(objfile);
if (gflag)
addarg(tool, "-g");
- addarg(tool, "-o");
- addarg(tool, t->outfile);
+ for (n = 0; ascmd[n]; n++)
+ addarg(tool, ascmd[n]);
+ break;
break;
default:
break;
@@ -657,9 +660,6 @@ operand:
fputs("scc-cc: could not open /dev/null\n", stderr);
}
- if (!outfile)
- outfile = "a.out";
-
if (!(tmpdir = getenv("TMPDIR")) || !tmpdir[0])
tmpdir = ".";
tmpdirln = strlen(tmpdir);