
Hello, If I compile my source code two time I would like to get the same binary. But currently when I run echo "main = return ()" > c.hs && ghc -fforce-recomp c.hs && xxd c > c1.hex && ghc -fforce-recomp c.hs && xxd c > c2.hex && diff c1.hex c2.hex my output is [1 of 1] Compiling Main ( c.hs, c.o ) Linking c ... [1 of 1] Compiling Main ( c.hs, c.o ) Linking c ... 55494c55494 < 00d8c50: 7400 6768 6333 3130 3830 5f30 2e63 0073 t.ghc31080_0.c.s ---
00d8c50: 7400 6768 6333 3130 3935 5f30 2e63 0073 t.ghc31095_0.c.s
So why does the binary differ? Is there a way to compile with ghc and get the same binary? Even though only one byte differ, the checksum (sha,md5,..) is completely changed... I'm running Linux and ghc 7.6.3. Regards, Joakim

On Tue, Mar 11, 2014 at 3:27 AM,
< 00d8c50: 7400 6768 6333 3130 3830 5f30 2e63 0073 t.ghc31080_0.c.s
---
00d8c50: 7400 6768 6333 3130 3935 5f30 2e63 0073 t.ghc31095_0.c.s
So why does the binary differ? Is there a way to compile with ghc and get the same binary?
That's a filename symbol in the debug info. Using a deterministic filename has potential problems, although I note that it's still fairly deterministic anyway. A C compile that uses temporary files will also have symbols that change this way (usually referring to assembler temporary files). There is not a lot to be done about this, as you're at cross purposes with the system linker and with people who want to be able to debug programs. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

There is a GHC bug dealing with such things: https://ghc.haskell.org/trac/ghc/ticket/4012

Thank you, that works fine for me! Från: Marc Ziegert [mailto:Coeus@gmx.de] Skickat: den 12 mars 2014 00:39 Till: Joakim Goldkuhl Kopia: haskell-cafe@haskell.org Ämne: Aw: [Haskell-cafe] pure ghc that time stamp is generated at link time, not compile time. to remove it, simply use the "strip" tool: echo "main = return ()" > c.hs && ghc -fforce-recomp c.hs && mv c c1 && ghc -fforce-recomp c.hs && mv c c2 && md5sum c1 c2 && strip c1 c2 && md5sum c1 c2 Gesendet: Dienstag, 11. März 2014 um 08:27 Uhr Von: joakim@comex.semailto:joakim@comex.se An: haskell-cafe@haskell.orgmailto:haskell-cafe@haskell.org Betreff: [Haskell-cafe] pure ghc Hello, If I compile my source code two time I would like to get the same binary. But currently when I run echo "main = return ()" > c.hs && ghc -fforce-recomp c.hs && xxd c > c1.hex && ghc -fforce-recomp c.hs && xxd c > c2.hex && diff c1.hex c2.hex my output is [1 of 1] Compiling Main ( c.hs, c.o ) Linking c ... [1 of 1] Compiling Main ( c.hs, c.o ) Linking c ... 55494c55494 < 00d8c50: 7400 6768 6333 3130 3830 5f30 2e63 0073 t.ghc31080_0.c.s ---
00d8c50: 7400 6768 6333 3130 3935 5f30 2e63 0073 t.ghc31095_0.c.s
So why does the binary differ? Is there a way to compile with ghc and get the same binary? Even though only one byte differ, the checksum (sha,md5,..) is completely changed… I’m running Linux and ghc 7.6.3. Regards, Joakim _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.orgmailto:Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Brandon Allbery
-
joakim@comex.se
-
Marc Ziegert
-
Niklas Hambüchen