From fe0bb59baa2ad3184a928b3d335cd69682a263e7 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Fri, 8 Jul 2022 14:35:40 +0200 Subject: [PATCH 1/8] do not include -lrt or -ldl on platform that do not support them Some platforms were already listed, this includes OpenBSD to the list and makes it easier to add more. (cherry picked from commit b6c0b36c8aa0a181a541a8cc4320ebde938a0fe0) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6780c3571..bb62f14a1 100644 --- a/Makefile +++ b/Makefile @@ -137,11 +137,11 @@ endif # LIBS := -ldl -lrt LIBS += -lm -ifneq ($(OS), FreeBSD) +ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD)) LIBS += -ldl endif -ifneq ($(findstring Darwin, $(shell uname)), Darwin) +ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD Darwin)) LIBS += -lrt endif From f5f317d7d24a5abdf4e576948e0cdd7acd83bcf2 Mon Sep 17 00:00:00 2001 From: Jason Thorpe Date: Sun, 3 Mar 2024 08:02:41 -0800 Subject: [PATCH 2/8] Skip -ldl on NetBSD; it does not exist. Skip -lrt on NetBSD; it is not required. Same treatment as FreeBSD. (cherry picked from commit ecce27ce1d8d8ff1f5ccd89be65700f0da98eaf4) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bb62f14a1..4eaad067c 100644 --- a/Makefile +++ b/Makefile @@ -137,11 +137,11 @@ endif # LIBS := -ldl -lrt LIBS += -lm -ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD)) +ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD NetBSD)) LIBS += -ldl endif -ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD Darwin)) +ifneq ($(OS), $(filter $(OS), FreeBSD OpenBSD NetBSD Darwin)) LIBS += -lrt endif From a692c0da486f310f3967ce9f2401616fe551732d Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Thu, 11 Apr 2024 16:28:36 +0200 Subject: [PATCH 3/8] Support out of tree builds (cherry picked from commit 2c52e3f969827fbba60224b15b4da0f867e62a26) --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4eaad067c..b36e4f80d 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ AR := ar LD := $(CXX) MSG_PREFIX ?= -ABCSRC = . +ABCSRC ?= . +VPATH = $(ABCSRC) $(info $(MSG_PREFIX)Using CC=$(CC)) $(info $(MSG_PREFIX)Using CXX=$(CXX)) @@ -41,7 +42,7 @@ default: $(PROG) ARCHFLAGS_EXE ?= ./arch_flags $(ARCHFLAGS_EXE) : arch_flags.c - $(CC) arch_flags.c -o $(ARCHFLAGS_EXE) + $(CC) $< -o $(ARCHFLAGS_EXE) INCLUDES += -I$(ABCSRC)/src @@ -173,26 +174,32 @@ DEP := $(OBJ:.o=.d) # implicit rules %.o: %.c + @mkdir -p $(dir $@) @echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$< $(VERBOSE)$(CC) -c $(OPTFLAGS) $(INCLUDES) $(CFLAGS) $< -o $@ %.o: %.cc + @mkdir -p $(dir $@) @echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$< $(VERBOSE)$(CXX) -c $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< -o $@ %.o: %.cpp + @mkdir -p $(dir $@) @echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$< $(VERBOSE)$(CXX) -c $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< -o $@ %.d: %.c + @mkdir -p $(dir $@) @echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$< $(VERBOSE)$(ABCSRC)/depends.sh "$(CC)" `dirname $*.c` $(OPTFLAGS) $(INCLUDES) $(CFLAGS) $< > $@ %.d: %.cc + @mkdir -p $(dir $@) @echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$< $(VERBOSE)$(ABCSRC)/depends.sh "$(CXX)" `dirname $*.cc` $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< > $@ %.d: %.cpp + @mkdir -p $(dir $@) @echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$< $(VERBOSE)$(ABCSRC)/depends.sh "$(CXX)" `dirname $*.cpp` $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $< > $@ From 10b9da7acb177c36b600583790a7d210dd9c599b Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sat, 19 Oct 2019 12:36:14 +0800 Subject: [PATCH 4/8] Makefile: break apart steps in `make clean` The `make clean` target consists of a single `rm` call that passes every generated file, object file, and dependency directory. This results in a command line that's around 53,800 characters long. On Linux, the maximum length of a command line is 131,072 or 262,144 characters, however on Windows the limit is 32,768. The 53,800 character command simply fails to run on Windows, which is a problem when the first command that gets run is `make clean`. Break this target into steps, first removing the output files, then the object files, then any generated garbage, and then the object depedency directories. This fixes `make clean` (and as a result yosys) on Windows. Signed-off-by: Sean Cross (cherry picked from commit 11c4f998b25b6c07f4081cea10e2532ebcb7f4d4) --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b36e4f80d..dc909bb63 100644 --- a/Makefile +++ b/Makefile @@ -213,7 +213,10 @@ depend: $(DEP) clean: @echo "$(MSG_PREFIX)\`\` Cleaning up..." - $(VERBOSE)rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d) + $(VERBOSE)rm -rvf $(PROG) lib$(PROG).a + $(VERBOSE)rm -rvf $(OBJ) + $(VERBOSE)rm -rvf $(GARBAGE) + $(VERBOSE)rm -rvf $(OBJ:.o=.d) tags: etags `find . -type f -regex '.*\.\(c\|h\)'` From 23435fc8bf7e6b05259eed6350421a2e0904dce3 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 25 Jul 2022 11:54:23 +0200 Subject: [PATCH 5/8] Export version (cherry picked from commit 4e89fc7ccb32086a55c2fbc567755c96e319d2f8) --- .gitattributes | 1 + .gitcommit | 1 + 2 files changed, 2 insertions(+) create mode 100644 .gitcommit diff --git a/.gitattributes b/.gitattributes index 400b529f0..93b5c8649 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ +/.gitcommit export-subst * text=auto *.c text diff --git a/.gitcommit b/.gitcommit new file mode 100644 index 000000000..46b7856fb --- /dev/null +++ b/.gitcommit @@ -0,0 +1 @@ +$Format:%h$ From 15ec30209592ec9e418c6375c8c730d20bc8997b Mon Sep 17 00:00:00 2001 From: "Mohamed A. Bamakhrama" Date: Mon, 3 Aug 2020 23:19:23 +0200 Subject: [PATCH 6/8] Define S_IREAD|IWRITE macros using IRUSR|IWUSR On platforms such as Android, legacy macros are no longer defined. Hence, we define them in terms of the new POSIX macros if the new ones are defined. Otherwise, we throw an error. Signed-off-by: Mohamed A. Bamakhrama Signed-off-by: Miodrag Milanovic (cherry picked from commit e792072f8a6f016eb5f2c8653f261ba7c88e6392) --- src/misc/util/utilFile.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/misc/util/utilFile.c b/src/misc/util/utilFile.c index 4bb2f4c68..b096cabb6 100644 --- a/src/misc/util/utilFile.c +++ b/src/misc/util/utilFile.c @@ -25,6 +25,23 @@ #include #include +// Handle legacy macros +#if !defined(S_IREAD) +#if defined(S_IRUSR) +#define S_IREAD S_IRUSR +#else +#error S_IREAD is undefined +#endif +#endif + +#if !defined(S_IWRITE) +#if defined(S_IWUSR) +#define S_IWRITE S_IWUSR +#else +#error S_IWRITE is undefined +#endif +#endif + #if defined(_MSC_VER) || defined(__MINGW32__) #include #include From 57c3bd36f2dd19918bca9682c7f0fbe168fc6d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 7 Aug 2024 14:44:53 +0200 Subject: [PATCH 7/8] Patch to support WASI builds Co-authored-by: whitequark --- src/aig/gia/giaStoch.c | 4 ++++ src/base/abc/abcShow.c | 8 ++++++++ src/base/abci/abc.c | 4 ++++ src/base/cmd/cmd.c | 4 ++++ src/base/cmd/cmdUtils.c | 5 ++++- src/base/main/mainReal.c | 2 ++ src/base/wln/wlnRtl.c | 4 ++++ src/misc/util/abc_global.h | 4 ++-- src/misc/util/utilFile.c | 11 +++++++++++ src/misc/util/utilSignal.c | 4 ++++ src/sat/bmc/bmcMaj.c | 4 ++++ src/sat/bsat2/Alloc.h | 8 ++++++++ src/sat/bsat2/Vec.h | 4 ++++ src/sat/bsat2/XAlloc.h | 4 ++++ src/sat/cnf/cnfUtil.c | 8 ++++++++ src/sat/glucose/IntTypes.h | 16 +++++++--------- src/sat/glucose2/IntTypes.h | 16 +++++++--------- 17 files changed, 89 insertions(+), 21 deletions(-) diff --git a/src/aig/gia/giaStoch.c b/src/aig/gia/giaStoch.c index 03f80513b..68e23019e 100644 --- a/src/aig/gia/giaStoch.c +++ b/src/aig/gia/giaStoch.c @@ -114,7 +114,11 @@ Gia_Man_t * Gia_StochProcessOne( Gia_Man_t * p, char * pScript, int Rand, int Ti sprintf( FileName, "%06x.aig", Rand ); Gia_AigerWrite( p, FileName, 0, 0, 0 ); sprintf( Command, "./abc -q \"&read %s; %s; &write %s\"", FileName, pScript, FileName ); +#if defined(__wasm) + if ( 1 ) +#else if ( system( (char *)Command ) ) +#endif { fprintf( stderr, "The following command has returned non-zero exit status:\n" ); fprintf( stderr, "\"%s\"\n", (char *)Command ); diff --git a/src/base/abc/abcShow.c b/src/base/abc/abcShow.c index 88b8cbf69..cdd53fc20 100644 --- a/src/base/abc/abcShow.c +++ b/src/base/abc/abcShow.c @@ -363,7 +363,11 @@ void Abc_ShowFile( char * FileNameDot, int fKeepDot ) // generate the PostScript file using DOT sprintf( CommandDot, "%s -Tps -o %s %s", pDotName, FileNamePs, FileNameDot ); +#if defined(__wasm) + RetValue = -1; +#else RetValue = system( CommandDot ); +#endif if ( RetValue == -1 ) { fprintf( stdout, "Command \"%s\" did not succeed.\n", CommandDot ); @@ -401,7 +405,11 @@ void Abc_ShowFile( char * FileNameDot, int fKeepDot ) char CommandPs[1000]; if ( !fKeepDot ) unlink( FileNameDot ); sprintf( CommandPs, "%s %s &", pGsNameUnix, FileNamePs ); +#if defined(__wasm) + if ( 1 ) +#else if ( system( CommandPs ) == -1 ) +#endif { fprintf( stdout, "Cannot execute \"%s\".\n", CommandPs ); return; diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index a78706032..e12728bd9 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -7295,7 +7295,11 @@ int Abc_CommandRunSat( Abc_Frame_t * pAbc, int argc, char ** argv ) sprintf( pCommand, "kissat -q --seed=%d %s", i, pFileCnf ); else if ( fWalk ) sprintf( pCommand, "walk -s%d %s", i, pFileCnf ); +#if defined(__wasm) + if (1) { +#else if (system(pCommand) == -1) { +#endif fprintf(stdout, "Command \"%s\" did not succeed.\n", pCommand); return 0; } diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c index d1408b6c1..20d0f0c38 100644 --- a/src/base/cmd/cmd.c +++ b/src/base/cmd/cmd.c @@ -2412,7 +2412,11 @@ void Gia_ManGnuplotShow( char * pPlotFileName ) { char Command[1000]; sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName ); +#if defined(__wasm) + if ( 1 ) +#else if ( system( Command ) == -1 ) +#endif { fprintf( stdout, "Cannot execute \"%s\".\n", Command ); return; diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c index a5dc6972b..e8e28078f 100644 --- a/src/base/cmd/cmdUtils.c +++ b/src/base/cmd/cmdUtils.c @@ -53,6 +53,9 @@ int cmdCheckShellEscape( Abc_Frame_t * pAbc, int argc, char ** argv) int RetValue; if (argv[0][0] == '!') { +#if defined(__wasm) + RetValue = -1; +#else const int size = 4096; int i; char * buffer = ABC_ALLOC(char, 10000); @@ -71,7 +74,7 @@ int cmdCheckShellEscape( Abc_Frame_t * pAbc, int argc, char ** argv) // the parts, we lose information. So a command like // `!ls "file name"` will be sent to the system as // `ls file name` which is a BUG - +#endif return 1; } else diff --git a/src/base/main/mainReal.c b/src/base/main/mainReal.c index 922e05215..420f2cf10 100644 --- a/src/base/main/mainReal.c +++ b/src/base/main/mainReal.c @@ -49,7 +49,9 @@ SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #include #include #include +#if !defined(__wasm) #include +#endif #include #endif diff --git a/src/base/wln/wlnRtl.c b/src/base/wln/wlnRtl.c index 36801c862..f7364bded 100644 --- a/src/base/wln/wlnRtl.c +++ b/src/base/wln/wlnRtl.c @@ -121,6 +121,9 @@ char * Wln_GetYosysName() } int Wln_ConvertToRtl( char * pCommand, char * pFileTemp ) { +#if defined(__wasm) + return 0; +#else FILE * pFile; if ( system( pCommand ) == -1 ) { @@ -134,6 +137,7 @@ int Wln_ConvertToRtl( char * pCommand, char * pFileTemp ) } fclose( pFile ); return 1; +#endif } Rtl_Lib_t * Wln_ReadSystemVerilog( char * pFileName, char * pTopModule, char * pDefines, int fCollapse, int fVerbose ) { diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index 8fdda44bf..96944d7cc 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -334,7 +334,7 @@ static inline abctime Abc_Clock() #else #define APPLE_MACH 0 #endif -#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) +#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) && !defined(__wasm) struct timespec ts; if ( clock_gettime(CLOCK_MONOTONIC, &ts) < 0 ) return (abctime)-1; @@ -353,7 +353,7 @@ static inline abctime Abc_ThreadClock() #else #define APPLE_MACH 0 #endif -#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) +#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) && !defined(__wasm) struct timespec ts; if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) < 0 ) return (abctime)-1; diff --git a/src/misc/util/utilFile.c b/src/misc/util/utilFile.c index b096cabb6..f64d71c24 100644 --- a/src/misc/util/utilFile.c +++ b/src/misc/util/utilFile.c @@ -119,6 +119,17 @@ int tmpFile(const char* prefix, const char* suffix, char** out_name) } assert(0); // -- could not open temporary file return 0; +#elif defined(__wasm) + static int seq = 0; // no risk of collision since we're in a sandbox + int fd; + *out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 9); + sprintf(*out_name, "%s%08d%s", prefix, seq++, suffix); + fd = open(*out_name, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE); + if (fd == -1){ + free(*out_name); + *out_name = NULL; + } + return fd; #else int fd; *out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 7); diff --git a/src/misc/util/utilSignal.c b/src/misc/util/utilSignal.c index 03af81d13..137ff54b8 100644 --- a/src/misc/util/utilSignal.c +++ b/src/misc/util/utilSignal.c @@ -43,7 +43,11 @@ ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char* cmd) { +#if defined(__wasm) + return -1; +#else return system(cmd); +#endif } int tmpFile(const char* prefix, const char* suffix, char** out_name); diff --git a/src/sat/bmc/bmcMaj.c b/src/sat/bmc/bmcMaj.c index ef1717403..5e9c1310c 100644 --- a/src/sat/bmc/bmcMaj.c +++ b/src/sat/bmc/bmcMaj.c @@ -1642,7 +1642,11 @@ Vec_Int_t * Exa4_ManSolve( char * pFileNameIn, char * pFileNameOut, int TimeOut, sprintf( pCommand, "%s --time=%d %s %s > %s", pKissat, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut ); else sprintf( pCommand, "%s %s %s > %s", pKissat, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut ); +#ifdef __wasm + if ( 1 ) +#else if ( system( pCommand ) == -1 ) +#endif { fprintf( stdout, "Command \"%s\" did not succeed.\n", pCommand ); return 0; diff --git a/src/sat/bsat2/Alloc.h b/src/sat/bsat2/Alloc.h index a9786a9a8..1bf5784fc 100644 --- a/src/sat/bsat2/Alloc.h +++ b/src/sat/bsat2/Alloc.h @@ -99,7 +99,11 @@ void RegionAllocator::capacity(uint32_t min_cap) cap += delta; if (cap <= prev_cap) +#ifdef __wasm + abort(); +#else throw OutOfMemoryException(); +#endif } // printf(" .. (%p) cap = %u\n", this, cap); @@ -121,7 +125,11 @@ RegionAllocator::alloc(int size) // Handle overflow: if (sz < prev_sz) +#ifdef __wasm + abort(); +#else throw OutOfMemoryException(); +#endif return prev_sz; } diff --git a/src/sat/bsat2/Vec.h b/src/sat/bsat2/Vec.h index f5f5499ea..6937d7256 100644 --- a/src/sat/bsat2/Vec.h +++ b/src/sat/bsat2/Vec.h @@ -98,7 +98,11 @@ void vec::capacity(int min_cap) { if (cap >= min_cap) return; int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2 if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM)) +#ifdef __wasm + abort(); +#else throw OutOfMemoryException(); +#endif } diff --git a/src/sat/bsat2/XAlloc.h b/src/sat/bsat2/XAlloc.h index fdebe502a..3e9e39674 100644 --- a/src/sat/bsat2/XAlloc.h +++ b/src/sat/bsat2/XAlloc.h @@ -38,7 +38,11 @@ static inline void* xrealloc(void *ptr, size_t size) { void* mem = realloc(ptr, size); if (mem == NULL && errno == ENOMEM){ +#ifdef __wasm + abort(); +#else throw OutOfMemoryException(); +#endif }else return mem; } diff --git a/src/sat/cnf/cnfUtil.c b/src/sat/cnf/cnfUtil.c index e67328171..3a47ae796 100644 --- a/src/sat/cnf/cnfUtil.c +++ b/src/sat/cnf/cnfUtil.c @@ -82,7 +82,11 @@ Vec_Int_t *Cnf_RunSolverOnce(int Id, int Rand, int TimeOut, int fVerbose) FILE * pFile = fopen(FileNameIn, "rb"); if ( pFile != NULL ) { fclose( pFile ); +#if defined(__wasm) + if ( 1 ) { +#else if (system(pCommand) == -1) { +#endif fprintf(stdout, "Command \"%s\" did not succeed.\n", pCommand); return 0; } @@ -764,7 +768,11 @@ void Cnf_SplitCnfFile(char * pFileName, int nParts, int iVarBeg, int iVarEnd, in char Command[1000]; sprintf(Command, "satelite --verbosity=0 -pre temp.cnf %s", FileName); Cnf_DataWriteIntoFile(pCnf, "temp.cnf", 0, NULL, NULL); +#if defined(__wasm) + if ( 1 ) { +#else if (system(Command) == -1) { +#endif fprintf(stdout, "Command \"%s\" did not succeed. Preprocessing skipped.\n", Command); Cnf_DataWriteIntoFile(pCnf, FileName, 0, NULL, NULL); } diff --git a/src/sat/glucose/IntTypes.h b/src/sat/glucose/IntTypes.h index 3f75862b1..5c4176b29 100644 --- a/src/sat/glucose/IntTypes.h +++ b/src/sat/glucose/IntTypes.h @@ -28,20 +28,18 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA # include # include +#elif _WIN32 + +# include "pstdint.h" + #else -#define __STDC_LIMIT_MACROS -# include "pstdint.h" -//# include +# define __STDC_LIMIT_MACROS +# include +# include #endif -#include - -#ifndef PRIu64 -#define PRIu64 "lu" -#define PRIi64 "ld" -#endif //================================================================================================= #include diff --git a/src/sat/glucose2/IntTypes.h b/src/sat/glucose2/IntTypes.h index 3f75862b1..5c4176b29 100644 --- a/src/sat/glucose2/IntTypes.h +++ b/src/sat/glucose2/IntTypes.h @@ -28,20 +28,18 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA # include # include +#elif _WIN32 + +# include "pstdint.h" + #else -#define __STDC_LIMIT_MACROS -# include "pstdint.h" -//# include +# define __STDC_LIMIT_MACROS +# include +# include #endif -#include - -#ifndef PRIu64 -#define PRIu64 "lu" -#define PRIi64 "ld" -#endif //================================================================================================= #include From 68c99247bd09fce5c7ef25a2d4c769179a090717 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Thu, 27 Jun 2024 13:41:10 -0700 Subject: [PATCH 8/8] Fix archive reproducibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The git archive export-subst option does not have consistent results over time, since the abbreviated commit hash can get longer over time. Instead, let's export the full commit hash. This was found in an audit of source archive reproducibility in nixpkgs: ``` ~ » expected=$(nix-store -r /nix/store/4j9rj4m6akjskp0f7k923qff817k6hv5-source) actual=$(nix-prefetch-url --print-path --unpack --name source https://github.com/yosyshq/abc/archive/896e5e7dedf9b9b1459fa019f1fa8aa8101fdf43.tar.gz | tail -n1) nix-shell -p diffoscope --run "diffoscope $expected $actual" this path will be fetched (3.77 MiB download, 34.50 MiB unpacked): /nix/store/4j9rj4m6akjskp0f7k923qff817k6hv5-source copying path '/nix/store/4j9rj4m6akjskp0f7k923qff817k6hv5-source' from 'https://cache.nixos.org'... warning: you did not specify '--add-root'; the result might be removed by the garbage collector --- /nix/store/4j9rj4m6akjskp0f7k923qff817k6hv5-source +++ /nix/store/v7ms5ghibzi8pk71nzlhvsbn7a0rdpy7-source │ --- /nix/store/4j9rj4m6akjskp0f7k923qff817k6hv5-source/.gitcommit ├── +++ /nix/store/v7ms5ghibzi8pk71nzlhvsbn7a0rdpy7-source/.gitcommit │ @@ -1 +1 @@ │ -896e5e7de │ +896e5e7ded │ ├── stat {} │ │ @@ -1,7 +1,7 @@ │ │ │ │ - Size: 10 Blocks: 1 IO Block: 512 regular file │ │ + Size: 11 Blocks: 1 IO Block: 512 regular file │ │ Device: 0,24 Access: (0444/-r--r--r--) Uid: ( 0/ root) Gid: ( 0/ root) │ │ │ │ Modify: 1970-01-01 00:00:01.000000000 +0000 ``` (cherry picked from commit 04f50406fd93f4193a58083e391b27e195e4bfd5) --- .gitcommit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitcommit b/.gitcommit index 46b7856fb..6828f88dc 100644 --- a/.gitcommit +++ b/.gitcommit @@ -1 +1 @@ -$Format:%h$ +$Format:%H$