I've noticed that swiftc may not update the modification time of outputs after successfully compiling. In the example below, foo.o has the same modification time after a compile even though the input file has been touched. The source file ends up with a modification time later than the object file at the end.
Was that the intended behaviour? It makes any kind of build dependency tracking (via make, ninja etc) a bit of a pain. It's easy enough to touch the files afterwards but it's kind of odd.
$ swiftc -frontend -o foo.o -emit-object foo.swift -target x86_64-apple-macosx10.15 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
$ stat foo.o
File: foo.o
Size: 2840 Blocks: 8 IO Block: 4096 regular file
Device: 1000004h/16777220d Inode: 8679820584 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 501/ krister) Gid: ( 20/ staff)
Access: 2019-10-17 15:41:20.769490519 +0800
Modify: 2019-10-17 15:41:20.772221926 +0800
Change: 2019-10-17 15:41:20.772221926 +0800
Birth: 2019-10-17 15:41:20.769490519 +0800
$ touch foo.swift
$ swiftc -frontend -o foo.o -emit-object foo.swift -target x86_64-apple-macosx10.15 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
$ stat foo.o
File: foo.o
Size: 2840 Blocks: 8 IO Block: 4096 regular file
Device: 1000004h/16777220d Inode: 8679820584 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 501/ krister) Gid: ( 20/ staff)
Access: 2019-10-17 15:41:31.555112097 +0800
Modify: 2019-10-17 15:41:20.772221926 +0800
Change: 2019-10-17 15:41:20.772221926 +0800
Birth: 2019-10-17 15:41:20.769490519 +0800
$ stat foo.swift
File: foo.swift
Size: 36 Blocks: 8 IO Block: 4096 regular file
Device: 1000004h/16777220d Inode: 8679669012 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 501/ krister) Gid: ( 20/ staff)
Access: 2019-10-17 15:41:27.991699000 +0800
Modify: 2019-10-17 15:41:27.991699000 +0800
Change: 2019-10-17 15:41:27.991715976 +0800
Birth: 2019-10-16 19:52:23.072205698 +0800
jrose
(Jordan Rose)
2
Yep, this is intended behavior when the output hasn't changed. It's supposed to help make/ninja-style dependency tracking by allowing downstream files to not be recompiled/relinked, but maybe we should have a flag to turn it off since it means the intermediate steps still look out of date.
(Also, I notice you're using frontend commands directly, so please take a look at docs/Driver.md if you haven't already and you're doing that in production somewhere!)
3 Likes