datetime-fortran icon indicating copy to clipboard operation
datetime-fortran copied to clipboard

Force ar/ranlib to do a deterministic build.

Open harshula opened this issue 2 years ago • 2 comments

I noticed that datetime-fortran does not create deterministic builds. Details are documented in: https://github.com/ACCESS-NRI/ACCESS-OM/issues/8

harshula avatar Oct 13 '22 04:10 harshula

Thanks @harshula! Does ar on Xcode have a different option set? From the failed ci/mac job, it seems that ar there doesn't like -D

milancurcic avatar Oct 14 '22 15:10 milancurcic

Thanks @harshula! Does ar on Xcode have a different option set?

Sorry, I'm not familiar with Xcode.

harshula avatar Oct 15 '22 09:10 harshula

@scivision do you know what's the ar option for deterministic builds on macOS? -D doesn't seem to be it, but I also can't find an answer from an online search. See https://github.com/wavebitscientific/datetime-fortran/actions/runs/3261165880/jobs/5368639001

milancurcic avatar Oct 17 '22 14:10 milancurcic

Notes

https://gitlab.kitware.com/cmake/cmake/-/issues/19852

My current workaround is to set CMAKE__CREATE_STATIC_LIBRARY on macOS platforms to something along the lines of /usr/bin/xcrun libtool -static -D -o <TARGET> <LINK_FLAGS> <OBJECTS>, which seems to have the same effect, but it would be preferable if CMake had native libtool support instead of relying on xcrun.

&

You can also try setting ZERO_AR_DATE=1 in the environment. This is supported by older apple tools. It doesn't zero out the uid etc. in the .a, but it's better than nothing.

harshula avatar Nov 09 '22 22:11 harshula

Thanks. Either workaround is OK with me.

milancurcic avatar Nov 09 '22 23:11 milancurcic

Closing this as wontfix because:

  • On Linux, it appears that some distros are defaulting to building binutils with "--enable-deterministic-archives".
  • CMake should have a better mechanism to do this.

harshula avatar Jan 31 '23 04:01 harshula