From b6fe562f8993d3b8b1f653dc3aff0aeb867d66d9 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Fri, 17 Mar 2023 19:47:18 +0100 Subject: [PATCH 1/3] bump darwin gcc version to 12 TODO: get rid of gcc on darwin, we should use clang for native darwin builds. --- .github/workflows/komodo_mac_ci.yml | 2 +- .github/workflows/komodod_cd.yml | 2 +- README.md | 2 +- depends/builders/darwin.mk | 8 ++++---- depends/hosts/darwin.mk | 4 ++-- src/cc/Makefile_custom | 2 +- src/cc/Makefile_rogue | 2 +- src/komodo.cpp | 2 +- toolchain-info.sh | 2 +- zcutil/build-mac-dtest.sh | 4 ++-- zcutil/build-mac.sh | 4 ++-- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/komodo_mac_ci.yml b/.github/workflows/komodo_mac_ci.yml index 933165b3cbb..f8ea3454118 100644 --- a/.github/workflows/komodo_mac_ci.yml +++ b/.github/workflows/komodo_mac_ci.yml @@ -26,7 +26,7 @@ jobs: brew upgrade || true brew tap discoteq/discoteq; brew install flock brew install autoconf autogen automake - brew install gcc@8 + brew install gcc@12 brew install binutils brew install protobuf brew install coreutils diff --git a/.github/workflows/komodod_cd.yml b/.github/workflows/komodod_cd.yml index 78cd31ca2f1..eabe2183562 100644 --- a/.github/workflows/komodod_cd.yml +++ b/.github/workflows/komodod_cd.yml @@ -81,7 +81,7 @@ jobs: brew upgrade || true brew tap discoteq/discoteq; brew install flock brew install autoconf autogen automake - brew install gcc@8 + brew install gcc@12 brew install binutils brew install protobuf brew install coreutils diff --git a/README.md b/README.md index 9568c70741a..82f2224f65b 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ brew update brew upgrade brew tap discoteq/discoteq; brew install flock brew install autoconf autogen automake -brew update && brew install gcc@8 +brew update && brew install gcc@12 brew install binutils brew install protobuf brew install coreutils diff --git a/depends/builders/darwin.mk b/depends/builders/darwin.mk index cbbc5a667ab..71615d1f420 100644 --- a/depends/builders/darwin.mk +++ b/depends/builders/darwin.mk @@ -1,5 +1,5 @@ -build_darwin_CC = gcc-8 -build_darwin_CXX = g++-8 +build_darwin_CC = gcc-12 +build_darwin_CXX = g++-12 build_darwin_AR: = $(shell xcrun -f ar) build_darwin_RANLIB: = $(shell xcrun -f ranlib) build_darwin_STRIP: = $(shell xcrun -f strip) @@ -10,8 +10,8 @@ build_darwin_SHA256SUM = shasum -a 256 build_darwin_DOWNLOAD = curl --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -L -f -o #darwin host on darwin builder. overrides darwin host preferences. -darwin_CC= gcc-8 -darwin_CXX= g++-8 +darwin_CC= gcc-12 +darwin_CXX= g++-12 darwin_AR:=$(shell xcrun -f ar) darwin_RANLIB:=$(shell xcrun -f ranlib) darwin_STRIP:=$(shell xcrun -f strip) diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 43a4c88f2ab..9b0c9e6536e 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -2,8 +2,8 @@ OSX_MIN_VERSION=10.12 OSX_SDK_VERSION=10.12 OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=253.9 -darwin_CC=gcc-8 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -darwin_CXX=g++-8 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CC=gcc-12 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CXX=g++-12 -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CFLAGS=-pipe darwin_CXXFLAGS=$(darwin_CFLAGS) diff --git a/src/cc/Makefile_custom b/src/cc/Makefile_custom index 364f9f4a121..e7835182f01 100755 --- a/src/cc/Makefile_custom +++ b/src/cc/Makefile_custom @@ -1,6 +1,6 @@ SHELL = /bin/sh CC = gcc -CC_DARWIN = g++-8 +CC_DARWIN = g++-12 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -DBUILD_CUSTOMCC -std=c++11 -arch x86_64 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared diff --git a/src/cc/Makefile_rogue b/src/cc/Makefile_rogue index 3b2f65e00f6..fe1c63b940b 100644 --- a/src/cc/Makefile_rogue +++ b/src/cc/Makefile_rogue @@ -1,6 +1,6 @@ SHELL = /bin/sh CC = gcc -CC_DARWIN = g++-8 +CC_DARWIN = g++-12 CC_WIN = x86_64-w64-mingw32-gcc-posix CFLAGS_DARWIN = -DBUILD_ROGUE -std=c++11 -arch x86_64 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared diff --git a/src/komodo.cpp b/src/komodo.cpp index 0164301d2d6..b21c946e60d 100644 --- a/src/komodo.cpp +++ b/src/komodo.cpp @@ -831,7 +831,7 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) return(-1); fprintf(stderr,"komodo_connectblock: unxexpected behaviour when fJustCheck == true, report blackjok3rtt plz ! \n"); - /* this needed by gcc-8, it counts here that control reaches end of non-void function without this. + /* this needed by gcc-12, it counts here that control reaches end of non-void function without this. by default, we count that if control reached here -> the valid notarization isnt in position 1 or there are too many notarizations in this block. */ return(-1); diff --git a/toolchain-info.sh b/toolchain-info.sh index 6a0fc7e75af..f313f67b3f7 100755 --- a/toolchain-info.sh +++ b/toolchain-info.sh @@ -1,6 +1,6 @@ #!/bin/bash -tools=("gcc-8" "g++-8" "otool" "nm") +tools=("gcc-12" "g++-12" "otool" "nm") echo "Platform: `uname -a`" echo "-------------------------------------" diff --git a/zcutil/build-mac-dtest.sh b/zcutil/build-mac-dtest.sh index 701aab871af..5a772b4cd6d 100755 --- a/zcutil/build-mac-dtest.sh +++ b/zcutil/build-mac-dtest.sh @@ -1,6 +1,6 @@ #!/bin/bash -export CC=gcc-8 -export CXX=g++-8 +export CC=gcc-12 +export CXX=g++-12 export LIBTOOL=libtool export AR=ar export RANLIB=ranlib diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index 77a5e764ecf..39f95ac326e 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -1,6 +1,6 @@ #!/bin/bash -export CC=gcc-8 -export CXX=g++-8 +export CC=gcc-12 +export CXX=g++-12 export LIBTOOL=libtool export AR=ar export RANLIB=ranlib From 88fcf1cdb5d4026aa666695d88cc13b79b3ac94f Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Fri, 17 Mar 2023 20:31:29 +0100 Subject: [PATCH 2/3] fix write NUL byte to the end of out ``` cc/import.cpp: In function 'int32_t CheckCODAimport(CTransaction, CTransaction, std::vector, std::string, std::string)': cc/import.cpp:260:12: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 260 | out[65]='\0'; | ~~~~~~~^~~~~ cc/import.cpp:247:44: note: at offset 65 into destination object 'out' of size 65 247 | cJSON *result,*tmp,*tmp1; char *retstr,out[SHA256_DIGEST_LENGTH*2+1]; int i,n,m; | ^~~ ``` actually this is not needed, and the line out[64]='\0' could be commented, as sprintf actually writes 3 bytes per call, i.e. for hash[i] = 0xca, it will actually write the following sequence of bytes 'c', 'a', 0x00. So, end of string will be always with end NUL byte. --- src/cc/import.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 13a2325dac3..331c868b237 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -257,7 +257,7 @@ int32_t CheckCODAimport(CTransaction importTx,CTransaction burnTx,std::vector Date: Fri, 17 Mar 2023 20:34:32 +0100 Subject: [PATCH 3/3] add -Wno-deprecated-declarations to darwin build --- zcutil/build-mac.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index 39f95ac326e..2c65d335c63 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -57,7 +57,7 @@ make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 ./autogen.sh CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \ -CXXFLAGS="-arch x86_64 -I/usr/local/Cellar/gcc\@8/8.3.0/include/c++/8.3.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -Wno-error=attributes -g -Wl,-undefined -Wl,dynamic_lookup" \ +CXXFLAGS="-arch x86_64 -I/usr/local/Cellar/gcc\@8/8.3.0/include/c++/8.3.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Wno-deprecated-declarations -Werror -Wno-error=attributes -g -Wl,-undefined -Wl,dynamic_lookup" \ ./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" "$DEBUGGING_ARG" make "$@" NO_GTEST=1 STATIC=1