Repository navigation
Emulate GNU ar's deterministic mode - #1537
Conversation
There was a problem hiding this comment.
I forget, don't we already have utilities to create a temporary filename that's guaranteed to not be used?
There was a problem hiding this comment.
I think I saw one. I'll look into using some existing thing, but I remembered it giving a file Handle which I don't need, and I wasn't sure if I could just hClose it. (Also it should preferably be on the same FS as target.)
There was a problem hiding this comment.
I eventually realised withTempFile (& cetera) was just too painful to use and ended up with withTempDirectory instead.
|
@liyang It would have been nicer if you had created another commit instead of amending my ones; I can't easily look at what's changed compared to my version this ways, or comment on it. Would you mind changing? |
|
@liyang I'm aware. It still attributes code which I did not write to me (!), and as I said, forbids me to make github comments on what you changed since my last proposal. |
|
@nh2 I essentially rewrote the whole thing. At the time, it seemed like a choice between crediting[0] you for the original code or just claiming that I wrote everything. (I generally dislike including refactors of earlier commits in a feature branch.) Okay, I'll rebase my refactor on top of your original when I get in to work on Monday. [0] Or blaming. ;) |
|
Much appreciated! |
|
I think I've addressed most of the issues mentioned earlier. The one remaining task is to test this on Windows and OS X (and FreeBSD? I have never used FreeBSD. Someone else will have to do this, or we just trust Wikipedia.) |
|
On OS X (with Homebrew removed from However I noticed that the metadata for the symbol table (first entry in Haven't checked with Homebrew enabled yet. Will look at Windows when I'm home. (Windows GHC uses mingw32 and GNU tools, so I don't foresee any compatibility problems there.) |
|
@liyang Thanks for doing that work. |
|
How embarrassing. Under Windows I actually got some Checking OS X (with and without Homebrew (again)) now. |
…X ld issues ∙ At one point under OS X ld required that the mtime of the symbol table to be not older than that of the archive itself. This means that even copying an .a file required invoking ranlib to update the symbol table mtime. ∙ However running ranlib renders pointless the deterministic mode of haskell#1537. ∙ As of at least 2008 according to the BUGS section of ranlib(1), this has no longer been necessary. First introduction: 12b3590 Current implementation: af3da76
|
See comments for the latest commit. Under OS X, I managed to install I think it's time to ship now. |
|
Any chance we can add a test so we don't accidentally break this feature in the future? |
|
Break which aspect of this feature? Could you be more specific? I could add a test that builds a simple archive and checks that all the metadata in the headers are as expected, but I'm not sure what kind of breakage this would help to protect against. |
|
@liyang Well, having at least some tests is better than no tests at all. |
…X ld issues ∙ At one point under OS X, ld required the mtime of the symbol table to be not older than that of the archive itself. This means that even copying an .a file required invoking ranlib to update the symbol table mtime. ∙ However running ranlib renders pointless the deterministic mode of haskell#1537. ∙ As of at least 2008 according to the BUGS section of ranlib(1), this has no longer been necessary. First introduction: 12b3590 Current implementation: af3da76
We need them to compare against, so that we can decide if we want to write new files or keep the old ones untouched.
We do this by not putting timestamps into the .a file, and not touching it if is already there and the contents are the same.
After invoking ar(1), replace each object file's metadata with zero for the mtime, UID and GID, and 0644 for the file mode. Do not touch the existing archive if the contents are the same. This rewrites the previous patch to, ∙ also wipe UID, GID and file mode; ∙ do a single read/write for each header, and less seeking in general; ∙ do its work inside a temporary directory, via 'withTempDirectory'; ∘ Which also deletes the temporary target when it's identical to the old. ∙ use Distribution.Compat.CopyFile.filesEqual; ∙ use the standard 'dieWithLocation' instead of invoking 'error'.
…X ld issues ∙ At one point under OS X, ld required the mtime of the symbol table to be not older than that of the archive itself. This means that even copying an .a file required invoking ranlib to update the symbol table mtime. ∙ However running ranlib renders pointless the deterministic mode of haskell#1537. ∙ As of at least 2008 according to the BUGS section of ranlib(1), this has no longer been necessary. First introduction: 12b3590 Current implementation: af3da76
|
Sorry for taking so long over this, had been busy with other things. The latest commit builds and installs a dummy library and checks that the resulting archives in both the I've tested this test by commenting out the call to Does it look good to merge now? |
There was a problem hiding this comment.
How can assertFailure fail? In other words: why does this function exist?
There was a problem hiding this comment.
It can't, but it has the type Assertion = IO () whereas I wanted a polymorphic IO a. If you like, I can rewrite it as:
assertFailure' msg = assertFailure msg >> return {-unpossible!-}undefinedand add a comment--I thought it was obvious what it was doing but maybe it's not.
|
One comment. Looks good to merge otherwise. |
|
Hi guys, This seems to be crashing me when using cabal with GHC iOS: I'm using the arm scripts from https://github.com/ghc-ios/ghc-ios-scripts. Happy to help debug, or we can just skip this optimization if the metadata can't be parsed? |
The Could you check if your |
|
@lukexi I've disabled this behaviour on ARM for now. Please tell whether my patch fixed the problem. |
|
Hi Mikhail, On Jan 29, 2014, at 4:02 PM, Mikhail Glushenkov [email protected] wrote:
|
|
Thanks. Would be nice to know why it broke in the first place. |
After invoking ar(1), replace each object file's metadata with zero for the mtime, UID and GID, and 0644 for the file mode. Do not touch the existing archive if the contents are the same.
Relevant discussion in #1177; we can probably close the previous attempts in #1410 and #1501.
@nh2 originally wrote this but he disappeared. We would like to see this in production eventually, so I cleaned it up and added more sanity checks.