From 2e12aebf246b69294ff57ee797105b43ab288b0e Mon Sep 17 00:00:00 2001 From: chenzhiyu Date: Thu, 17 Sep 2020 17:18:53 +0800 Subject: [PATCH] fix missed with_musl macro control --- cmake/configure.cmake | 4 ++-- paddle/fluid/platform/enforce.h | 11 ++++++++--- paddle/fluid/platform/macros.h | 8 +++++--- paddle/fluid/platform/port.h | 1 - 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cmake/configure.cmake b/cmake/configure.cmake index 67dfc3c42a8..fc984f5e560 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -54,10 +54,10 @@ endif(WIN32) if(WITH_MUSL) add_definitions(-DPADDLE_WITH_MUSL) - message(STATUS, "WITH_MKL=OFF, when WITH_MUSL=ON") + message(STATUS, "Set compile option WITH_MKL=OFF when WITH_MUSL=ON") SET(WITH_MKL OFF) - message(STATUS, "WITH_GPU=OFF, when WITH_MUSL=ON") + message(STATUS, "Set compile option WITH_GPU=OFF when WITH_MUSL=ON") SET(WITH_GPU OFF) endif() diff --git a/paddle/fluid/platform/enforce.h b/paddle/fluid/platform/enforce.h index 784760a65a4..01bf5335da6 100644 --- a/paddle/fluid/platform/enforce.h +++ b/paddle/fluid/platform/enforce.h @@ -47,6 +47,10 @@ limitations under the License. */ #include #include +#ifndef PADDLE_WITH_MUSL +#include +#endif + #define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h #include "glog/logging.h" #include "paddle/fluid/platform/errors.h" @@ -230,13 +234,14 @@ inline std::string SimplifyDemangleStr(std::string str) { } inline std::string GetCurrentTraceBackString() { - //static constexpr int TRACE_STACK_LIMIT = 100; std::ostringstream sout; sout << "\n\n--------------------------------------\n"; sout << "C++ Traceback (most recent call last):"; sout << "\n--------------------------------------\n"; -#if !defined(_WIN32) && 0 +#if !defined(_WIN32) && !defined(PADDLE_WITH_MUSL) + static constexpr int TRACE_STACK_LIMIT = 100; + void* call_stack[TRACE_STACK_LIMIT]; auto size = backtrace(call_stack, TRACE_STACK_LIMIT); auto symbols = backtrace_symbols(call_stack, size); @@ -255,7 +260,7 @@ inline std::string GetCurrentTraceBackString() { } free(symbols); #else - sout << "Windows not support stack backtrace yet.\n"; + sout << "Not support stack backtrace yet.\n"; #endif return sout.str(); } diff --git a/paddle/fluid/platform/macros.h b/paddle/fluid/platform/macros.h index 7ab63cc10c1..82b20a53ce7 100644 --- a/paddle/fluid/platform/macros.h +++ b/paddle/fluid/platform/macros.h @@ -25,6 +25,8 @@ limitations under the License. */ classname& operator=(classname&&) = delete #endif -//#if defined(__FLT_MAX__) -//#define FLT_MAX __FLT_MAX__ -//#endif // __FLT_MAX__ +#ifndef PADDLE_WITH_MUSL + #if defined(__FLT_MAX__) + #define FLT_MAX __FLT_MAX__ + #endif // __FLT_MAX__ +#endif diff --git a/paddle/fluid/platform/port.h b/paddle/fluid/platform/port.h index 0c4d41a7835..5c346537cca 100644 --- a/paddle/fluid/platform/port.h +++ b/paddle/fluid/platform/port.h @@ -26,7 +26,6 @@ #if !defined(_WIN32) #include // dladdr -//#include // backtrace #include #include #include // std::accumulate -- GitLab