Skip to content

Commit

Permalink
[build][hexagon] fix several compiler warnings (apache#11245)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Convey authored May 16, 2022
1 parent b4c4215 commit ebf3607
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmake/modules/Hexagon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ endif()
# the path to the SDK), unless it's needed. The flag USE_HEXAGON decides
# whether any Hexagon-related functionality is enabled. Specifically,
# setting USE_HEXAGON=OFF, disables any form of Hexagon support.
#
#
# Note on the function of USE_HEXAGON_RPC:
# - When building for Hexagon, this will build the Hexagon endpoint of the
# RPC server: the FastRPC skel library (with TVM runtime built into it),
Expand Down Expand Up @@ -172,6 +172,14 @@ if(USE_HEXAGON_RPC)
-o "${TVMRT_SOURCE_DIR}/hexagon/rpc"
MAIN_DEPENDENCY "${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc.idl"
)

if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
# We can't easily fix this at the source-code level, because the .c file is generated
# by the qaic program. But it should be safe to ignore the warning:
# https://stackoverflow.com/questions/13905200/is-it-wise-to-ignore-gcc-clangs-wmissing-braces-warning
set_source_files_properties("${TVMRT_SOURCE_DIR}/hexagon/rpc/hexagon_rpc_stub.c"
PROPERTY COMPILE_FLAGS "-Wno-missing-braces")
endif()
endfunction()

if(BUILD_FOR_ANDROID)
Expand Down
21 changes: 21 additions & 0 deletions src/runtime/hexagon/rpc/simulator/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,18 @@ std::string SimulatorRPCChannel::Cpu_::str() const {
return default_cpu_;
}

// LOG(FATAL) always throws an exception or terminates the
// process, but the compiler doesn't know that.
#if (__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreturn-type"
#endif

#if (__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreturn-type"
#endif

std::string SimulatorRPCChannel::Message_::str() const {
switch (msg.code) {
case Message::kNone:
Expand All @@ -483,10 +495,19 @@ std::string SimulatorRPCChannel::Message_::str() const {
case Message::kSendEnd:
return "kSendEnd";
default:
LOG(FATAL) << "Internal error: Unrecognized code value: " << msg.code;
break;
}
}

#if (__GNUC__)
#pragma GCC diagnostic pop
#endif

#if (__clang__)
#pragma GCC diagnostic pop
#endif

SimulatorRPCChannel::SDKInfo_::SDKInfo_(const std::string& sdk_root, const std::string& cpu)
: root(sdk_root) {
// For v69 chips, still look for v68 in the directory names.
Expand Down

0 comments on commit ebf3607

Please sign in to comment.