Skip to content

Commit 6fb04e8

Browse files
FrostMLfc500110
authored andcommitted
[cherry-pick] Add support to gcc8, add docker env (#20892)
* add support to gcc8, add docker env * remove the warning issue
1 parent 5119f26 commit 6fb04e8

File tree

16 files changed

+460
-35
lines changed

16 files changed

+460
-35
lines changed

cmake/external/cares.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ SET(CARES_SOURCES_DIR ${THIRD_PARTY_PATH}/cares)
2525
SET(CARES_INSTALL_DIR ${THIRD_PARTY_PATH}/install/cares)
2626
SET(CARES_INCLUDE_DIR "${CARES_INSTALL_DIR}/include/" CACHE PATH "cares include directory." FORCE)
2727

28+
if(NOT APPLE AND NOT WIN32)
29+
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 8.0)
30+
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)
31+
endif()
32+
endif()
33+
2834
ExternalProject_Add(
2935
extern_cares
3036
GIT_REPOSITORY "https://github.com/c-ares/c-ares.git"
@@ -33,6 +39,7 @@ ExternalProject_Add(
3339
UPDATE_COMMAND ""
3440
CONFIGURE_COMMAND ./buildconf && ./configure --disable-shared --prefix=${CARES_INSTALL_DIR}
3541
BUILD_IN_SOURCE 1
42+
PATCH_COMMAND ${PATCH_COMMAND_CARES}
3643
BUILD_COMMAND make -j8
3744
INSTALL_COMMAND make install
3845
)

cmake/external/grpc.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ ProcessorCount(NUM_OF_PROCESSOR)
3030
IF(APPLE)
3131
SET(BUILD_CMD make -n HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin | sed "s/-Werror//g" | sh)
3232
ELSE()
33-
SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin)
33+
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 8.0)
34+
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)
35+
else()
36+
SET(BUILD_CMD make HAS_SYSTEM_PROTOBUF=false -s -j ${NUM_OF_PROCESSOR} static grpc_cpp_plugin)
37+
endif()
3438
ENDIF()
3539

3640
# FIXME(wuyi): do not build zlib cares protobuf twice, find a way to build grpc with them

cmake/external/warpctc.cmake

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@ ELSE()
2929
SET(USE_OMP ON)
3030
ENDIF()
3131

32-
IF(WIN32)
33-
SET(WARPCTC_REPOSITORY "https://github.com/wopeizl/warp-ctc.git")
34-
ELSE()
35-
SET(WARPCTC_REPOSITORY "https://github.com/dzhwinter/warp-ctc.git")
36-
ENDIF()
32+
# TODO: Use the official github address instead of private branch
33+
SET(WARPCTC_REPOSITORY "https://github.com/wopeizl/warp-ctc.git")
3734

3835
ExternalProject_Add(
3936
extern_warpctc

cmake/flags.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,25 @@ set(COMMON_FLAGS
155155
-Wno-error=terminate # Warning in PADDLE_ENFORCE
156156
-Wno-error=int-in-bool-context # Warning in Eigen gcc 7.2
157157
-Wimplicit-fallthrough=0 # Warning in tinyformat.h
158+
-Wno-error=maybe-uninitialized # Warning in boost gcc 7.2
158159
${fsanitize}
159160
)
160161

162+
if(NOT APPLE)
163+
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 8.0)
164+
set(COMMON_FLAGS
165+
${COMMON_FLAGS}
166+
-Wno-format-truncation # Warning in boost gcc 8.2
167+
-Wno-error=cast-function-type # Warning in boost gcc 8.2
168+
-Wno-error=parentheses # Warning in boost gcc 8.2
169+
-Wno-error=catch-value # Warning in boost gcc 8.2
170+
-Wno-error=nonnull-compare # Warning in boost gcc 8.2
171+
-Wno-error=address # Warning in boost gcc 8.2
172+
-Wno-ignored-qualifiers # Warning in boost gcc 8.2
173+
)
174+
endif()
175+
endif(NOT APPLE)
176+
161177
set(GPU_COMMON_FLAGS
162178
-fPIC
163179
-fno-omit-frame-pointer

paddle/fluid/framework/details/exception_holder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class ExceptionHolder {
2929
void Catch(std::exception_ptr eptr) {
3030
try {
3131
std::rethrow_exception(eptr);
32-
} catch (platform::EOFException exp) {
32+
} catch (platform::EOFException& exp) {
3333
Catch(exp);
34-
} catch (platform::EnforceNotMet exp) {
34+
} catch (platform::EnforceNotMet& exp) {
3535
Catch(exp);
3636
} catch (std::exception& ex) {
3737
LOG(FATAL) << "std::exception caught, " << ex.what();

paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class CoalesceGradTensorPass : public ir::Pass {
451451
params_grads->emplace_back(std::make_pair(
452452
backward_vars[i] /*param*/, backward_vars[i + 1] /*grad*/));
453453
}
454-
} catch (boost::bad_get e) {
454+
} catch (boost::bad_get &e) {
455455
}
456456
}
457457
}

paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void MultiDevSSAGraphBuilderBase::ApplyImpl(ir::Graph *graph) const {
242242
InsertCollectiveOp(&result, p_name, g_name);
243243
}
244244
}
245-
} catch (boost::bad_get e) {
245+
} catch (boost::bad_get &e) {
246246
}
247247
}
248248
}
@@ -777,7 +777,7 @@ std::vector<ir::Node *> ReduceSSAGraphBuilder::SortForReduceMode(
777777
backward_vars =
778778
boost::get<std::vector<std::string>>(node->Op()->GetNullableAttr(
779779
OpProtoAndCheckerMaker::OpRoleVarAttrName()));
780-
} catch (boost::bad_get e) {
780+
} catch (boost::bad_get &e) {
781781
}
782782
PADDLE_ENFORCE_EQ(backward_vars.size() % 2, 0);
783783

paddle/fluid/framework/ir/pass_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TEST(PassTest, TestPassAttrCheck) {
6060
std::string exception;
6161
try {
6262
graph.reset(pass->Apply(graph.release()));
63-
} catch (paddle::platform::EnforceNotMet e) {
63+
} catch (paddle::platform::EnforceNotMet& e) {
6464
exception = std::string(e.what());
6565
}
6666
ASSERT_TRUE(exception.find("test_pass_attr not set") != exception.npos);
@@ -71,7 +71,7 @@ TEST(PassTest, TestPassAttrCheck) {
7171

7272
try {
7373
graph.reset(pass->Apply(graph.release()));
74-
} catch (paddle::platform::EnforceNotMet e) {
74+
} catch (paddle::platform::EnforceNotMet& e) {
7575
exception = std::string(e.what());
7676
}
7777
ASSERT_TRUE(exception.find("test_graph_attr not set") != exception.npos);
@@ -96,7 +96,7 @@ TEST(PassTest, TestPassAttrCheck) {
9696
graph->Get<int>("test_graph_attr") = 2;
9797
try {
9898
pass->Apply(graph.release());
99-
} catch (paddle::platform::EnforceNotMet e) {
99+
} catch (paddle::platform::EnforceNotMet& e) {
100100
exception = std::string(e.what());
101101
}
102102
ASSERT_TRUE(exception.find("shouldn't have cycle") != exception.npos);

paddle/fluid/framework/op_desc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ void OpDesc::InferShape(const BlockDesc &block) const {
702702
VLOG(10) << sout.str();
703703
}
704704
infer_shape(&ctx);
705-
} catch (platform::EnforceNotMet exception) {
705+
} catch (platform::EnforceNotMet &exception) {
706706
framework::InsertCallStackInfo(Type(), attrs_, &exception);
707707
throw std::move(exception);
708708
} catch (...) {

paddle/fluid/framework/op_registry_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ TEST(OpRegistry, IllegalAttr) {
115115
bool caught = false;
116116
try {
117117
paddle::framework::OpRegistry::CreateOp(op_desc);
118-
} catch (paddle::platform::EnforceNotMet err) {
118+
} catch (paddle::platform::EnforceNotMet& err) {
119119
caught = true;
120120
std::string msg = "larger_than check fail";
121121
std::string err_msg = err.what();
@@ -149,7 +149,7 @@ TEST(OpRegistry, CustomChecker) {
149149
bool caught = false;
150150
try {
151151
paddle::framework::OpRegistry::CreateOp(op_desc);
152-
} catch (paddle::platform::EnforceNotMet err) {
152+
} catch (paddle::platform::EnforceNotMet& err) {
153153
caught = true;
154154
std::string msg = "Attribute 'test_attr' is required!";
155155
std::string err_msg = err.what();
@@ -165,7 +165,7 @@ TEST(OpRegistry, CustomChecker) {
165165
caught = false;
166166
try {
167167
paddle::framework::OpRegistry::CreateOp(op_desc);
168-
} catch (paddle::platform::EnforceNotMet err) {
168+
} catch (paddle::platform::EnforceNotMet& err) {
169169
caught = true;
170170
std::string msg = "'test_attr' must be even!";
171171
std::string err_msg = err.what();

0 commit comments

Comments
 (0)