temurin-build icon indicating copy to clipboard operation
temurin-build copied to clipboard

Reproducible builds on AIX

Open sxa opened this issue 2 years ago • 3 comments

We have reproducible build capability on Windows, Linux and MacOS now, but not AIX (Or Solaris). This issue will cover any investigation for AIX.

sxa avatar May 30 '23 13:05 sxa

The most important flag for reproducibilty is -qnotimestamps which stops the compiler from adding timestamps into the object files.

Unfortunately the linker still puts a timestamp into the object files starting from byte 5 in the file. I have spoken to IBM and apparently there is no easy way to inhibit this behaviour, so there will need to be some tweaks to the binaries (executables and shared libraries). This will include the shared libraries included in the jmods within the JDK which will need to be exploded and processed (I believe this is comparable to what we have to do on Windows platforms).

The following C code will squash the relevant bytes to enable comparisons:

#include <stdio.h>

int main(int argc, char *argv[])
{
   if (argc<2) {
     printf("Usage: aixtssquash <filename>\n");
     exit(1);
   }
   printf("Processing %s ... ", argv[1]);
   FILE *f;
   f = fopen(argv[1], "rb+");
   fseek(f, 4, SEEK_SET);
   printf("Replacing these four characters with nulls: %x%x%x%x\n", fgetc(f), fgetc(f), fgetc(f), fgetc(f));
   fseek(f, 4, SEEK_SET);
   fputc((char)0, f); fputc((char)0, f); fputc((char)0, f); fputc((char)0, f);
   fclose(f);
   return(0);
}

sxa avatar May 30 '23 14:05 sxa

FYI @andrew-m-leonard

sxa avatar May 30 '23 14:05 sxa

qnotimestamps update: This option was added to builds of JDK17+ on AIX here, tweaked here to prevent this issue, and the tweaked version is being tested here.

Update: The tweak failed. Changed and rerunning here.

Update 2: The above build seems to be working, but there are many instances of the warning below, which seems to defeat the point of the change:

warning: 1540-5200 The option "-qnotimestamp" is not supported.

So -qnotimestamp has become -qnotimestamps, and I tried again here. This seems to work much better.

adamfarley avatar Jun 05 '23 12:06 adamfarley