aboutsummaryrefslogtreecommitdiff
path: root/driver.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-06-25 11:34:29 -0700
committerMichael Forney <mforney@mforney.org>2019-06-27 16:32:49 -0700
commit2afeff7d9e6a0a735f80bae9e932df376bc42590 (patch)
treec31df9ef60a94652aa2f1a52587800e4d5f1c9a5 /driver.c
parentb237b938d0e10da65f951ed64e7e38ae5926c804 (diff)
Pass target to cc-qbe
Diffstat (limited to 'driver.c')
-rw-r--r--driver.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/driver.c b/driver.c
index 9d48ce6..b334f38 100644
--- a/driver.c
+++ b/driver.c
@@ -347,11 +347,17 @@ compilecommand(char *arg)
return cmd;
}
+static int
+hasprefix(const char *str, const char *pfx)
+{
+ return memcmp(str, pfx, strlen(pfx)) == 0;
+}
+
int
main(int argc, char *argv[])
{
enum phaseid first = 0, last = LINK;
- char *arg, *end, *output = NULL;
+ char *arg, *end, *output = NULL, *arch, *qbearch;
struct array inputs = {0}, *cmd;
struct input *input;
size_t i;
@@ -362,6 +368,18 @@ main(int argc, char *argv[])
arrayaddbuf(&phases[ASSEMBLE].cmd, assemblecmd, sizeof(assemblecmd));
arrayaddbuf(&phases[LINK].cmd, linkcmd, sizeof(linkcmd));
+ if (hasprefix(target, "x86_64-") || hasprefix(target, "amd64-")) {
+ arch = "x86_64";
+ qbearch = "amd64_sysv";
+ } else if (hasprefix(target, "aarch64-")) {
+ arch = "aarch64";
+ qbearch = "arm64";
+ }
+ arrayaddptr(&phases[COMPILE].cmd, "-t");
+ arrayaddptr(&phases[COMPILE].cmd, arch);
+ arrayaddptr(&phases[CODEGEN].cmd, "-t");
+ arrayaddptr(&phases[CODEGEN].cmd, qbearch);
+
argv0 = progname(argv[0], "cc");
for (;;) {
++argv, --argc;