Unbreak the MSVC build

Don't use inline variables, our MSVC builds do not like them.

Instead, simulate them using inline functions + function-scope static variables.

PiperOrigin-RevId: 317428053
Change-Id: Icf8838c159ab9f132ad32360633046f4c2224a79
This commit is contained in:
David Majnemer 2020-06-19 21:10:52 -07:00 committed by TensorFlower Gardener
parent fcba37557a
commit 728a4a4405
3 changed files with 15 additions and 8 deletions

View File

@ -37,7 +37,7 @@ using ManifestT = absl::flat_hash_map<std::string, std::vector<std::string>>;
ManifestT ReadManifest() {
ManifestT manifest;
absl::string_view path = absl::NullSafeStringView(kDisabledManifestPath);
absl::string_view path = absl::NullSafeStringView(*DisabledManifestPath());
if (path.empty()) {
return manifest;
}
@ -115,7 +115,7 @@ void ManifestCheckingTest::SetUp() {
// Expect a full match vs. one of the platform regexps to disable the test.
const std::vector<std::string>& disabled_platforms = it->second;
auto platform_string = kTestPlatform;
auto platform_string = *TestPlatform();
for (const auto& s : disabled_platforms) {
if (RE2::FullMatch(/*text=*/platform_string, /*re=*/s)) {
GTEST_SKIP();

View File

@ -20,10 +20,10 @@ limitations under the License.
namespace xla {
static bool InitModule() {
kDisabledManifestPath = XLA_DISABLED_MANIFEST;
VLOG(1) << "kDisabledManifestPath: " << kDisabledManifestPath;
kTestPlatform = XLA_PLATFORM;
VLOG(1) << "kTestPlatform: " << kTestPlatform;
*DisabledManifestPath() = XLA_DISABLED_MANIFEST;
VLOG(1) << "DisabledManifestPath: " << *DisabledManifestPath();
*TestPlatform() = XLA_PLATFORM;
VLOG(1) << "TestPlatform: " << *TestPlatform();
return false;
}

View File

@ -73,8 +73,15 @@ limitations under the License.
namespace xla {
inline const char *kDisabledManifestPath = nullptr;
inline const char *kTestPlatform = nullptr;
inline const char** DisabledManifestPath() {
static const char* disabled_manifest_path = nullptr;
return &disabled_manifest_path;
}
inline const char** TestPlatform() {
static const char* test_platform = nullptr;
return &test_platform;
}
} // namespace xla