'C++ compiling incubator-pagespeed-mod with newer sparse_hash_map lib (systemlib) results in errors

i trying to build pagespeed-mod and have a problem who I have no idea how to fix that.

I tried it booth - with the embedded lib old 0.7 google sparsehash lib it compiles - but fails when i configure NGINX with the mod - when i add the newer lib (sparsehash from alpine repo) psol build failed.

I trying to make a patch file to embed the lib directly in the source and rename the typedef correctly like so:

  typedef google::sparse_hash_map<
    GoogleString, const char*,
    CaseFoldStringHash,
    CaseFoldStringEqual> StringStringSparseHashMapInsensitive;
  typedef google::sparse_hash_map<
    GoogleString, const char*,
    CasePreserveStringHash> StringStringSparseHashMapSensitive;

It is the only usage of that lib, but the build fails to build with the same error.

Here is the error that I get:

#30 2561.8 In file included from /usr/include/sparsehash/internal/sparsehashtable.h:104,
#30 2561.8                  from /usr/include/sparsehash/sparse_hash_map:93,
#30 2561.8                  from ./pagespeed/kernel/html/html_keywords.h:27,
#30 2561.8                  from pagespeed/kernel/util/statistics_logger.cc:42:
#30 2561.8 /usr/include/sparsehash/type_traits.h:94:52: error: expected class-name before '{' token
#30 2561.8    94 | template <class T> struct is_integral : false_type { };
#30 2561.8       |                                                    ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:95:49: error: expected class-name before '{' token
#30 2561.8    95 | template<> struct is_integral<bool> : true_type { };
#30 2561.8       |                                                 ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:96:49: error: expected class-name before '{' token
#30 2561.8    96 | template<> struct is_integral<char> : true_type { };
#30 2561.8       |                                                 ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:97:58: error: expected class-name before '{' token
#30 2561.8    97 | template<> struct is_integral<unsigned char> : true_type { };
#30 2561.8       |                                                          ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:98:56: error: expected class-name before '{' token
#30 2561.8    98 | template<> struct is_integral<signed char> : true_type { };
#30 2561.8       |                                                        ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:105:52: error: expected class-name before '{' token
#30 2561.8   105 | template<> struct is_integral<wchar_t> : true_type { };
#30 2561.8       |                                                    ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:107:50: error: expected class-name before '{' token
#30 2561.8   107 | template<> struct is_integral<short> : true_type { };
#30 2561.8       |                                                  ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:108:59: error: expected class-name before '{' token
#30 2561.8   108 | template<> struct is_integral<unsigned short> : true_type { };
#30 2561.8       |                                                           ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:109:48: error: expected class-name before '{' token
#30 2561.8   109 | template<> struct is_integral<int> : true_type { };
#30 2561.8       |                                                ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:110:57: error: expected class-name before '{' token
#30 2561.8   110 | template<> struct is_integral<unsigned int> : true_type { };
#30 2561.8       |                                                         ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:111:49: error: expected class-name before '{' token
#30 2561.8   111 | template<> struct is_integral<long> : true_type { };
#30 2561.8       |                                                 ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:112:58: error: expected class-name before '{' token
#30 2561.8   112 | template<> struct is_integral<unsigned long> : true_type { };
#30 2561.8       |                                                          ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:114:54: error: expected class-name before '{' token
#30 2561.8   114 | template<> struct is_integral<long long> : true_type { };
#30 2561.8       |                                                      ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:115:63: error: expected class-name before '{' token
#30 2561.8   115 | template<> struct is_integral<unsigned long long> : true_type { };
#30 2561.8       |                                                               ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:123:58: error: expected class-name before '{' token
#30 2561.8   123 | template <class T> struct is_floating_point : false_type { };
#30 2561.8       |                                                          ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:124:56: error: expected class-name before '{' token
#30 2561.8   124 | template<> struct is_floating_point<float> : true_type { };
#30 2561.8       |                                                        ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:125:57: error: expected class-name before '{' token
#30 2561.8   125 | template<> struct is_floating_point<double> : true_type { };
#30 2561.8       |                                                         ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:126:62: error: expected class-name before '{' token
#30 2561.8   126 | template<> struct is_floating_point<long double> : true_type { };
#30 2561.8       |                                                              ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:137:51: error: expected class-name before '{' token
#30 2561.8   137 | template <class T> struct is_pointer : false_type { };
#30 2561.8       |                                                   ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:138:54: error: expected class-name before '{' token
#30 2561.8   138 | template <class T> struct is_pointer<T*> : true_type { };
#30 2561.8       |                                                      ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:148:29: error: 'small_' does not name a type
#30 2561.8   148 |   template <class U> static small_ tester(void (U::*)());
#30 2561.8       |                             ^~~~~~
#30 2561.8 /usr/include/sparsehash/type_traits.h:149:29: error: 'big_' does not name a type
#30 2561.8   149 |   template <class U> static big_ tester(...);
#30 2561.8       |                             ^~~~
#30 2561.8 /usr/include/sparsehash/type_traits.h:150:36: error: 'tester' was not declared in this scope
#30 2561.8   150 |   static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
#30 2561.8       |                                    ^~~~~~
#30 2561.8 /usr/include/sparsehash/type_traits.h:150:44: error: expected primary-expression before '>' token
#30 2561.8   150 |   static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
#30 2561.8       |                                            ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:150:60: error: 'small_' was not declared in this scope
#30 2561.8   150 |   static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
#30 2561.8       |                                                            ^~~~~~
#30 2561.8 /usr/include/sparsehash/type_traits.h:158:62: error: expected class-name before '{' token
#30 2561.8   158 | template <class T> struct is_enum_impl<true, T> : false_type { };
#30 2561.8       |                                                              ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:193:55: error: expected class-name before '{' token
#30 2561.8   193 | template<typename T> struct is_reference : false_type {};
#30 2561.8       |                                                       ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:194:58: error: expected class-name before '{' token
#30 2561.8   194 | template<typename T> struct is_reference<T&> : true_type {};
#30 2561.8       |                                                          ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:202:21: error: expected template-name before '<' token
#30 2561.8   202 |  : integral_constant<bool, (is_integral<T>::value ||
#30 2561.8       |                     ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:202:21: error: expected '{' before '<' token
#30 2561.8 /usr/include/sparsehash/type_traits.h:221:22: error: expected template-name before '<' token
#30 2561.8   221 |   : integral_constant<bool,
#30 2561.8       |                      ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:221:22: error: expected '{' before '<' token
#30 2561.8 /usr/include/sparsehash/type_traits.h:236:22: error: expected template-name before '<' token
#30 2561.8   236 |   : integral_constant<bool,
#30 2561.8       |                      ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:236:22: error: expected '{' before '<' token
#30 2561.8 /usr/include/sparsehash/type_traits.h:249:22: error: expected template-name before '<' token
#30 2561.8   249 |   : integral_constant<bool,
#30 2561.8       |                      ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:249:22: error: expected '{' before '<' token
#30 2561.8 /usr/include/sparsehash/type_traits.h:262:22: error: expected template-name before '<' token
#30 2561.8   262 |   : integral_constant<bool,
#30 2561.8       |                      ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:262:22: error: expected '{' before '<' token
#30 2561.8 /usr/include/sparsehash/type_traits.h:296:69: error: expected class-name before '{' token
#30 2561.8   296 | template<typename T, typename U> struct is_same : public false_type { };
#30 2561.8       |                                                                     ^
#30 2561.8 /usr/include/sparsehash/type_traits.h:297:62: error: expected class-name before '{' token
#30 2561.8   297 | template<typename T> struct is_same<T, T> : public true_type { };
#30 2561.8       |                                                              ^
#30 2561.9 /usr/include/sparsehash/type_traits.h:314:10: error: 'small_' does not name a type
#30 2561.9   314 |   static small_ Test(To);
#30 2561.9       |          ^~~~~~
#30 2561.9 /usr/include/sparsehash/type_traits.h:315:10: error: 'big_' does not name a type
#30 2561.9   315 |   static big_ Test(...);
#30 2561.9       |          ^~~~
#30 2561.9 /usr/include/sparsehash/type_traits.h:323:24: error: expected template-name before '<' token
#30 2561.9   323 |     : integral_constant<bool,
#30 2561.9       |                        ^
#30 2561.9 /usr/include/sparsehash/type_traits.h:323:24: error: expected '{' before '<' token
#30 2561.9 In file included from /usr/include/sparsehash/internal/sparsehashtable.h:106,
#30 2561.9                  from /usr/include/sparsehash/sparse_hash_map:93,
#30 2561.9                  from ./pagespeed/kernel/html/html_keywords.h:27,
#30 2561.9                  from pagespeed/kernel/util/statistics_logger.cc:42:
#30 2561.9 /usr/include/sparsehash/sparsetable:266:25: error: 'true_type' has not been declared in 'google'
#30 2561.9   266 | using GOOGLE_NAMESPACE::true_type;
#30 2561.9       |                         ^~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:267:25: error: 'false_type' has not been declared in 'google'
#30 2561.9   267 | using GOOGLE_NAMESPACE::false_type;
#30 2561.9       |                         ^~~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:268:25: error: 'integral_constant' has not been declared in 'google'
#30 2561.9   268 | using GOOGLE_NAMESPACE::integral_constant;
#30 2561.9       |                         ^~~~~~~~~~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1086:40: error: 'google::base::true_type' has not been declared
#30 2561.9  1086 |   void set_aux(size_type offset, base::true_type) {
#30 2561.9       |                                        ^~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1098:40: error: 'google::base::false_type' has not been declared
#30 2561.9  1098 |   void set_aux(size_type offset, base::false_type) {
#30 2561.9       |                                        ^~~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1098:8: error: 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::set_aux(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type, int)' cannot be overloaded with 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::set_aux(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type, int)'
#30 2561.9  1098 |   void set_aux(size_type offset, base::false_type) {
#30 2561.9       |        ^~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1086:8: note: previous declaration 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::set_aux(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type, int)'
#30 2561.9  1086 |   void set_aux(size_type offset, base::true_type) {
#30 2561.9       |        ^~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1151:42: error: 'google::base::true_type' has not been declared
#30 2561.9  1151 |   void erase_aux(size_type offset, base::true_type) {
#30 2561.9       |                                          ^~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1168:42: error: 'google::base::false_type' has not been declared
#30 2561.9  1168 |   void erase_aux(size_type offset, base::false_type) {
#30 2561.9       |                                          ^~~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1168:8: error: 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::erase_aux(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type, int)' cannot be overloaded with 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::erase_aux(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type, int)'
#30 2561.9  1168 |   void erase_aux(size_type offset, base::false_type) {
#30 2561.9       |        ^~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1151:8: note: previous declaration 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::erase_aux(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type, int)'
#30 2561.9  1151 |   void erase_aux(size_type offset, base::true_type) {
#30 2561.9       |        ^~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable: In member function 'google::sparsegroup<T, GROUP_SIZE, Alloc>::reference google::sparsegroup<T, GROUP_SIZE, Alloc>::set(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type, google::sparsegroup<T, GROUP_SIZE, Alloc>::const_reference)':
#30 2561.9 /usr/include/sparsehash/sparsetable:1118:21: error: 'integral_constant' in namespace 'google::base' does not name a template type
#30 2561.9  1118 |       typedef base::integral_constant<bool,
#30 2561.9       |                     ^~~~~~~~~~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1125:23: error: there are no arguments to 'realloc_and_memmove_ok' that depend on a template parameter, so a declaration of 'realloc_and_memmove_ok' must be available [-fpermissive]
#30 2561.9  1125 |       set_aux(offset, realloc_and_memmove_ok());
#30 2561.9       |                       ^~~~~~~~~~~~~~~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1125:23: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
#30 2561.9 /usr/include/sparsehash/sparsetable: In member function 'void google::sparsegroup<T, GROUP_SIZE, Alloc>::erase(google::sparsegroup<T, GROUP_SIZE, Alloc>::size_type)':
#30 2561.9 /usr/include/sparsehash/sparsetable:1190:23: error: 'integral_constant' in namespace 'google::base' does not name a template type
#30 2561.9  1190 |         typedef base::integral_constant<bool,
#30 2561.9       |                       ^~~~~~~~~~~~~~~~~
#30 2561.9 /usr/include/sparsehash/sparsetable:1197:27: error: there are no arguments to 'realloc_and_memmove_ok' that depend on a template parameter, so a declaration of 'realloc_and_memmove_ok' must be available [-fpermissive]
#30 2561.9  1197 |         erase_aux(offset, realloc_and_memmove_ok());
#30 2561.9       |                           ^~~~~~~~~~~~~~~~~~~~~~
#30 2562.0   CXX(target) out/Release/obj.target/util/pagespeed/kernel/util/url_to_filename_encoder.o
#30 2562.3 make[1]: *** [pagespeed/util.target.mk:323: out/Release/obj.target/util/pagespeed/kernel/util/statistics_logger.o] Error 1
#30 2562.3 make[1]: *** Waiting for unfinished jobs....
#30 2563.1 make: *** [Makefile:209: build_libraries] Error 2

Can someone help me please to resolve this error? The code is building on an Alpine I managed that with some patches (Source for some patches are the patches from FreeBSD: https://svnweb.freebsd.org/ports/head/www/mod_pagespeed/files/?pathrev=548979) Mostly only the OpenSSL 1.1 Support patch.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source