Problem with clang on Windows

85 views
Skip to first unread message

oven...@gmail.com

unread,
Aug 11, 2018, 1:47:19 AM8/11/18
to tup-users
I'm excited to use tup for a new project but I'm having trouble getting it to work in a simple situation on Windows.  I'm trying to compile a single "hello world" C file with clang and there seems to be a problem with tup not understanding some of clang's temporary files.

Here's the C file:

#include <stdio.h>

int main(int argc, char** argv) {
    printf("hello\n");
    return 0;
}

Here's the Tupfile:

: main.c |> clang -c %f -o %o |> main.o
: main.o |> clang -o %o %f |> main.exe

Here's the output:
 
* 1) clang -c main.c -o main.o
 *** tup errors ***
tup error: File 'C:\test\main-645c19a0.o.tmp' was written to, but is not in .tup/db. You probably should specify it as an output
 -- Delete: C:\test\main-645c19a0.o.tmp
tup error: Expected to write to file 'main.o' from cmd 20 but didn't
 *** Command failed due to errors processing the output dependencies.
 [  ]  50%
 *** tup: 1 job failed.

However, there is a main.o file in the directory after tup exits.  I've tried running the commands on the command line and they work okay.  I've observed the issue when using both 32 bit and 64 bit clang.  This is all on tup v0.7.6-33-g221ae9a on Windows 10.  Everything works fine on a unix based system.  Any help or workarounds would be appreciated!

Erik Brinkman

unread,
Aug 12, 2018, 11:43:43 AM8/12/18
to tup-...@googlegroups.com
The short answer is that tup wants to know about all build artifacts, and thus, every output file must be specified. I don't know much about clang's side effects, but I guess on Windows it leaves this tmp file around. You'll need to account for that with your build command.

The easiest way is probably a flag to tell clang to not write it. If that doesn't exist, you can try removing it after the command runs (rm -f *.o.tmp in shell, but I don't know a good cross platform command that operates silently if the file is missing).

If neither of those works, then more information about what you want to do would be useful.

Hope that helps!
Erik

--
--
tup-users mailing list
email: tup-...@googlegroups.com
unsubscribe: tup-users+...@googlegroups.com
options: http://groups.google.com/group/tup-users?hl=en
---
You received this message because you are subscribed to the Google Groups "tup-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tup-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Shal

unread,
Aug 12, 2018, 11:27:31 PM8/12/18
to tup-...@googlegroups.com
Ahh it looks like in this case clang writes to main-XYZ.o.tmp and then calls NtSetInformationFile with a FILE_RENAME_INFORMATION to tell it to rename the file, and tup didn't have a hook for this function. (We already hook the various MoveFile* and ReplaceFile* functions, but apparently we need another way to rename files :)

Can you try http://gittup.org/tup/win32/tup-v0.7.7-8-gf77dbd4.zip and let me know if that helps? I was only able to get clang working as a compiler (ie: clang -c foo.c -o foo.o), but I couldn't get it to link anything even without tup in the mix.

-Mike

oven...@gmail.com

unread,
Aug 13, 2018, 10:25:24 PM8/13/18
to tup-users
That new version works great, thank you!

btw, I didn't find any flags to tell clang to avoid creating those temporary files.
Reply all
Reply to author
Forward
0 new messages