diff --git a/cmake/external/cares.cmake b/cmake/external/cares.cmake index 52507a6ae4aabe300cf8bf88d0946c45a2c0e79c..d37b22fa2d9e84686c3bb0388dfd07ae6ebd6a33 100644 --- a/cmake/external/cares.cmake +++ b/cmake/external/cares.cmake @@ -25,6 +25,12 @@ SET(CARES_SOURCES_DIR ${THIRD_PARTY_PATH}/cares) SET(CARES_INSTALL_DIR ${THIRD_PARTY_PATH}/install/cares) SET(CARES_INCLUDE_DIR "${CARES_INSTALL_DIR}/include/" CACHE PATH "cares include directory." FORCE) +if(NOT APPLE AND NOT WIN32) + if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 8.0) + set(PATCH_COMMAND_CARES cp ${PADDLE_SOURCE_DIR}/patches/cares/ares_parse_ptr_reply.c.txt ${CARES_SOURCES_DIR}/src/extern_cares/ares_parse_ptr_reply.c) + endif() +endif() + ExternalProject_Add( extern_cares GIT_REPOSITORY "https://github.com/c-ares/c-ares.git" @@ -33,6 +39,7 @@ ExternalProject_Add( UPDATE_COMMAND "" CONFIGURE_COMMAND ./buildconf && ./configure --disable-shared --prefix=${CARES_INSTALL_DIR} BUILD_IN_SOURCE 1 + PATCH_COMMAND ${PATCH_COMMAND_CARES} BUILD_COMMAND make -j8 INSTALL_COMMAND make install ) diff --git a/cmake/external/grpc.cmake b/cmake/external/grpc.cmake index d96da470b3cbbd8092dbf80ec5f500af9afa2ce4..a9a9de88d6fb4954741edd69d4b290eba1ea8390 100644 --- a/cmake/external/grpc.cmake +++ b/cmake/external/grpc.cmake @@ -30,7 +30,11 @@ ProcessorCount(NUM_OF_PROCESSOR) IF(APPLE) SET(BUILD_CMD make -n HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin | sed "s/-Werror//g" | sh) ELSE() - SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin) + if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 8.0) + SET(BUILD_CMD make CFLAGS=-Wno-error=sizeof-pointer-memaccess CXXFLAGS=-Wno-error=ignored-qualifiers HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin) + else() + SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin) + endif() ENDIF() # FIXME(wuyi): do not build zlib cares protobuf twice, find a way to build grpc with them diff --git a/cmake/external/warpctc.cmake b/cmake/external/warpctc.cmake index 5fc46ae8eb8623ee6677cea7e62ce0329c57e1f2..c7ca7ba56ba74e40a1a44884435c1bf2852f688d 100644 --- a/cmake/external/warpctc.cmake +++ b/cmake/external/warpctc.cmake @@ -29,11 +29,8 @@ ELSE() SET(USE_OMP ON) ENDIF() -IF(WIN32) - SET(WARPCTC_REPOSITORY "https://github.com/wopeizl/warp-ctc.git") -ELSE() - SET(WARPCTC_REPOSITORY "https://github.com/dzhwinter/warp-ctc.git") -ENDIF() +# TODO: Use the official github address instead of private branch +SET(WARPCTC_REPOSITORY "https://github.com/wopeizl/warp-ctc.git") ExternalProject_Add( extern_warpctc diff --git a/cmake/flags.cmake b/cmake/flags.cmake index cfd5e177d921e9b07371cbc3e36bcc849edb59b2..6208ef969bc4a14cc07d53f9f38505897f902820 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -155,9 +155,23 @@ set(COMMON_FLAGS -Wno-error=terminate # Warning in PADDLE_ENFORCE -Wno-error=int-in-bool-context # Warning in Eigen gcc 7.2 -Wimplicit-fallthrough=0 # Warning in tinyformat.h + -Wno-error=maybe-uninitialized # Warning in boost gcc 7.2 ${fsanitize} ) +if(NOT APPLE) + if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 8.0) + set(COMMON_FLAGS + ${COMMON_FLAGS} + -Wno-format-truncation # Warning in boost gcc 8.2 + -Wno-error=cast-function-type # Warning in boost gcc 8.2 + -Wno-error=parentheses # Warning in boost gcc 8.2 + -Wno-error=catch-value # Warning in boost gcc 8.2 + -Wno-ignored-qualifiers # Warning in boost gcc 8.2 + ) + endif() +endif(NOT APPLE) + set(GPU_COMMON_FLAGS -fPIC -fno-omit-frame-pointer diff --git a/paddle/fluid/framework/details/exception_holder.h b/paddle/fluid/framework/details/exception_holder.h index f8fd395bd9cc1e569bf7789e6a3adc63b00716ac..14b78861761f9b2dd85ffbdae05bf4702f9d366a 100644 --- a/paddle/fluid/framework/details/exception_holder.h +++ b/paddle/fluid/framework/details/exception_holder.h @@ -29,9 +29,9 @@ class ExceptionHolder { void Catch(std::exception_ptr eptr) { try { std::rethrow_exception(eptr); - } catch (platform::EOFException exp) { + } catch (platform::EOFException& exp) { Catch(exp); - } catch (platform::EnforceNotMet exp) { + } catch (platform::EnforceNotMet& exp) { Catch(exp); } catch (std::exception& ex) { LOG(FATAL) << "std::exception caught, " << ex.what(); diff --git a/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc b/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc index 590f6120187555d65295154501e254ccaa3e0213..b737cd9b084cec2590c202b22c3a4f6e9f0499af 100644 --- a/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc +++ b/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc @@ -451,7 +451,7 @@ class CoalesceGradTensorPass : public ir::Pass { params_grads->emplace_back(std::make_pair( backward_vars[i] /*param*/, backward_vars[i + 1] /*grad*/)); } - } catch (boost::bad_get e) { + } catch (boost::bad_get &e) { } } } diff --git a/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc b/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc index 23c463eca41428fc60f8e6ba2e94267bc6697b3e..491bbc17ff514494f8037e7e45b12eb7f9e8f7d9 100644 --- a/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc +++ b/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc @@ -242,7 +242,7 @@ void MultiDevSSAGraphBuilderBase::ApplyImpl(ir::Graph *graph) const { InsertCollectiveOp(&result, p_name, g_name); } } - } catch (boost::bad_get e) { + } catch (boost::bad_get &e) { } } } @@ -777,7 +777,7 @@ std::vector ReduceSSAGraphBuilder::SortForReduceMode( backward_vars = boost::get>(node->Op()->GetNullableAttr( OpProtoAndCheckerMaker::OpRoleVarAttrName())); - } catch (boost::bad_get e) { + } catch (boost::bad_get &e) { } PADDLE_ENFORCE_EQ(backward_vars.size() % 2, 0); diff --git a/paddle/fluid/framework/ir/pass_test.cc b/paddle/fluid/framework/ir/pass_test.cc index 44fddd80c19ee4d5c5618b66d3fef0cd5c39047b..bad17c52210d3e39d32ab254bee9d6a15531544b 100644 --- a/paddle/fluid/framework/ir/pass_test.cc +++ b/paddle/fluid/framework/ir/pass_test.cc @@ -60,7 +60,7 @@ TEST(PassTest, TestPassAttrCheck) { std::string exception; try { graph.reset(pass->Apply(graph.release())); - } catch (paddle::platform::EnforceNotMet e) { + } catch (paddle::platform::EnforceNotMet& e) { exception = std::string(e.what()); } ASSERT_TRUE(exception.find("test_pass_attr not set") != exception.npos); @@ -71,7 +71,7 @@ TEST(PassTest, TestPassAttrCheck) { try { graph.reset(pass->Apply(graph.release())); - } catch (paddle::platform::EnforceNotMet e) { + } catch (paddle::platform::EnforceNotMet& e) { exception = std::string(e.what()); } ASSERT_TRUE(exception.find("test_graph_attr not set") != exception.npos); @@ -96,7 +96,7 @@ TEST(PassTest, TestPassAttrCheck) { graph->Get("test_graph_attr") = 2; try { pass->Apply(graph.release()); - } catch (paddle::platform::EnforceNotMet e) { + } catch (paddle::platform::EnforceNotMet& e) { exception = std::string(e.what()); } ASSERT_TRUE(exception.find("shouldn't have cycle") != exception.npos); diff --git a/paddle/fluid/framework/op_desc.cc b/paddle/fluid/framework/op_desc.cc index a36e3605270dae7dfb7039891d5bbc410edefd2a..bd709db6d898970874f984ceb9f2e0577a3775d8 100644 --- a/paddle/fluid/framework/op_desc.cc +++ b/paddle/fluid/framework/op_desc.cc @@ -702,7 +702,7 @@ void OpDesc::InferShape(const BlockDesc &block) const { VLOG(10) << sout.str(); } infer_shape(&ctx); - } catch (platform::EnforceNotMet exception) { + } catch (platform::EnforceNotMet &exception) { framework::InsertCallStackInfo(Type(), attrs_, &exception); throw std::move(exception); } catch (...) { diff --git a/paddle/fluid/framework/op_registry_test.cc b/paddle/fluid/framework/op_registry_test.cc index 66d08759e3705ba1510728b654909b6008dfb435..c62835e51be0dca2f564fad1a9e4325cbadf5059 100644 --- a/paddle/fluid/framework/op_registry_test.cc +++ b/paddle/fluid/framework/op_registry_test.cc @@ -115,7 +115,7 @@ TEST(OpRegistry, IllegalAttr) { bool caught = false; try { paddle::framework::OpRegistry::CreateOp(op_desc); - } catch (paddle::platform::EnforceNotMet err) { + } catch (paddle::platform::EnforceNotMet& err) { caught = true; std::string msg = "larger_than check fail"; std::string err_msg = err.what(); @@ -149,7 +149,7 @@ TEST(OpRegistry, CustomChecker) { bool caught = false; try { paddle::framework::OpRegistry::CreateOp(op_desc); - } catch (paddle::platform::EnforceNotMet err) { + } catch (paddle::platform::EnforceNotMet& err) { caught = true; std::string msg = "Attribute 'test_attr' is required!"; std::string err_msg = err.what(); @@ -165,7 +165,7 @@ TEST(OpRegistry, CustomChecker) { caught = false; try { paddle::framework::OpRegistry::CreateOp(op_desc); - } catch (paddle::platform::EnforceNotMet err) { + } catch (paddle::platform::EnforceNotMet& err) { caught = true; std::string msg = "'test_attr' must be even!"; std::string err_msg = err.what(); diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index c17502a545dc2d914d3b52e484ead2dd5b76f281..1a719e6b7da1468d3470944ff026b15b372fd2e8 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -180,7 +180,7 @@ void OperatorBase::Run(const Scope& scope, const platform::Place& place) { RunImpl(scope, place); } VLOG(3) << place << " " << DebugStringEx(&scope); - } catch (platform::EnforceNotMet exception) { + } catch (platform::EnforceNotMet& exception) { framework::InsertCallStackInfo(Type(), Attrs(), &exception); throw std::move(exception); } catch (...) { diff --git a/paddle/fluid/framework/tensor_test.cc b/paddle/fluid/framework/tensor_test.cc index 4c124a998a41ae996c77bf39682b57b8595d901f..8438feca65257ccee04daa1a681ee724de474455 100644 --- a/paddle/fluid/framework/tensor_test.cc +++ b/paddle/fluid/framework/tensor_test.cc @@ -36,7 +36,7 @@ TEST(Tensor, DataAssert) { bool caught = false; try { src_tensor.data(); - } catch (platform::EnforceNotMet err) { + } catch (platform::EnforceNotMet& err) { caught = true; std::string ex_msg = err.what(); EXPECT_TRUE(ex_msg.find("holder_ should not be null\nTensor holds no " @@ -151,7 +151,7 @@ TEST(Tensor, ShareDataWith) { bool caught = false; try { dst_tensor.ShareDataWith(src_tensor); - } catch (paddle::platform::EnforceNotMet err) { + } catch (paddle::platform::EnforceNotMet& err) { caught = true; std::string ex_msg = err.what(); EXPECT_TRUE(ex_msg.find("holder_ should not be null\nTensor holds no " diff --git a/paddle/fluid/framework/threadpool.h b/paddle/fluid/framework/threadpool.h index 7a51d18fbbf65f68725aa86a6a0ce4d15dff5673..6475e557703522d1bc940b3fe74a5179aa2e7fd5 100644 --- a/paddle/fluid/framework/threadpool.h +++ b/paddle/fluid/framework/threadpool.h @@ -17,9 +17,11 @@ limitations under the License. */ #include // NOLINT #include #include // NOLINT -#include // NOLINT +#include +#include // NOLINT #include #include // NOLINT +#include #include #include "glog/logging.h" #include "paddle/fluid/platform/enforce.h" @@ -72,7 +74,7 @@ class ThreadPool { Task task([fn]() -> std::unique_ptr { try { fn(); - } catch (platform::EnforceNotMet ex) { + } catch (platform::EnforceNotMet& ex) { return std::unique_ptr( new platform::EnforceNotMet(ex)); } catch (const std::exception& e) { diff --git a/paddle/fluid/platform/enforce_test.cc b/paddle/fluid/platform/enforce_test.cc index 2a2a85646939ba8f3b6d394f0c75c0b227763a33..8dedfe97049d3f5688695504585fd9146b3dc203 100644 --- a/paddle/fluid/platform/enforce_test.cc +++ b/paddle/fluid/platform/enforce_test.cc @@ -29,7 +29,7 @@ TEST(ENFORCE, FAILED) { bool caught_exception = false; try { PADDLE_ENFORCE(false, "Enforce is not ok %d at all", 123); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Enforce is not ok 123 at all") != @@ -40,7 +40,7 @@ TEST(ENFORCE, FAILED) { caught_exception = false; try { PADDLE_ENFORCE(false, "Enforce is not ok at all"); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Enforce is not ok at all") != std::string::npos); @@ -50,7 +50,7 @@ TEST(ENFORCE, FAILED) { caught_exception = false; try { PADDLE_ENFORCE(false); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; EXPECT_NE(std::string(error.what()).find(" at "), 0); } @@ -70,7 +70,7 @@ TEST(ENFORCE_EQ, NO_EXTRA_MSG_FAIL) { bool caught_exception = false; try { PADDLE_ENFORCE_EQ(a, 1 + 3); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Expected a == 1 + 3, but received a:2 != 1 " @@ -84,7 +84,7 @@ TEST(ENFORCE_EQ, EXTRA_MSG_FAIL) { bool caught_exception = false; try { PADDLE_ENFORCE_EQ(a, 1 + 3, "%s size not match", "their"); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Expected a == 1 + 3, but received a:2 != 1 + " @@ -103,7 +103,7 @@ TEST(ENFORCE_NE, FAIL) { try { // 2UL here to check data type compatible PADDLE_ENFORCE_NE(1.0, 1UL); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Expected 1.0 != 1UL, but " @@ -117,7 +117,7 @@ TEST(ENFORCE_GT, FAIL) { bool caught_exception = false; try { PADDLE_ENFORCE_GT(1, 2); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Expected 1 > 2, but received 1:1 <= 2:2.") != @@ -135,7 +135,7 @@ TEST(ENFORCE_GE, FAIL) { bool caught_exception = false; try { PADDLE_ENFORCE_GE(1, 2); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Expected 1 >= 2, but received 1:1 < 2:2.") != @@ -155,7 +155,7 @@ TEST(ENFORCE_LE, FAIL) { bool caught_exception = false; try { PADDLE_ENFORCE_GT(1, 2); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Expected 1 > 2, but received 1:1 <= 2:2.") != @@ -173,7 +173,7 @@ TEST(ENFORCE_LT, FAIL) { bool caught_exception = false; try { PADDLE_ENFORCE_LT(1UL, 0.12); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("Expected 1UL < 0.12, but " @@ -193,7 +193,7 @@ TEST(ENFORCE_NOT_NULL, FAIL) { try { int* a = nullptr; PADDLE_ENFORCE_NOT_NULL(a); - } catch (paddle::platform::EnforceNotMet error) { + } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("a should not be null") != std::string::npos); @@ -247,7 +247,7 @@ TEST(EOF_EXCEPTION, THROW_EOF) { bool caught_eof = false; try { PADDLE_THROW_EOF(); - } catch (paddle::platform::EOFException error) { + } catch (paddle::platform::EOFException& error) { caught_eof = true; std::string ex_msg = error.what(); EXPECT_TRUE(ex_msg.find("There is no next data.") != std::string::npos); diff --git a/patches/cares/ares_parse_ptr_reply.c.txt b/patches/cares/ares_parse_ptr_reply.c.txt new file mode 100644 index 0000000000000000000000000000000000000000..c590add9e73a3116628bcd665227c9e9a98fb01a --- /dev/null +++ b/patches/cares/ares_parse_ptr_reply.c.txt @@ -0,0 +1,221 @@ + +/* Copyright 1998 by the Massachusetts Institute of Technology. + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of M.I.T. not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +#include "ares_setup.h" + +#ifdef HAVE_NETINET_IN_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif +#ifdef HAVE_ARPA_NAMESER_H +# include +#else +# include "nameser.h" +#endif +#ifdef HAVE_ARPA_NAMESER_COMPAT_H +# include +#endif + +#ifdef HAVE_STRINGS_H +# include +#endif + +#include "ares.h" +#include "ares_dns.h" +#include "ares_nowarn.h" +#include "ares_private.h" + +int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, + int addrlen, int family, struct hostent **host) +{ + unsigned int qdcount, ancount; + int status, i, rr_type, rr_class, rr_len; + long len; + const unsigned char *aptr; + char *ptrname, *hostname, *rr_name, *rr_data; + struct hostent *hostent; + int aliascnt = 0; + int alias_alloc = 8; + char ** aliases; + size_t rr_data_len; + + /* Set *host to NULL for all failure cases. */ + *host = NULL; + + /* Give up if abuf doesn't have room for a header. */ + if (alen < HFIXEDSZ) + return ARES_EBADRESP; + + /* Fetch the question and answer count from the header. */ + qdcount = DNS_HEADER_QDCOUNT(abuf); + ancount = DNS_HEADER_ANCOUNT(abuf); + if (qdcount != 1) + return ARES_EBADRESP; + + /* Expand the name from the question, and skip past the question. */ + aptr = abuf + HFIXEDSZ; + status = ares__expand_name_for_response(aptr, abuf, alen, &ptrname, &len); + if (status != ARES_SUCCESS) + return status; + if (aptr + len + QFIXEDSZ > abuf + alen) + { + ares_free(ptrname); + return ARES_EBADRESP; + } + aptr += len + QFIXEDSZ; + + /* Examine each answer resource record (RR) in turn. */ + hostname = NULL; + aliases = ares_malloc(alias_alloc * sizeof(char *)); + if (!aliases) + { + ares_free(ptrname); + return ARES_ENOMEM; + } + for (i = 0; i < (int)ancount; i++) + { + /* Decode the RR up to the data field. */ + status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len); + if (status != ARES_SUCCESS) + break; + aptr += len; + if (aptr + RRFIXEDSZ > abuf + alen) + { + ares_free(rr_name); + status = ARES_EBADRESP; + break; + } + rr_type = DNS_RR_TYPE(aptr); + rr_class = DNS_RR_CLASS(aptr); + rr_len = DNS_RR_LEN(aptr); + aptr += RRFIXEDSZ; + if (aptr + rr_len > abuf + alen) + { + ares_free(rr_name); + status = ARES_EBADRESP; + break; + } + + if (rr_class == C_IN && rr_type == T_PTR + && strcasecmp(rr_name, ptrname) == 0) + { + /* Decode the RR data and set hostname to it. */ + status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, + &len); + if (status != ARES_SUCCESS) + { + ares_free(rr_name); + break; + } + if (hostname) + ares_free(hostname); + hostname = rr_data; + rr_data_len = strlen(rr_data)+1; + aliases[aliascnt] = ares_malloc(rr_data_len * sizeof(char)); + if (!aliases[aliascnt]) + { + ares_free(rr_name); + status = ARES_ENOMEM; + break; + } + strncpy(aliases[aliascnt], rr_data, rr_data_len); + aliascnt++; + if (aliascnt >= alias_alloc) { + char **ptr; + alias_alloc *= 2; + ptr = ares_realloc(aliases, alias_alloc * sizeof(char *)); + if(!ptr) { + ares_free(rr_name); + status = ARES_ENOMEM; + break; + } + aliases = ptr; + } + } + + if (rr_class == C_IN && rr_type == T_CNAME) + { + /* Decode the RR data and replace ptrname with it. */ + status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, + &len); + if (status != ARES_SUCCESS) + { + ares_free(rr_name); + break; + } + ares_free(ptrname); + ptrname = rr_data; + } + + ares_free(rr_name); + aptr += rr_len; + if (aptr > abuf + alen) + { /* LCOV_EXCL_START: already checked above */ + status = ARES_EBADRESP; + break; + } /* LCOV_EXCL_STOP */ + } + + if (status == ARES_SUCCESS && !hostname) + status = ARES_ENODATA; + if (status == ARES_SUCCESS) + { + /* We got our answer. Allocate memory to build the host entry. */ + hostent = ares_malloc(sizeof(struct hostent)); + if (hostent) + { + hostent->h_addr_list = ares_malloc(2 * sizeof(char *)); + if (hostent->h_addr_list) + { + hostent->h_addr_list[0] = ares_malloc(addrlen); + if (hostent->h_addr_list[0]) + { + hostent->h_aliases = ares_malloc((aliascnt+1) * sizeof (char *)); + if (hostent->h_aliases) + { + /* Fill in the hostent and return successfully. */ + hostent->h_name = hostname; + for (i=0 ; ih_aliases[i] = aliases[i]; + hostent->h_aliases[aliascnt] = NULL; + hostent->h_addrtype = aresx_sitoss(family); + hostent->h_length = aresx_sitoss(addrlen); + memcpy(hostent->h_addr_list[0], addr, addrlen); + hostent->h_addr_list[1] = NULL; + *host = hostent; + ares_free(aliases); + ares_free(ptrname); + return ARES_SUCCESS; + } + ares_free(hostent->h_addr_list[0]); + } + ares_free(hostent->h_addr_list); + } + ares_free(hostent); + } + status = ARES_ENOMEM; + } + for (i=0 ; i + +# ENV variables +ARG WITH_GPU +ARG WITH_AVX +ARG WITH_DOC + +ENV WITH_GPU=${WITH_GPU:-ON} +ENV WITH_AVX=${WITH_AVX:-ON} +ENV WITH_DOC=${WITH_DOC:-OFF} + +ENV HOME /root +# Add bash enhancements +COPY ./paddle/scripts/docker/root/ /root/ + +# Prepare packages for Python +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ + libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ + xz-utils tk-dev libffi-dev liblzma-dev +RUN apt-get install -y python-dev python-pip wget vim git + +# install cmake +WORKDIR /home +RUN wget https://cmake.org/files/v3.4/cmake-3.4.0-Linux-x86_64.tar.gz +RUN tar -xvf cmake-3.4.0-Linux-x86_64.tar.gz +RUN apt install libidn11 +ENV PATH=/home/cmake-3.4.0-Linux-x86_64/bin:$PATH +WORKDIR /usr/bin +RUN apt install -y gcc-8 g++-8 +RUN cp gcc gcc.bak +RUN cp g++ g++.bak +RUN rm gcc +RUN rm g++ +RUN ln -s gcc-8 gcc +RUN ln -s g++-8 g++ + +# Install Python3.6 +RUN mkdir -p /root/python_build/ && wget -q https://www.sqlite.org/2018/sqlite-autoconf-3250300.tar.gz && \ + tar -zxf sqlite-autoconf-3250300.tar.gz && cd sqlite-autoconf-3250300 && \ + ./configure -prefix=/usr/local && make -j8 && make install && cd ../ && rm sqlite-autoconf-3250300.tar.gz && \ + wget -q https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz && \ + tar -xzf Python-3.6.9.tgz && cd Python-3.6.9 && \ + CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \ + make -j8 > /dev/null && make altinstall > /dev/null + +# Install Python3.7 +RUN wget -q https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz && \ + tar -xzf Python-3.7.0.tgz && cd Python-3.7.0 && \ + CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \ + make -j8 > /dev/null && make altinstall > /dev/null + +RUN rm -r /root/python_build + +RUN apt-get update && \ + apt-get install -y --allow-downgrades --allow-change-held-packages \ + patchelf python3 python3-dev python3-pip \ + git python-pip python-dev python-opencv openssh-server bison \ + wget unzip unrar tar xz-utils bzip2 gzip coreutils ntp \ + curl sed grep graphviz libjpeg-dev zlib1g-dev \ + python-matplotlib \ + automake locales clang-format swig cmake \ + liblapack-dev liblapacke-dev \ + net-tools libtool ccache module-init-tools && \ + apt-get clean -y + +# Install Python2.7.15 to replace original python +WORKDIR /home +ENV version=2.7.15 +RUN wget https://www.python.org/ftp/python/$version/Python-$version.tgz +RUN tar -xvf Python-$version.tgz +WORKDIR /home/Python-$version +RUN ./configure --enable-unicode=ucs4 --enable-shared CFLAGS=-fPIC --prefix=/usr/local/python2.7.15 +RUN make && make install + +RUN echo "export PATH=/usr/local/python2.7.15/include:${PATH}" >> ~/.bashrc +RUN echo "export PATH=/usr/local/python2.7.15/bin:${PATH}" >> ~/.bashrc +RUN echo "export LD_LIBRARY_PATH=/usr/local/python2.7.15/lib:${LD_LIBRARY_PATH}" >> ~/.bashrc +RUN echo "export CPLUS_INCLUDE_PATH=/usr/local/python2.7.15/include/python2.7:$CPLUS_INCLUDE_PATH" >> ~/.bashrc +ENV PATH=/usr/local/python2.7.15/include:${PATH} +ENV PATH=/usr/local/python2.7.15/bin:${PATH} +ENV LD_LIBRARY_PATH=/usr/local/python2.7.15/lib:${LD_LIBRARY_PATH} +ENV CPLUS_INCLUDE_PATH=/usr/local/python2.7.15/include/python2.7:$CPLUS_INCLUDE_PATH +RUN mv /usr/bin/python /usr/bin/python.bak +RUN ln -s /usr/local/python2.7.15/bin/python2.7 /usr/local/bin/python +RUN ln -s /usr/local/python2.7.15/bin/python2.7 /usr/bin/python +WORKDIR /home +RUN wget https://files.pythonhosted.org/packages/b0/d1/8acb42f391cba52e35b131e442e80deffbb8d0676b93261d761b1f0ef8fb/setuptools-40.6.2.zip +RUN apt-get -y install unzip +RUN unzip setuptools-40.6.2.zip +WORKDIR /home/setuptools-40.6.2 +RUN python setup.py build +RUN python setup.py install +WORKDIR /home +RUN wget https://files.pythonhosted.org/packages/69/81/52b68d0a4de760a2f1979b0931ba7889202f302072cc7a0d614211bc7579/pip-18.0.tar.gz +RUN tar -zxvf pip-18.0.tar.gz +WORKDIR pip-18.0 +RUN python setup.py install + +WORKDIR /home +RUN rm Python-$version.tgz setuptools-40.6.2.zip pip-18.0.tar.gz && \ + rm -r Python-$version setuptools-40.6.2 pip-18.0 + +# git credential to skip password typing +RUN git config --global credential.helper store + +# Fix locales to en_US.UTF-8 +RUN localedef -i en_US -f UTF-8 en_US.UTF-8 + +# specify sphinx version as 1.5.6 and remove -U option for [pip install -U +# sphinx-rtd-theme] since -U option will cause sphinx being updated to newest +# version(1.7.1 for now), which causes building documentation failed. +RUN pip3 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ + pip3 --no-cache-dir install -U docopt PyYAML sphinx==1.5.6 && \ + pip3 --no-cache-dir install sphinx-rtd-theme==0.1.9 recommonmark && \ + pip3.6 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ + pip3.6 --no-cache-dir install -U docopt PyYAML sphinx==1.5.6 && \ + pip3.6 --no-cache-dir install sphinx-rtd-theme==0.1.9 recommonmark && \ + pip3.7 --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ + pip3.7 --no-cache-dir install -U docopt PyYAML sphinx==1.5.6 && \ + pip3.7 --no-cache-dir install sphinx-rtd-theme==0.1.9 recommonmark && \ + pip --no-cache-dir install -U wheel py-cpuinfo==5.0.0 && \ + pip --no-cache-dir install -U docopt PyYAML sphinx==1.5.6 && \ + pip --no-cache-dir install sphinx-rtd-theme==0.1.9 recommonmark + +RUN pip3 --no-cache-dir install 'pre-commit==1.10.4' 'ipython==5.3.0' && \ + pip3 --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \ + pip3 --no-cache-dir install opencv-python && \ + pip3.6 --no-cache-dir install 'pre-commit==1.10.4' 'ipython==5.3.0' && \ + pip3.6 --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \ + pip3.6 --no-cache-dir install opencv-python && \ + pip3.7 --no-cache-dir install 'pre-commit==1.10.4' 'ipython==5.3.0' && \ + pip3.7 --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \ + pip3.7 --no-cache-dir install opencv-python && \ + pip --no-cache-dir install 'pre-commit==1.10.4' 'ipython==5.3.0' && \ + pip --no-cache-dir install 'ipykernel==4.6.0' 'jupyter==1.0.0' && \ + pip --no-cache-dir install opencv-python + +#For docstring checker +RUN pip3 --no-cache-dir install pylint pytest astroid isort +RUN pip3.6 --no-cache-dir install pylint pytest astroid isort +RUN pip3.7 --no-cache-dir install pylint pytest astroid isort +RUN pip --no-cache-dir install pylint pytest astroid isort LinkChecker + +RUN pip3 --no-cache-dir install coverage +RUN pip3.6 --no-cache-dir install coverage +RUN pip3.7 --no-cache-dir install coverage +RUN pip --no-cache-dir install coverage + +COPY ./python/requirements.txt /root/ +RUN pip3 --no-cache-dir install -r /root/requirements.txt +RUN pip3.6 --no-cache-dir install -r /root/requirements.txt +RUN pip3.7 --no-cache-dir install -r /root/requirements.txt +RUN pip --no-cache-dir install -r /root/requirements.txt + +# To fix https://github.com/PaddlePaddle/Paddle/issues/1954, we use +# the solution in https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2 +RUN apt-get install -y libssl-dev libffi-dev && apt-get clean -y +RUN pip3 --no-cache-dir install certifi urllib3[secure] +RUN pip3.6 --no-cache-dir install certifi urllib3[secure] +RUN pip3.7 --no-cache-dir install certifi urllib3[secure] +RUN pip --no-cache-dir install certifi urllib3[secure] + +RUN echo "export PATH=/usr/lib/ccache:${PATH}" >> ~/.bashrc + +# Configure OpenSSH server. c.f. https://docs.docker.com/engine/examples/running_ssh_service +RUN mkdir /var/run/sshd +RUN echo 'root:root' | chpasswd +RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config +RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config +CMD source ~/.bashrc +EXPOSE 22 +