Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphite Fails to Compile in recent Electronite version 20 - std::iterator deprecated #76

Closed
PhotoNomad0 opened this issue Nov 3, 2022 · 4 comments
Assignees
Labels

Comments

@PhotoNomad0
Copy link

Electronite is a fork of Electron that adds Graphite support. And starting with Electron v20.3.3 (https://github.com/unfoldingWord/electronite/tree/electronite-v20.3.3-beta), graphite fails to compile in the Electron Build environment. I am getting similar build errors in Windows, MacOS, and LInux that are related to the use of std::iterator.

In building for Windows, I get the error:

"[5 processes, 3768/44375 @ 2.9/s : 1289.525s] "CXX obj/third_party/graphite/graphite_source/GlyphCache.obj
FAILED: obj/third_party/graphite/graphite_source/GlyphCache.obj
..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe /c ../../third_party/graphite/graphite2/src/GlyphCache.cpp /Foobj/third_party/graphite/graphite_source/GlyphCache.obj /nologo /showIncludes:user "-imsvcC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-imsvcC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include" "-imsvcC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\ucrt" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\shared" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\um" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\winrt" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\cppwinrt" -DGRAPHITE2_NTRACING -DGRAPHITE2_NSEGCACHE -DGRAPHITE2_NFILEFACE -DUSE_AURA=1 -DOFFICIAL_BUILD "-DCR_CLANG_REVISION=\"llvmorg-15-init-11722-g3f3a235a-2\"" -D_LIBCPP_ABI_NAMESPACE=Cr -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_NO_AUTO_LINK -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_FE -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D_CRT_NONSTDC_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DGRAPHITE2_STATIC -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/graphite/graphite2/src -I../../third_party/graphite/graphite2/include -fno-delete-null-pointer-checks -fno-ident -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 /clang:-ffp-contract=off -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase -ffile-reproducible /Zc:sizedDealloc- /D__WRL_ENABLE_FUNCTION_STATICS__ -fmsc-version=1916 -m64 -msse3 -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern /O2 /Ob2 /Oy- /Zc:inline /Gw /Oi /Z7 -gcodeview-ghash -Xclang -fuse-ctor-homing -fprofile-use=../../chrome/build/pgo_profiles/chrome-win64-5112-1659522760-a359105fb1eb14e8c5d61b542f3a35d55c6ea4fc.profdata -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date -Wno-backend-plugin /guard:cf /MT -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang raw-ptr-template-as-trivial-member -Xclang -plugin-arg-find-bad-constructs -Xclang use-classify-type -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare /W3 /wd4800 /wd4267 -Wno-unused-variable -Wno-c++11-narrowing -Wno-unused-but-set-variable -Wno-misleading-indentation /WX -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-nonportable-include-path -Wno-null-pointer-subtraction -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Xclang -no-opaque-pointers /std:c++17 -Wno-trigraphs /Zc:alignedNew- /TP /GR- -I../../buildtools/third_party/libc++/trunk/include /Fd"obj/third_party/graphite/graphite_source_cc.pdb"
../../third_party/graphite/graphite2/src/GlyphCache.cpp(47,40): error: 'iterator<std::input_iterator_tag, std::pair<unsigned short, unsigned short>>' is deprecated [-Werror,-Wdeprecated-declarations]
    class _glat_iterator : public std::iterator<std::input_iterator_tag, std::pair<sparse::key_type, sparse::mapped_type> >
                                       ^
../../buildtools/third_party/libc++/trunk/include\__iterator/iterator.h(24,29): note: 'iterator<std::input_iterator_tag, std::pair<unsigned short, unsigned short>>' has been explicitly marked deprecated here
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator
                            ^
../../buildtools/third_party/libc++/trunk/include\__config(912,39): note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
#  define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
                                      ^
../../buildtools/third_party/libc++/trunk/include\__config(889,48): note: expanded from macro '_LIBCPP_DEPRECATED'
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))               

And in building for Linux, I get the error:

[6 processes, 756/41382 @ 22.0/s : 34.433s] CXX obj/third_party/graphite/graphite_source/GlyphCache.o
FAILED: obj/third_party/graphite/graphite_source/GlyphCache.o 
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/third_party/graphite/graphite_source/GlyphCache.o.d -DGRAPHITE2_NTRACING -DGRAPHITE2_NSEGCACHE -DGRAPHITE2_NFILEFACE -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -DOFFICIAL_BUILD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D_GNU_SOURCE -DCR_CLANG_REVISION=\"llvmorg-15-init-11722-g3f3a235a-2\" -D_LIBCPP_ABI_NAMESPACE=Cr -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -DCR_LIBCXX_REVISION=b1269813eaf5b8ac78e35e45a0f7cc320bd3e7d6 -DCR_SYSROOT_HASH=202e5738f4fad834a43ad9978efc53ff710ee979 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/graphite/graphite2/src -I../../third_party/graphite/graphite2/include -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers -m64 -msse3 -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O2 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-omit-frame-pointer -gdwarf-4 -g2 -gdwarf-aranges -ggnu-pubnames -Xclang -fuse-ctor-homing -fprofile-use=../../chrome/build/pgo_profiles/chrome-linux-5112-1659546792-1870321c902fd7dca1271b1e96ff9ea74063d09a.profdata -Wno-profile-instr-unprofiled -Wno-profile-instr-out-of-date -Wno-backend-plugin -fvisibility=hidden -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang raw-ptr-template-as-trivial-member -Xclang -plugin-arg-find-bad-constructs -Xclang use-classify-type -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Werror -Wall -Wno-unused-variable -Wno-c++11-narrowing -Wno-unused-but-set-variable -Wno-misleading-indentation -Wno-missing-field-initializers -Wno-unused-parameter -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-psabi -Wno-ignored-pragma-optimize -Wno-unqualified-std-cast-call -Xclang -no-opaque-pointers -Wall -Wextra -Wno-unknown-pragmas -Wendif-labels -Wshadow -Wctor-dtor-privacy -Wnon-virtual-dtor -std=c++17 -Wno-trigraphs -fno-aligned-new -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -c ../../third_party/graphite/graphite2/src/GlyphCache.cpp -o obj/third_party/graphite/graphite_source/GlyphCache.o
../../third_party/graphite/graphite2/src/GlyphCache.cpp:47:40: error: 'iterator<std::input_iterator_tag, std::pair<unsigned short, unsigned short>>' is deprecated [-Werror,-Wdeprecated-declarations]
    class _glat_iterator : public std::iterator<std::input_iterator_tag, std::pair<sparse::key_type, sparse::mapped_type> >
                                       ^
../../buildtools/third_party/libc++/trunk/include/__iterator/iterator.h:24:29: note: 'iterator<std::input_iterator_tag, std::pair<unsigned short, unsigned short>>' has been explicitly marked deprecated here
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator
                            ^
../../buildtools/third_party/libc++/trunk/include/__config:912:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'
#  define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
                                      ^
../../buildtools/third_party/libc++/trunk/include/__config:889:48: note: expanded from macro '_LIBCPP_DEPRECATED'
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))

And in building for MacOS, the error message is similar to Linux.

It appears that starting in Electron v20, the build environment has changed so that this has been escalated from a build warning to an error.

I found this posting that explains the change in implementation of std::iterator: https://stackoverflow.com/questions/43268146/why-is-stditerator-deprecated

@PhotoNomad0
Copy link
Author

PhotoNomad0 commented Nov 3, 2022

I was able to update GlyphCache.cpp, and graphite now compiles in Electron v20. Here is a patch:

diff --git a/src/GlyphCache.cpp b/src/GlyphCache.cpp
index 282bdc18..336de3f1 100644
--- a/src/GlyphCache.cpp
+++ b/src/GlyphCache.cpp
@@ -44,12 +44,18 @@ namespace
     // variable length structures.
 
     template<typename W>
-    class _glat_iterator : public std::iterator<std::input_iterator_tag, std::pair<sparse::key_type, sparse::mapped_type> >
+    class _glat_iterator
     {
         unsigned short  key() const             { return uint16(be::peek<W>(_e) + _n); }
         unsigned int    run() const             { return be::peek<W>(_e+sizeof(W)); }
         void            advance_entry()         { _n = 0; _e = _v; be::skip<W>(_v,2); }
     public:
+        using iterator_category = std::input_iterator_tag;
+        using value_type = std::pair<sparse::key_type, sparse::mapped_type>;
+        using difference_type = std::pair<sparse::key_type, sparse::mapped_type>;
+        using pointer = std::pair<sparse::key_type, sparse::mapped_type>*;
+        using reference = std::pair<sparse::key_type, sparse::mapped_type>&;
+        
         _glat_iterator(const void * glat=0) : _e(reinterpret_cast<const byte *>(glat)), _v(_e+2*sizeof(W)), _n(0) {}
 
         _glat_iterator<W> & operator ++ () {

@PhotoNomad0 PhotoNomad0 changed the title Graphite Fails to Compile in recent Electronite version 20 Graphite Fails to Compile in recent Electronite version 20 - std::iterator deprecated Nov 5, 2022
@marksvc
Copy link

marksvc commented Nov 14, 2022

I was getting this error when compiling Graphite2 in FieldWorks with more recent Linux libraries / gcc. Thanks @PhotoNomad0 !

@marksvc
Copy link

marksvc commented Nov 14, 2022

Your example gives me more confidence about implementing what I saw at https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/ .

@PhotoNomad0
Copy link
Author

Your example gives me more confidence about implementing what I saw at https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/ .

Glad it helped you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants