blm768 / pg-libphonenumber

A (partially implemented!) PostgreSQL extension that provides access to Google's libphonenumber
Apache License 2.0
93 stars 7 forks source link

Compile failure related to cmath #10

Closed singingwolfboy closed 4 years ago

singingwolfboy commented 4 years ago

I was able to build this project in the past, and now I can't. I'm not sure if the error is caused by changes in the project, or changes in my development environment.

traceback for first problem
$ make
clang++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2  -fPIC -std=c++14 -Isrc/ -I/usr/include -Wall -Wextra -O3 -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -I/usr/local/Cellar/icu4c/64.2/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2   -c -o src/error_handling.o src/error_handling.cpp
In file included from src/error_handling.cpp:1:
src/error_handling.h:5:10: fatal error: 'phonenumbers/phonenumberutil.h' file
      not found
#include "phonenumbers/phonenumberutil.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [src/error_handling.o] Error 1

I was able to work around that by adding /usr/local/include to the list of include paths for C++ -- I installed libphonenumber via Homebrew, and Homebrew keeps everything under /usr/local.

After I fixed that, I ran into a different issue:

traceback for second issue
$ make
clang++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2  -fPIC -std=c++14 -Isrc/ -I/usr/include -I/usr/local/include -Wall -Wextra -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -O3 -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -I/usr/local/Cellar/icu4c/64.2/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/libxml2   -c -o src/error_handling.o src/error_handling.cpp
In file included from src/error_handling.cpp:1:
In file included from src/error_handling.h:5:
In file included from /usr/local/include/phonenumbers/phonenumberutil.h:29:
/usr/local/include/phonenumbers/base/memory/scoped_ptr.h:36:65: warning: unused
      parameter 'other' [-Wunused-parameter]
  template  DefaultDeleter(const DefaultDeleter& other) {
                                                                ^
In file included from src/error_handling.cpp:1:
In file included from src/error_handling.h:5:
In file included from /usr/local/include/phonenumbers/phonenumberutil.h:30:
In file included from /usr/local/include/phonenumbers/base/memory/singleton.h:91:
In file included from /usr/local/include/phonenumbers/base/memory/singleton_posix.h:18:
/usr/include/pthread.h:331:6: warning: macro expansion producing 'defined' has
      undefined behavior [-Wexpansion-to-defined]
#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
     ^
/usr/include/pthread.h:200:2: note: expanded from macro
      '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
        defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREA...
        ^
/usr/include/pthread.h:331:6: warning: macro expansion producing 'defined' has
      undefined behavior [-Wexpansion-to-defined]
/usr/include/pthread.h:200:34: note: expanded from macro
      '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
        defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREA...
                                        ^
/usr/include/pthread.h:540:6: warning: macro expansion producing 'defined' has
      undefined behavior [-Wexpansion-to-defined]
#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT
     ^
/usr/include/pthread.h:200:2: note: expanded from macro
      '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
        defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREA...
        ^
/usr/include/pthread.h:540:6: warning: macro expansion producing 'defined' has
      undefined behavior [-Wexpansion-to-defined]
/usr/include/pthread.h:200:34: note: expanded from macro
      '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
        defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREA...
                                        ^
In file included from src/error_handling.cpp:1:
In file included from src/error_handling.h:5:
In file included from /usr/local/include/phonenumbers/phonenumberutil.h:31:
In file included from /usr/local/include/phonenumbers/phonenumber.pb.h:23:
In file included from /usr/local/include/google/protobuf/io/coded_stream.h:143:
In file included from /usr/local/include/google/protobuf/stubs/strutil.h:39:
In file included from /usr/local/include/google/protobuf/stubs/stringpiece.h:152:
In file included from /usr/local/include/google/protobuf/stubs/hash.h:39:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:408:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:19:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:314:9: error: 
      no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:315:9: error: 
      no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:316:9: error: 
      no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/usr/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from src/error_handling.cpp:1:
In file included from src/error_handling.h:5:
In file included from /usr/local/include/phonenumbers/phonenumberutil.h:31:
In file included from /usr/local/include/phonenumbers/phonenumber.pb.h:23:
In file included from /usr/local/include/google/protobuf/io/coded_stream.h:143:
In file included from /usr/local/include/google/protobuf/stubs/strutil.h:39:
In file included from /usr/local/include/google/protobuf/stubs/stringpiece.h:152:
In file included from /usr/local/include/google/protobuf/stubs/hash.h:39:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:408:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:19:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error: 
      no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error: 
      no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error: 
      no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:7: error: 
      no member named 'isgreater' in the global namespace; did you mean
      '::std::greater'?
using ::isgreater;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:728:29: note: 
      '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
                            ^
In file included from src/error_handling.cpp:1:
In file included from src/error_handling.h:5:
In file included from /usr/local/include/phonenumbers/phonenumberutil.h:31:
In file included from /usr/local/include/phonenumbers/phonenumber.pb.h:23:
In file included from /usr/local/include/google/protobuf/io/coded_stream.h:143:
In file included from /usr/local/include/google/protobuf/stubs/strutil.h:39:
In file included from /usr/local/include/google/protobuf/stubs/stringpiece.h:152:
In file included from /usr/local/include/google/protobuf/stubs/hash.h:39:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:408:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:19:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:7: error: 
      no member named 'isgreaterequal' in the global namespace; did you mean
      '::std::greater_equal'?
using ::isgreaterequal;
      ^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:757:29: note: 
      '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
                            ^
In file included from src/error_handling.cpp:1:
In file included from src/error_handling.h:5:
In file included from /usr/local/include/phonenumbers/phonenumberutil.h:31:
In file included from /usr/local/include/phonenumbers/phonenumber.pb.h:23:
In file included from /usr/local/include/google/protobuf/io/coded_stream.h:143:
In file included from /usr/local/include/google/protobuf/stubs/strutil.h:39:
In file included from /usr/local/include/google/protobuf/stubs/stringpiece.h:152:
In file included from /usr/local/include/google/protobuf/stubs/hash.h:39:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:408:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:19:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error: 
      no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:9: error: 
      no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:9: error: 
      no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error: 
      no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error: 
      no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
5 warnings and 13 errors generated.
make: *** [src/error_handling.o] Error 1

I have not found a workaround for this issue. It appears that the latest development toolchain on macOS has problems with the <cmath> headers -- I think this is the same problem.

I'm running macOS 10.14.6, Xcode 11.2.1. Not sure what other debugging information would be useful.

blm768 commented 4 years ago

Are you building from the master branch or the new_phone_number branch? I haven't put any commits into master for a while, so if you're building master, it's probably a change in your development environment.

The errors seem to be in headers that are transitively included by the libphonenumber headers, so it may also be related to the version of libphonenumber you're using, but if you haven't changed which version of libphonenumber you're using, it's probably a problem with the Xcode toolchain.

singingwolfboy commented 4 years ago

I just checked, and the problem exists on both the master branch and the new_phone_number branch. ☹️

singingwolfboy commented 4 years ago

Upgrading to macOS Catalina, deleting and reinstalling Xcode, and deleting and reinstalling Homebrew solved the problem.