From b9310c1c1225fb891937f63c61cbf3b79020e5a1 Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Wed, 2 Aug 2023 12:34:14 -0400 Subject: [PATCH] Apply patch from yosyshq to fix yosys FTBFS (#2226521) --- abc-format.patch | 105 ++++++++++++--------------------------- abc-gia.patch | 10 ++-- abc-overflow.patch | 11 ---- abc-use-after-free.patch | 23 --------- abc-yosys-segfault.patch | 22 ++++++++ abc.spec | 27 ++++++---- sources | 2 +- 7 files changed, 76 insertions(+), 124 deletions(-) delete mode 100644 abc-overflow.patch delete mode 100644 abc-use-after-free.patch create mode 100644 abc-yosys-segfault.patch diff --git a/abc-format.patch b/abc-format.patch index 2db66ba..c71498d 100644 --- a/abc-format.patch +++ b/abc-format.patch @@ -1,38 +1,15 @@ ---- src/aig/saig/saigIoa.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/aig/saig/saigIoa.c 2022-01-17 08:22:16.506371575 -0700 -@@ -47,15 +47,15 @@ char * Saig_ObjName( Aig_Man_t * p, Aig_ - { - static char Buffer[16]; - if ( Aig_ObjIsNode(pObj) || Aig_ObjIsConst1(pObj) ) -- sprintf( Buffer, "n%0*d", Abc_Base10Log(Aig_ManObjNumMax(p)), Aig_ObjId(pObj) ); -+ snprintf( Buffer, 16, "n%0*d", Abc_Base10Log(Aig_ManObjNumMax(p)), Aig_ObjId(pObj) ); - else if ( Saig_ObjIsPi(p, pObj) ) -- sprintf( Buffer, "pi%0*d", Abc_Base10Log(Saig_ManPiNum(p)), Aig_ObjCioId(pObj) ); -+ snprintf( Buffer, 16, "pi%0*d", Abc_Base10Log(Saig_ManPiNum(p)), Aig_ObjCioId(pObj) ); - else if ( Saig_ObjIsPo(p, pObj) ) -- sprintf( Buffer, "po%0*d", Abc_Base10Log(Saig_ManPoNum(p)), Aig_ObjCioId(pObj) ); -+ snprintf( Buffer, 16, "po%0*d", Abc_Base10Log(Saig_ManPoNum(p)), Aig_ObjCioId(pObj) ); - else if ( Saig_ObjIsLo(p, pObj) ) -- sprintf( Buffer, "lo%0*d", Abc_Base10Log(Saig_ManRegNum(p)), Aig_ObjCioId(pObj) - Saig_ManPiNum(p) ); -+ snprintf( Buffer, 16, "lo%0*d", Abc_Base10Log(Saig_ManRegNum(p)), Aig_ObjCioId(pObj) - Saig_ManPiNum(p) ); - else if ( Saig_ObjIsLi(p, pObj) ) -- sprintf( Buffer, "li%0*d", Abc_Base10Log(Saig_ManRegNum(p)), Aig_ObjCioId(pObj) - Saig_ManPoNum(p) ); -+ snprintf( Buffer, 16, "li%0*d", Abc_Base10Log(Saig_ManRegNum(p)), Aig_ObjCioId(pObj) - Saig_ManPoNum(p) ); - else - assert( 0 ); - return Buffer; ---- src/base/abci/abc.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/base/abci/abc.c 2022-01-17 08:22:16.510371570 -0700 -@@ -30577,7 +30577,7 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pA - else - { - assert( i >= Abc_NtkPoNum(pNtk) ); -- sprintf( pSuffix, "_li%0*d", nDigits, i-Abc_NtkPoNum(pNtk) ); -+ snprintf( pSuffix, 100, "_li%0*d", nDigits, i-Abc_NtkPoNum(pNtk) ); - Abc_ObjAssignName( pObj, (char *)Vec_PtrEntry(pAbc->pGia->vNamesOut, i), pSuffix ); - } - } -@@ -43889,7 +43889,7 @@ int Abc_CommandAbc9Cone( Abc_Frame_t * p +--- src/base/abci/abc.c.orig 2023-07-08 11:18:18.000000000 -0600 ++++ src/base/abci/abc.c 2023-07-14 11:14:10.263628991 -0600 +@@ -23905,7 +23905,7 @@ int Abc_CommandSymFun( Abc_Frame_t * pAb + printf( "%s\n", pTruth ); + // read the truth table to be the current network in ABC + pCommand = ABC_CALLOC( char, strlen(pTruth) + 100 ); +- sprintf( pCommand, "read_truth %s", pTruth ); ++ snprintf( pCommand, strlen(pTruth) + 100, "read_truth %s", pTruth ); + Cmd_CommandExecute( pAbc, pCommand ); + ABC_FREE( pCommand ); + ABC_FREE( pTruth ); +@@ -45189,7 +45189,7 @@ int Abc_CommandAbc9Cone( Abc_Frame_t * p Gia_ManForEachPo( pAbc->pGia, pObj, i ) { Gia_Man_t * pOne = Gia_ManDupDfsCone( pAbc->pGia, pObj ); @@ -41,8 +18,8 @@ Gia_AigerWrite( pOne, Buffer, 0, 0, 0 ); Gia_ManStop( pOne ); } ---- src/base/io/ioReadBlifMv.c.orig 2022-01-17 08:21:48.617409341 -0700 -+++ src/base/io/ioReadBlifMv.c 2022-01-17 08:22:16.511371568 -0700 +--- src/base/io/ioReadBlifMv.c.orig 2023-07-14 11:12:54.591767465 -0600 ++++ src/base/io/ioReadBlifMv.c 2023-07-14 11:13:13.259486615 -0600 @@ -1627,7 +1627,7 @@ static int Io_MvParseLineMv( Io_MvMod_t ***********************************************************************/ static int Io_MvWriteValues( Abc_Obj_t * pNode, Vec_Str_t * vFunc ) @@ -52,34 +29,14 @@ Abc_Obj_t * pFanin; int i; // add the fanin number of values ---- src/base/io/ioReadPla.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/base/io/ioReadPla.c 2022-01-17 08:22:16.511371568 -0700 -@@ -448,7 +448,7 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_Fil - nDigits = Abc_Base10Log( nInputs ); - for ( i = 0; i < nInputs; i++ ) - { -- sprintf( Buffer, "x%0*d", nDigits, i ); -+ snprintf( Buffer, 100, "x%0*d", nDigits, i ); - Io_ReadCreatePi( pNtk, Buffer ); - } - } -@@ -465,7 +465,7 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_Fil - nDigits = Abc_Base10Log( nOutputs ); - for ( i = 0; i < nOutputs; i++ ) - { -- sprintf( Buffer, "z%0*d", nDigits, i ); -+ snprintf( Buffer, 100, "z%0*d", nDigits, i ); - Io_ReadCreatePo( pNtk, Buffer ); - } - } ---- src/base/wlc/wlcNtk.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/base/wlc/wlcNtk.c 2022-01-17 08:22:16.512371567 -0700 +--- src/base/wlc/wlcNtk.c.orig 2023-07-08 11:18:18.000000000 -0600 ++++ src/base/wlc/wlcNtk.c 2023-07-14 10:51:19.721294579 -0600 @@ -1300,7 +1300,7 @@ void Wlc_NtkShortNames( Wlc_Ntk_t * p ) { if ( Wlc_ObjIsPo(pObj) ) continue; - sprintf( pBuffer, "%s%0*d", "fi", nDigits, i - Wlc_NtkPoNum(p) ); -+ snprintf( pBuffer, 100, "%s%0*d", "fi", nDigits, i - Wlc_NtkPoNum(p) ); ++ snprintf( pBuffer, 1000, "%s%0*d", "fi", nDigits, i - Wlc_NtkPoNum(p) ); NameId = Abc_NamStrFindOrAdd( p->pManName, pBuffer, &fFound ); Wlc_ObjSetNameId( p, Wlc_ObjId(p, pObj), NameId ); } @@ -88,7 +45,7 @@ if ( Wlc_ObjIsPi(pObj) ) continue; - sprintf( pBuffer, "%s%0*d", "fo", nDigits, i - Wlc_NtkPiNum(p) ); -+ snprintf( pBuffer, 100, "%s%0*d", "fo", nDigits, i - Wlc_NtkPiNum(p) ); ++ snprintf( pBuffer, 1000, "%s%0*d", "fo", nDigits, i - Wlc_NtkPiNum(p) ); NameId = Abc_NamStrFindOrAdd( p->pManName, pBuffer, &fFound ); Wlc_ObjSetNameId( p, Wlc_ObjId(p, pObj), NameId ); } @@ -96,7 +53,7 @@ Wlc_NtkForEachPo( p, pObj, i ) { - sprintf( pBuffer, "%s%0*d", "po", nDigits, i ); -+ snprintf( pBuffer, 100, "%s%0*d", "po", nDigits, i ); ++ snprintf( pBuffer, 1000, "%s%0*d", "po", nDigits, i ); NameId = Abc_NamStrFindOrAdd( p->pManName, pBuffer, &fFound ); Wlc_ObjSetNameId( p, Wlc_ObjId(p, pObj), NameId ); } @@ -104,7 +61,7 @@ Wlc_NtkForEachPi( p, pObj, i ) { - sprintf( pBuffer, "%s%0*d", "pi", nDigits, i ); -+ snprintf( pBuffer, 100, "%s%0*d", "pi", nDigits, i ); ++ snprintf( pBuffer, 1000, "%s%0*d", "pi", nDigits, i ); NameId = Abc_NamStrFindOrAdd( p->pManName, pBuffer, &fFound ); Wlc_ObjSetNameId( p, Wlc_ObjId(p, pObj), NameId ); } @@ -113,13 +70,13 @@ if ( Wlc_ObjIsCi(pObj) || Wlc_ObjIsCo(pObj) ) continue; - sprintf( pBuffer, "%s%0*d", "n", nDigits, i ); -+ snprintf( pBuffer, 100, "%s%0*d", "n", nDigits, i ); ++ snprintf( pBuffer, 1000, "%s%0*d", "n", nDigits, i ); NameId = Abc_NamStrFindOrAdd( p->pManName, pBuffer, &fFound ); Wlc_ObjSetNameId( p, Wlc_ObjId(p, pObj), NameId ); } ---- src/map/mio/mioUtils.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/map/mio/mioUtils.c 2022-01-17 08:22:16.513371566 -0700 -@@ -1711,7 +1711,7 @@ void Mio_LibraryShortNames( Mio_Library_ +--- src/map/mio/mioUtils.c.orig 2023-07-08 11:18:18.000000000 -0600 ++++ src/map/mio/mioUtils.c 2023-07-14 10:47:26.983819441 -0600 +@@ -1716,7 +1716,7 @@ void Mio_LibraryShortNames( Mio_Library_ Mio_LibraryForEachGate( pLib, pGate ) { ABC_FREE( pGate->pName ); @@ -128,9 +85,9 @@ pGate->pName = Abc_UtilStrsav( Buffer ); // update formula Mio_LibraryShortFormula( pGate, pGate->pForm, Buffer ); ---- src/map/scl/sclLibUtil.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/map/scl/sclLibUtil.c 2022-01-17 08:22:16.513371566 -0700 -@@ -203,7 +203,7 @@ void Abc_SclShortNames( SC_Lib * p ) +--- src/map/scl/sclLibUtil.c.orig 2023-07-08 11:18:18.000000000 -0600 ++++ src/map/scl/sclLibUtil.c 2023-07-14 10:47:26.983819441 -0600 +@@ -205,7 +205,7 @@ void Abc_SclShortNames( SC_Lib * p ) SC_RingForEachCell( pClass, pCell, k ) { ABC_FREE( pCell->pName ); @@ -139,8 +96,8 @@ pCell->pName = Abc_UtilStrsav( Buffer ); // formula SC_CellForEachPinOut( pCell, pPin, n ) ---- src/opt/dau/dauMerge.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/opt/dau/dauMerge.c 2022-01-17 08:22:16.513371566 -0700 +--- src/opt/dau/dauMerge.c.orig 2023-07-08 11:18:18.000000000 -0600 ++++ src/opt/dau/dauMerge.c 2023-07-14 10:47:26.983819441 -0600 @@ -715,7 +715,7 @@ Dau_DsdMergeStorePrintDefs( pS ); // create new function @@ -150,8 +107,8 @@ pTruth = Dau_DsdToTruth( pS->pOutput, nVarsTotal ); Status = Dau_DsdDecompose( pTruth, nVarsTotal, 0, 1, pS->pOutput ); //printf( "%d ", Status ); ---- src/proof/fra/fraCore.c.orig 2021-12-29 14:08:32.000000000 -0700 -+++ src/proof/fra/fraCore.c 2022-01-17 08:22:16.513371566 -0700 +--- src/proof/fra/fraCore.c.orig 2023-07-08 11:18:18.000000000 -0600 ++++ src/proof/fra/fraCore.c 2023-07-14 10:47:26.983819441 -0600 @@ -163,7 +163,7 @@ static inline void Fra_FraigNodeSpeculat // create manager with the logic for these two nodes pTemp = Aig_ManExtractMiter( p->pManFraig, pObjFraig, pObjReprFraig ); diff --git a/abc-gia.patch b/abc-gia.patch index 9988b05..8e09872 100644 --- a/abc-gia.patch +++ b/abc-gia.patch @@ -1,11 +1,11 @@ ---- src/aig/gia/gia.h.orig 2020-07-20 20:56:06.000000000 -0600 -+++ src/aig/gia/gia.h 2020-07-24 15:13:12.699364636 -0600 -@@ -1118,7 +1118,7 @@ static inline int Gia_ObjCellId( +--- src/aig/gia/gia.h.orig 2023-07-14 10:53:06.361679474 -0600 ++++ src/aig/gia/gia.h 2023-07-14 10:54:12.069684316 -0600 +@@ -1142,7 +1142,7 @@ static inline int Gia_ObjCellId( #define Gia_ManForEachLutReverse( p, i ) \ for ( i = Gia_ManObjNum(p) - 1; i > 0; i-- ) if ( !Gia_ObjIsLut(p, i) ) {} else #define Gia_LutForEachFanin( p, i, iFan, k ) \ - for ( k = 0; k < Gia_ObjLutSize(p,i) && ((iFan = Gia_ObjLutFanins(p,i)[k]),1); k++ ) + for ( k = 0; k < Gia_ObjLutSize(p,i) && ((iFan = Gia_ObjLutFanins(p,i)[k]),1); k++ ) if (iFan >= 0) + #define Gia_LutForEachFaninIndex( p, i, iFan, k, Index ) \ + for ( k = 0; k < Gia_ObjLutSize(p,i) && (Index = Vec_IntEntry(p->vMapping, i)+1+k) && ((iFan = Vec_IntEntry(p->vMapping, Index)),1); k++ ) #define Gia_LutForEachFaninObj( p, i, pFanin, k ) \ - for ( k = 0; k < Gia_ObjLutSize(p,i) && ((pFanin = Gia_ManObj(p, Gia_ObjLutFanins(p,i)[k])),1); k++ ) - diff --git a/abc-overflow.patch b/abc-overflow.patch deleted file mode 100644 index 96a1d6f..0000000 --- a/abc-overflow.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- src/map/if/ifDsd.c.orig 2021-03-28 19:40:27.000000000 -0600 -+++ src/map/if/ifDsd.c 2021-03-31 09:50:14.911798180 -0600 -@@ -91,7 +91,7 @@ struct If_DsdMan_t_ - Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]; // truth table memory and hash table - Vec_Ptr_t * vTtDecs[IF_MAX_FUNC_LUTSIZE+1]; // truth table decompositions - Vec_Wec_t * vIsops[IF_MAX_FUNC_LUTSIZE+1]; // ISOP for each function -- int * pSched[IF_MAX_FUNC_LUTSIZE]; // grey code schedules -+ int * pSched[IF_MAX_FUNC_LUTSIZE+1]; // grey code schedules - int nTtBits; // the number of truth table bits - int nConfigWords; // the number of words for config data per node - Vec_Wrd_t * vConfigs; // permutations diff --git a/abc-use-after-free.patch b/abc-use-after-free.patch deleted file mode 100644 index 6c4ee43..0000000 --- a/abc-use-after-free.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- src/base/cmd/cmdLoad.c.orig 2022-10-19 06:05:56.000000000 -0600 -+++ src/base/cmd/cmdLoad.c 2022-11-16 11:26:13.394889017 -0700 -@@ -58,8 +58,8 @@ int CmdCommandLoad( Abc_Frame_t * pAbc, - // check if there is the binary - if ( (pFile = fopen( Vec_StrArray(vCommand), "r" )) == NULL ) - { -- Vec_StrFree( vCommand ); - Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", Vec_StrArray(vCommand) ); -+ Vec_StrFree( vCommand ); - return 1; - } - fclose( pFile ); -@@ -74,9 +74,9 @@ int CmdCommandLoad( Abc_Frame_t * pAbc, - // run the command line - if ( Util_SignalSystem( Vec_StrArray(vCommand) ) ) - { -- Vec_StrFree( vCommand ); - Abc_Print( -1, "The following command has returned non-zero exit status:\n" ); - Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) ); -+ Vec_StrFree( vCommand ); - return 1; - } - Vec_StrFree( vCommand ); diff --git a/abc-yosys-segfault.patch b/abc-yosys-segfault.patch new file mode 100644 index 0000000..602c820 --- /dev/null +++ b/abc-yosys-segfault.patch @@ -0,0 +1,22 @@ +From 1de4eafb0da0639199bd97f2fa98471e76327a6b Mon Sep 17 00:00:00 2001 +From: Miodrag Milanovic +Date: Tue, 6 Jun 2023 13:59:30 +0200 +Subject: [PATCH] fix segfault + +--- + src/base/io/ioWriteVerilog.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git src/base/io/ioWriteVerilog.c src/base/io/ioWriteVerilog.c +index 48b15b559..3d9f8fa38 100644 +--- src/base/io/ioWriteVerilog.c ++++ src/base/io/ioWriteVerilog.c +@@ -561,7 +561,7 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk, int fOnlyAnds ) + vLevels = Vec_VecAlloc( 10 ); + Abc_NtkForEachNode( pNtk, pObj, i ) + { +- if ( Abc_ObjFaninNum(pObj) == 1 || Abc_ObjIsCo(Abc_ObjFanout0(Abc_ObjFanout0(pObj))) ) ++ if ( Abc_ObjFaninNum(pObj) == 1 && Abc_ObjIsCo(Abc_ObjFanout0(Abc_ObjFanout0(pObj))) ) + { + int iLit = Abc_Var2Lit( Abc_ObjId( Abc_ObjFanin0(Abc_ObjFanin0(pObj)) ), Abc_NodeIsInv(pObj) ); + int iObj = Vec_IntEntry( vMap, iLit ); diff --git a/abc.spec b/abc.spec index ba3ef1e..1934b6c 100644 --- a/abc.spec +++ b/abc.spec @@ -1,7 +1,7 @@ # Upstream doesn't make releases. We have to check the code out of git. -%global gittag 66a5fe7aecd88d3fb0a70cc87aacc642b2d67c8c +%global gittag e61194bbed8c2ba8aac1f2720ebe513a571ee664 %global shorttag %(cut -b -7 <<< %{gittag}) -%global gitdate 20221229 +%global gitdate 20230708 # WARNING: When updating to a newer snapshot, because upstream doesn't do # shared library versioning, run abipkgdiff (from libabigail) against the @@ -21,7 +21,7 @@ Name: abc Version: 1.01 -Release: 37.git%{gitdate}%{?dist} +Release: 40.git%{gitdate}%{?dist} Summary: Sequential logic synthesis and formal verification # The ABC code itself is MIT-Modern-Variant. @@ -48,17 +48,14 @@ Patch4: %{name}-format.patch # Fix an out-of-bounds array access in the gia code # https://github.com/berkeley-abc/abc/pull/89 Patch5: %{name}-gia.patch -# Prevent a possible buffer overflow -Patch6: %{name}-overflow.patch -# Fix two cases of use-after-free -# https://github.com/berkeley-abc/abc/pull/193 -Patch7: %{name}-use-after-free.patch # Do not pass NULL to fprintf # https://github.com/berkeley-abc/abc/pull/194 -Patch8: %{name}-null-fprintf.patch +Patch6: %{name}-null-fprintf.patch # Weaken an overzealous assert # https://bitbucket.org/alanmi/abc/issue/27/assertion-failure-in-write_pla-command -Patch9: %{name}-weaken-assert.patch +Patch7: %{name}-weaken-assert.patch +# yosys aiger segfault (yosyshq downstream commit): +Patch8: abc-yosys-segfault.patch BuildRequires: cmake BuildRequires: gcc-c++ @@ -169,6 +166,16 @@ install -p -m 0644 %{name}.1 %{buildroot}%{_mandir}/man1 %{_libdir}/lib%{name}.so %changelog +* Sun Jul 30 2023 Gabriel Somlo - 1.01-40.git20230708 +- Apply patch from yosyshq to fix yosys FTBFS (#2226521) + +* Wed Jul 19 2023 Fedora Release Engineering - 1.01-39.git20230708 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Fri Jul 14 2023 Jerry James - 1.01-38.git20230708 +- Update to latest git snapshot +- Drop upstreamed patches: overflow, use-after-free + * Wed Jan 18 2023 Fedora Release Engineering - 1.01-37.git20221229 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild diff --git a/sources b/sources index 97fbc0b..d6e0d0c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (abc-66a5fe7.tar.gz) = 1bd28a063e4d30727ca911f47f5fe8ecea1c08feecefcc459c1839b5b6df83c3f6393de8379195481171aa137150a847d4cef052fbfaba194dd7cb428c433254 +SHA512 (abc-e61194b.tar.gz) = cd8b524b90f543ed1f6ecb6597ebedd78b7a6c0c8e65c078d655b213f1752397fdab111be3eb6828c3a758782127d0abe60cfe2729358d3bef8f97b17bfebe90