Commit 9d608677 authored by Adam Hupp's avatar Adam Hupp Committed by Facebook GitHub Bot

Fix mixed MSVC/clang-cl build (#1617)

Summary:
An executable built by clang-cl that is linked against folly/logging
from vcpkg will fail to link due to a few missing symbols.  folly/logging
has a number of functions that are only defined when `__INCLUDE_LEVEL__` is defined.
vcpkg always uses MSVC, MSVC does not support this macro while clang-cl does,
resulting in mismatch between what is defined, used, and declared.

These ifdefs mostly came from fc507b26.

The (minor IMO) negative consequence of this diff is that
`XlogFileScopeInfo` will be unnecessarily larger (a pointer and an uint32)
 on compilers that don't support `__INCLUDE_LEVEL__` (e.g MSVC).

The actual condition of whether to make use of `__INCLUDE_LEVEL__` remains, via the `XLOG_IS_IN_HEADER_FILE` macro.

Pull Request resolved: https://github.com/facebook/folly/pull/1617

Reviewed By: yfeldblum

Differential Revision: D29753787

Pulled By: Orvid

fbshipit-source-id: 28f8128c981b255960d7838d2df2a3d299153bc2
parent 0a5dcad2
......@@ -111,7 +111,6 @@ LogStreamProcessor::LogStreamProcessor(
message_{std::move(msg)},
stream_{this} {}
#ifdef __INCLUDE_LEVEL__
namespace {
LogCategory* getXlogCategory(XlogFileScopeInfo* fileScopeInfo) {
// By the time a LogStreamProcessor is created, the XlogFileScopeInfo object
......@@ -165,7 +164,6 @@ LogStreamProcessor::LogStreamProcessor(
functionName,
INTERNAL,
std::string()) {}
#endif
/*
* We intentionally define the LogStreamProcessor destructor in
......
......@@ -186,7 +186,6 @@ class LogStreamProcessor {
INTERNAL,
formatLogString(fmt, std::forward<Args>(args)...)) {}
#ifdef __INCLUDE_LEVEL__
/*
* Versions of the above constructors to use in XLOG() macros that appear in
* .cpp files. These are only used if the compiler supports the
......@@ -254,7 +253,6 @@ class LogStreamProcessor {
functionName,
INTERNAL,
formatLogString(fmt, std::forward<Args>(args)...)) {}
#endif
~LogStreamProcessor() noexcept;
......
......@@ -123,7 +123,6 @@ LogCategory* XlogCategoryInfo<IsInHeaderFile>::init(
&isInitialized_);
}
#ifdef __INCLUDE_LEVEL__
LogLevel XlogLevelInfo<false>::loadLevelFull(
folly::StringPiece categoryName,
bool isOverridden,
......@@ -137,12 +136,8 @@ LogLevel XlogLevelInfo<false>::loadLevelFull(
}
return currentLevel;
}
#endif
// Explicitly instantiations of XlogLevelInfo and XlogCategoryInfo
// If __INCLUDE_LEVEL__ is not available only the "true" variants ever get
// used, because we cannot determine if we are ever in the .cpp file being
// compiled or not.
template class XlogLevelInfo<true>;
template class XlogCategoryInfo<true>;
} // namespace folly
......@@ -636,10 +636,8 @@ namespace folly {
class XlogFileScopeInfo {
public:
#ifdef __INCLUDE_LEVEL__
std::atomic<::folly::LogLevel> level;
::folly::LogCategory* category;
#endif
};
/**
......@@ -712,7 +710,6 @@ class XlogCategoryInfo {
LogCategory* category_;
};
#ifdef __INCLUDE_LEVEL__
/**
* Specialization of XlogLevelInfo for XLOG() statements in the .cpp file being
* compiled. In this case we only define a single file-static LogLevel object
......@@ -765,7 +762,6 @@ class XlogCategoryInfo<false> {
return fileScopeInfo;
}
};
#endif
/**
* Get the default XLOG() category name for the given filename.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment