diff options
author | Michael Forney <mforney@mforney.org> | 2019-06-25 11:34:29 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-06-27 16:32:49 -0700 |
commit | 2afeff7d9e6a0a735f80bae9e932df376bc42590 (patch) | |
tree | c31df9ef60a94652aa2f1a52587800e4d5f1c9a5 /driver.c | |
parent | b237b938d0e10da65f951ed64e7e38ae5926c804 (diff) |
Pass target to cc-qbe
Diffstat (limited to 'driver.c')
-rw-r--r-- | driver.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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; |