Skip to content

Commit

Permalink
Enable windows compiler flags part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkulakowski committed Jan 24, 2025
1 parent 3b2afa2 commit 3f6ce45
Show file tree
Hide file tree
Showing 100 changed files with 510 additions and 114 deletions.
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ build:windows --config=monolithic

build:windows --copt=/W0
build:windows --host_copt=/W0
build:windows --copt=/external:env:BAZEL_VC
build:windows --host_copt=/external:env:BAZEL_VC
build:windows --copt=/external:W0
build:windows --host_copt=/external:W0

# On Windows, `__cplusplus` is wrongly defined without this switch
# See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
Expand Down
125 changes: 120 additions & 5 deletions common_settings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,45 @@ COMMON_STATIC_LIBS_COPTS = select({
"-Werror",
],
"//src:windows" : [
"-Wall",
"/W4",
"/WX",
"/external:anglebrackets",
"/external:W0",
"/sdl-",
"/analyze-",
"/Gy-",
"/DYNAMICBASE",
"/wd4099", # level 2
"/wd4018", # level 3
"/wd4068", # level 1
"/wd4458", # level 4
"/wd4100", # level 4
"/wd4267", # level 1
"/wd4389", # level 4
"/wd4005", # level 1
"/wd4127", # level 4
"/wd4456", # level 4
"/wd4673", # level 4
"/wd4670", # level 4
"/wd4244", # level 3
"/wd4457", # level 4
"/wd4505", # level 4
"/wd6346", # level 1
"/wd6011", # level 1
"/wd6246", # level 3
"/wd4702", # level 4
"/wd4309", # level 2
"/wd4101", # level 3/4
"/wd6294", # level 2
"/wd6201", # level 2
"/wd6269", # level 2
"/wd6387", # level 4
"/wd6308", # level 4
"/wd6295", # level 2
"/wd4661", # level 1
"/wd6319", # level 3/4
"/wd4297", # level 3/4
"/wd4701",
],
})

Expand All @@ -136,8 +174,46 @@ COMMON_STATIC_TEST_COPTS = select({
"-fvisibility=hidden",# Needed for pybind targets
],
"//src:windows" : [
"-W0",
"-Isrc",
#"/W0",
#"/WX",
"/external:anglebrackets",
"/external:W0",
"/sdl-",
"/analyze-",
"/Gy-",
"/DYNAMICBASE-",
#"/wd4099",
#"/wd4018",
#"/wd4068",
#"/wd4458",
#"/wd4100",
#"/wd4267",
#"/wd4389",
#"/wd4005",
#"/wd4127",
#"/wd4456",
#"/wd4673",
#"/wd4670",
#"/wd4244",
#"/wd4457",
#"/wd4505",
#"/wd6326",
#"/wd6346",
#"/wd6011",
#"/wd6246",
#"/wd4702",
#"/wd4309",
#"/wd4101",
#"/wd6294",
#"/wd6201",
#"/wd6269",
#"/wd6387",
#"/wd6308",
#"/wd6295",
#"/wd4661",
#"/wd6319",
#"/wd4297",
#"/wd4701",
],
})

Expand All @@ -150,7 +226,46 @@ COMMON_STATIC_LIBS_COPTS_VISIBLE = select({
"-Werror",
],
"//src:windows" : [
"-Wall",
#"/W0",
#"/WX",
"/external:anglebrackets",
"/external:W0",
"/sdl-",
"/analyze-",
"/Gy-",
"/DYNAMICBASE-",
#"/wd4099",
#"/wd4018",
#"/wd4068",
#"/wd4458",
#"/wd4100",
#"/wd4267",
#"/wd4389",
#"/wd4005",
#"/wd4127",
#"/wd4456",
#"/wd4673",
#"/wd4670",
#"/wd4244",
#"/wd4457",
#"/wd4505",
#"/wd6326",
#"/wd6346",
#"/wd6011",
#"/wd6246",
#"/wd4702",
#"/wd4309",
#"/wd4101",
#"/wd6294",
#"/wd6201",
#"/wd6269",
#"/wd6387",
#"/wd6308",
#"/wd6295",
#"/wd4661",
#"/wd6319",
#"/wd4297",
#"/wd4701",
],
})

Expand All @@ -165,7 +280,7 @@ COMMON_STATIC_LIBS_LINKOPTS = select({
],
"//src:windows" : [
"",
],
],
})
COPTS_PYTHON = select({
"//conditions:default": ["-DPYTHON_DISABLE=1"],
Expand Down
17 changes: 14 additions & 3 deletions src/capi_frontend/capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
#include <iterator>
#include <memory>
#include <string>

#pragma warning(push)
#pragma warning(disable : 6313)
#include <rapidjson/document.h>
#include <rapidjson/pointer.h>
#include <rapidjson/rapidjson.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#pragma warning(pop)

#include "../dags/pipeline.hpp"
#include "../dags/pipelinedefinition.hpp"
Expand Down Expand Up @@ -208,7 +210,11 @@ DLL_PUBLIC OVMS_Status* OVMS_MetadataFieldByPointer(OVMS_Metadata* metadata, con
if (!val) {
return reinterpret_cast<OVMS_Status*>(new Status(StatusCode::JSON_SERIALIZATION_ERROR, "value not found"));
}
#ifdef __linux__
*value = strdup(val->GetString());
#elif _WIN32
*value = _strdup(val->GetString());
#endif
*size = val->GetStringLength();
return nullptr;
}
Expand All @@ -229,7 +235,11 @@ DLL_PUBLIC OVMS_Status* OVMS_SerializeMetadataToString(OVMS_Metadata* metadata,

rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
doc->Accept(writer);
#ifdef __linux__
*json = strdup(strbuf.GetString());
#elif _WIN32
*json = _strdup(strbuf.GetString());
#endif
*size = strbuf.GetSize();

return nullptr;
Expand Down Expand Up @@ -878,7 +888,8 @@ enum : uint32_t {
TIMER_CALLBACK,
TIMER_END
};

#pragma warning(push)
#pragma warning(disable : 4190) // TODO verify
static Status getModelManager(Server& server, ModelManager** modelManager) {
if (!server.isLive()) {
return ovms::Status(ovms::StatusCode::SERVER_NOT_READY, "not live");
Expand Down Expand Up @@ -926,7 +937,7 @@ static Status getPipelineDefinition(Server& server, const std::string& servableN
}
return (*pipelineDefinition)->waitForLoaded(unloadGuard, 0);
}

#pragma warning(pop)
} // namespace

DLL_PUBLIC OVMS_Status* OVMS_Inference(OVMS_Server* serverPtr, OVMS_InferenceRequest* request, OVMS_InferenceResponse** response) {
Expand Down
4 changes: 3 additions & 1 deletion src/customloaderconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
#pragma once

#include <string>

#pragma warning(push)
#pragma warning(disable : 6313)
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#pragma warning(pop)
#include <spdlog/spdlog.h>

#include "filesystem.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/dags/custom_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

namespace ovms {

class NodeLibrary;
struct NodeLibrary;
class Status;
class CNLIMWrapper;
struct CNLIMWrapper;

class CustomNode : public Node {
NodeLibrary library;
Expand Down
6 changes: 3 additions & 3 deletions src/dags/customnodesession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
#include "pipelineeventqueue.hpp"
#include "tensormap.hpp"

class CustomNodeTensor;
class CustomNodeParam;
struct CustomNodeTensor;
struct CustomNodeParam;

namespace ovms {

class Node;
class NodeLibrary;
struct NodeLibrary;
class Status;

class CustomNodeSession : public NodeSession {
Expand Down
3 changes: 3 additions & 0 deletions src/dags/entry_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@
#include "../tfs_frontend/tfs_utils.hpp"
#include "nodesession.hpp"

#pragma warning(push)
#pragma warning(disable : 4624 6001 6385 6386 6326)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow_serving/apis/prediction_service.grpc.pb.h"
#pragma GCC diagnostic pop
#pragma warning(pop)

namespace ovms {

Expand Down
4 changes: 3 additions & 1 deletion src/dags/exit_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

#include <string>
#include <utility>

#pragma warning(push)
#pragma warning(disable : 4624 6001 6385 6386 6326)
#include "../capi_frontend/inferenceresponse.hpp"
#include "../logging.hpp"
#include "../ov_utils.hpp"
Expand All @@ -28,6 +29,7 @@
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include "tensorflow/core/framework/tensor.h"
#pragma GCC diagnostic pop
#pragma warning(pop)

#include "exitnodesession.hpp"

Expand Down
8 changes: 4 additions & 4 deletions src/dags/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Status Node::setInputs(const Node& dependency, TensorWithSourceMap& inputs, Node
try {
static const std::set<std::string> emptySet;
shardId = metadata.getShardId(gatherFrom.value_or(emptySet));
} catch (const std::exception& e) {
} catch (const std::exception&) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to get shardId for node: {}", getName());
return StatusCode::INTERNAL_ERROR;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ NodeSession* Node::getNodeSession(const NodeSessionMetadata& metadata) {
if (gatherFrom) {
try {
sessionKey = metadata.getSessionKey(gatherFrom.value());
} catch (const std::exception& e) {
} catch (const std::exception&) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to create collapsed metadata session key for node: {}, incoming session key: {}",
getName(), metadata.getSessionKey());
return nullptr;
Expand All @@ -177,7 +177,7 @@ NodeSession* Node::getNodeSession(const NodeSessionMetadata& metadata) {
if (gatherFrom) {
try {
std::tie(newSessionMetadata, collapsingDetails) = metadata.getCollapsedSessionMetadata(gatherFrom.value());
} catch (const std::exception& e) {
} catch (const std::exception&) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Failed to create collapsed metadata for node: {}", getName());
return nullptr;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ Status Node::demultiplyOutputs(SessionResults& nodeSessionOutputs) {
}
auto& [metadata, tensorMap] = nodeSessionOutputs.begin()->second;
auto firstTensorShape = tensorMap.begin()->second.getActualTensor().get_shape();
uint32_t resultsDemultiplyCount = firstTensorShape[0];
size_t resultsDemultiplyCount = firstTensorShape[0];
if (firstTensorShape[0] > DEMULTIPLY_LIMIT) {
SPDLOG_LOGGER_ERROR(dag_executor_logger, "Node: {} - too large dim[0] size: {} of tensor: {}. Maximum allowed is: {}",
getName(), firstTensorShape[0], tensorMap.begin()->first, DEMULTIPLY_LIMIT);
Expand Down
2 changes: 1 addition & 1 deletion src/dags/nodeinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct NodeInfo {
std::string modelName;
std::optional<model_version_t> modelVersion;
std::unordered_map<std::string, std::string> outputNameAliases;
std::optional<int32_t> demultiplyCount;
std::optional<size_t> demultiplyCount;
std::set<std::string> gatherFromNode;
NodeLibrary library;
parameters_t parameters;
Expand Down
2 changes: 1 addition & 1 deletion src/dags/nodesession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "nodesessionmetadata.hpp"

namespace ovms {
struct NodeInputHandler;
class NodeInputHandler;
struct NodeOutputHandler;
class Status;
class TensorWithSource;
Expand Down
2 changes: 1 addition & 1 deletion src/dags/nodesessionmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::string NodeSessionMetadata::createSessionKey(const std::set<std::string>& i
}
std::stringstream ss;
size_t j = 0;
for (int32_t i = sessionsLevels.size() - 1; i >= 0; --i, ++j) {
for (size_t i = sessionsLevels.size() - 1; i >= 0; --i, ++j) {
if ((ignoredNodeNames.size() > 0) &&
(ignoredNodeNames.size() > j) &&
(sessionsLevels.size() >= ignoredNodeNames.size()) &&
Expand Down
Loading

0 comments on commit 3f6ce45

Please sign in to comment.