Skip to content

Commit

Permalink
Log cuda build command to stderr
Browse files Browse the repository at this point in the history
See #19
  • Loading branch information
jart committed Dec 2, 2023
1 parent 68f5622 commit ccc377e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions llamafile/cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,31 @@ static bool CreateTempPath(const char *path, char tmp[static PATH_MAX]) {
}
}

static void LogCommand(char *args[]) {
for (int i = 0; args[i]; ++i) {
if (i) {
tinyprint(2, " ", NULL);
}
// this quoting should be close enough to correct to be
// copy/pastable on both unix and windows command terms
bool need_quotes = !!strchr(args[i], ' ');
if (need_quotes) {
tinyprint(2, "\"", NULL);
}
tinyprint(2, args[i], NULL);
if (need_quotes) {
tinyprint(2, "\"", NULL);
}
}
tinyprint(2, "\n", NULL);
}

static bool Compile(const char *src,
const char *tmp,
const char *out,
char *args[]) {
int pid, ws;
LogCommand(args);
errno_t err = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
if (err) {
perror(args[0]);
Expand Down

0 comments on commit ccc377e

Please sign in to comment.