OpenMined / PyDP

The Python Differential Privacy Library. Built on top of: https://github.com/google/differential-privacy
Apache License 2.0
508 stars 139 forks source link

logging.cpp causing build error #144

Closed systemshift closed 4 years ago

systemshift commented 4 years ago

Expected Behavior

running build_PyDP.sh should have build PyDP without problems.

Current Behavior

it does not compile, likely as a result of the following error:

src/bindings/PyDP/base/logging.cpp:35:64: error: 'get_log_directory' is not a member of 'Logging_helper'
   35 |   obje.def_property_readonly("log_directory", &Logging_helper::get_log_directory);
      |                                                                ^~~~~~~~~~~~~~~~~
Target //src/python:bindings_test failed to build
INFO: Elapsed time: 3.712s, Critical Path: 3.51s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

Steps to Reproduce Behavior

I tried to build it by forking and cloning the repo, and following the contributor guide.

Steps to remove this behavior

By commenting out /src/bindings/PyDP/base/logging.cpp the build runs without errors

Logs

Are there any logs?

NFO: Analyzed target //src/python:bindings_test (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/user/PyDP/src/bindings/BUILD:4:1: C++ compilation of rule '//src/bindings:pydp.so' failed (Exit 1): gcc failed: error executing command 
  (cd /home/user/.cache/bazel/_bazel_user/9d5e4e56e0b6a0531adaa67be08db07e/sandbox/linux-sandbox/8/execroot/PyDP && \
  exec env - \
    PATH=/home/user/anaconda3/bin:/home/user/anaconda3/condabin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF bazel-out/k8-fastbuild/bin/src/bindings/_objs/pydp.so/logging.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/src/bindings/_objs/pydp.so/logging.pic.o' -fPIC -D__CLANG_SUPPORT_DYN_ANNOTATION__ -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/google_dp -iquote bazel-out/k8-fastbuild/bin/external/google_dp -iquote external/com_google_protobuf -iquote bazel-out/k8-fastbuild/bin/external/com_google_protobuf -iquote external/zlib -iquote bazel-out/k8-fastbuild/bin/external/zlib -iquote external/com_google_absl -iquote bazel-out/k8-fastbuild/bin/external/com_google_absl -iquote external/boringssl -iquote bazel-out/k8-fastbuild/bin/external/boringssl -iquote external/pybind11 -iquote bazel-out/k8-fastbuild/bin/external/pybind11 -iquote external/local_config_python -iquote bazel-out/k8-fastbuild/bin/external/local_config_python -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools -Ibazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_includes/any_proto -isystem external/com_google_protobuf/src -isystem bazel-out/k8-fastbuild/bin/external/com_google_protobuf/src -isystem external/zlib -isystem bazel-out/k8-fastbuild/bin/external/zlib -isystem external/boringssl/src/include -isystem bazel-out/k8-fastbuild/bin/external/boringssl/src/include -isystem external/pybind11/include -isystem bazel-out/k8-fastbuild/bin/external/pybind11/include -isystem external/local_config_python/python_include -isystem bazel-out/k8-fastbuild/bin/external/local_config_python/python_include -fexceptions '-fvisibility=hidden' -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c src/bindings/PyDP/base/logging.cpp -o bazel-out/k8-fastbuild/bin/src/bindings/_objs/pydp.so/logging.pic.o)
Execution platform: @local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox gcc failed: error executing command 
  (cd /home/user/.cache/bazel/_bazel_user/9d5e4e56e0b6a0531adaa67be08db07e/sandbox/linux-sandbox/8/execroot/PyDP && \
  exec env - \
    PATH=/home/user/anaconda3/bin:/home/user/anaconda3/condabin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF bazel-out/k8-fastbuild/bin/src/bindings/_objs/pydp.so/logging.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/src/bindings/_objs/pydp.so/logging.pic.o' -fPIC -D__CLANG_SUPPORT_DYN_ANNOTATION__ -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/google_dp -iquote bazel-out/k8-fastbuild/bin/external/google_dp -iquote external/com_google_protobuf -iquote bazel-out/k8-fastbuild/bin/external/com_google_protobuf -iquote external/zlib -iquote bazel-out/k8-fastbuild/bin/external/zlib -iquote external/com_google_absl -iquote bazel-out/k8-fastbuild/bin/external/com_google_absl -iquote external/boringssl -iquote bazel-out/k8-fastbuild/bin/external/boringssl -iquote external/pybind11 -iquote bazel-out/k8-fastbuild/bin/external/pybind11 -iquote external/local_config_python -iquote bazel-out/k8-fastbuild/bin/external/local_config_python -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools -Ibazel-out/k8-fastbuild/bin/external/com_google_protobuf/_virtual_includes/any_proto -isystem external/com_google_protobuf/src -isystem bazel-out/k8-fastbuild/bin/external/com_google_protobuf/src -isystem external/zlib -isystem bazel-out/k8-fastbuild/bin/external/zlib -isystem external/boringssl/src/include -isystem bazel-out/k8-fastbuild/bin/external/boringssl/src/include -isystem external/pybind11/include -isystem bazel-out/k8-fastbuild/bin/external/pybind11/include -isystem external/local_config_python/python_include -isystem bazel-out/k8-fastbuild/bin/external/local_config_python/python_include -fexceptions '-fvisibility=hidden' -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c src/bindings/PyDP/base/logging.cpp -o bazel-out/k8-fastbuild/bin/src/bindings/_objs/pydp.so/logging.pic.o)
Execution platform: @local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox
In file included from external/google_dp/differential_privacy/algorithms/bounded-algorithm.h:23,
                 from external/google_dp/differential_privacy/algorithms/bounded-mean.h:22,
                 from src/bindings/PyDP/base/../pydp_lib/casting.hpp:8,
                 from src/bindings/PyDP/base/logging.cpp:8:
external/google_dp/differential_privacy/algorithms/approx-bounds.h: In constructor 'differential_privacy::ApproxBounds<T>::ApproxBounds(double, int64_t, double, double, double, bool, std::unique_ptr<differential_privacy::LaplaceMechanism>)':
external/google_dp/differential_privacy/algorithms/approx-bounds.h:500:26: warning: lambda capture initializers only available with '-std=c++14' or '-std=gnu++14'
  500 |     auto get_boundary = [boundary = scale_, base = base_]() mutable {
      |                          ^~~~~~~~
external/google_dp/differential_privacy/algorithms/approx-bounds.h:500:45: warning: lambda capture initializers only available with '-std=c++14' or '-std=gnu++14'
  500 |     auto get_boundary = [boundary = scale_, base = base_]() mutable {
      |                                             ^~~~
src/bindings/PyDP/base/logging.cpp: At global scope:
src/bindings/PyDP/base/logging.cpp:23:17: error: 'string' in namespace 'std::__cxx11' does not name a type
   23 |   std::__cxx11::string get_log_directory() {
      |                 ^~~~~~
src/bindings/PyDP/base/logging.cpp: In function 'void init_base_logging(pybind11::module&)':
src/bindings/PyDP/base/logging.cpp:35:64: error: 'get_log_directory' is not a member of 'Logging_helper'
   35 |   obje.def_property_readonly("log_directory", &Logging_helper::get_log_directory);
      |                                                                ^~~~~~~~~~~~~~~~~
Target //src/python:bindings_test failed to build
INFO: Elapsed time: 3.712s, Critical Path: 3.51s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
cp: cannot stat './bazel-bin/src/bindings/pydp.so': No such file or directory
cp: cannot stat './bazel-bin/src/bindings/pydp.so': No such file or directory

System information

jeamick commented 4 years ago

Hey @systemshift
Nice to see people testing the repo !! Did you run ./ext_source_setup.sh and ./prereqs.sh before running build_PyDP.sh ?

chinmayshah99 commented 4 years ago

Hi @systemshift Thanks for reporting this, I suspect the latest commits in Google DP library cause this break.

@jeamick yeah, @systemshift did run these other dependencies. As a matter of fact, if he comments out logging.cpp, it builds successfully.

We need to investigate this further.

replomancer commented 4 years ago

Hey @systemshift Thanks for reporting this! I have reproduced the problem on Ubuntu 20.04. Before we fix the building process on Ubuntu 20.04 you can build and use the Docker image.

There is actually an error shown a little earlier in the messages:

src/bindings/PyDP/base/logging.cpp: At global scope:
src/bindings/PyDP/base/logging.cpp:23:17: error: 'string' in namespace 'std::__cxx11' does not name a type
   23 |   std::__cxx11::string get_log_directory() {

So far I discovered that removing "__cxx11" from this method definition:

  std::__cxx11::string get_log_directory() {
    return dpb::get_log_directory();
  }

like this:

  std::string get_log_directory() {
    return dpb::get_log_directory();
  }

fixes the building process for me, but I don't currently know if it's a good fix or only a hack.