Skip to content

Commit

Permalink
fix linux and macOS build (#2073)
Browse files Browse the repository at this point in the history
Summary:
fix linux and macOS build

linux and mac build was failing:
   * gcc and xcode hide std::chrono::years if C++ 20 mode not set.  Disable the affected test in this case
   * same with std::latch, also disable the affected test in this case

macOS build was failing with:

   * missing header includes, added them

macOS test run was failing with:
   * libcpp exception text has changed from "with" to "due to" which was breaking ExceptionTest.cpp, update the expectation to cover both.
   * FileUtilDetail.cpp was only enabling custom temp dir on linux, breaking FileUtilTest.cpp.  Enable custom temp dir for non-windows (i.e. mac and other unix) to fix it.

Pull Request resolved: #2073

Test Plan:
CI.  Before, build error on vector
```
CMakeFiles/tdigest_benchmark.dir/folly/stats/test/TDigestBenchmark.cpp.o -MF CMakeFiles/tdigest_benchmark.dir/folly/stats/test/TDigestBenchmark.cpp.o.d -o CMakeFiles/tdigest_benchmark.dir/folly/stats/test/TDigestBenchmark.cpp.o -c /Users/runner/work/folly/folly/folly/stats/test/TDigestBenchmark.cpp
In file included from /Users/runner/work/folly/folly/folly/stats/test/TDigestBenchmark.cpp:17:
/Users/runner/work/folly/folly/folly/stats/DigestBuilder.h:59:25: error: implicit instantiation of undefined template 'std::vector<double>'
    std::vector<double> buffer;
```

then build error on array
```
CMakeFiles/constexpr_math_test.dir/folly/test/ConstexprMathTest.cpp.o -c /Users/runner/work/folly/folly/folly/test/ConstexprMathTest.cpp
/Users/runner/work/folly/folly/folly/test/ConstexprMathTest.cpp:38:29: error: implicit instantiation of undefined template 'std::array<unsigned long, 7>'
    std::array<res_t, size> res{};
```

the build error on std::chrono::year
```
/Users/alex/local/folly.sapling/folly/logging/test/RateLimiterTest.cpp:124:47: error: no member named 'years' in namespace 'std::chrono'
  IntervalRateLimiter limiter{1, std::chrono::years{1}};
```

then test failues

After, works

 ---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/folly/pull/2073).
* #2074
* #2068
* #2084
* __->__ #2073

Reviewed By: xavierd

Differential Revision: D49931137

Pulled By: Orvid

fbshipit-source-id: 58830a637e73375eb648c5897dd8a1e5e479c657
  • Loading branch information
ahornby authored and facebook-github-bot committed Dec 13, 2023
1 parent 03adf32 commit 33c32b5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
10 changes: 9 additions & 1 deletion folly/concurrency/test/ConcurrentHashMapTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@
#include <folly/concurrency/ConcurrentHashMap.h>

#include <atomic>
#include <latch>
#include <limits>
#include <memory>
#include <thread>
#include <vector>

#include <folly/Portability.h>
#include <folly/Traits.h>
#include <folly/container/test/TrackingTypes.h>
#include <folly/hash/Hash.h>
#include <folly/portability/GFlags.h>
#include <folly/portability/GTest.h>
#include <folly/test/DeterministicSchedule.h>

#if FOLLY_CPLUSPLUS >= 202002L
// std::latch becomes visible in C++20 mode
#include <latch>
#endif

using namespace folly::test;
using namespace folly;
using namespace std;
Expand Down Expand Up @@ -1135,6 +1140,8 @@ TYPED_TEST_P(ConcurrentHashMapTest, ConcurrentInsertClear) {
}

TYPED_TEST_P(ConcurrentHashMapTest, StressTestReclamation) {
// This needs C++20 for std::latch.
#if FOLLY_CPLUSPLUS >= 202002L
// Create a map where we keep reclaiming a lot of objects that are linked to
// one node.

Expand Down Expand Up @@ -1178,6 +1185,7 @@ TYPED_TEST_P(ConcurrentHashMapTest, StressTestReclamation) {
for (auto& t : threads) {
join;
}
#endif
}

REGISTER_TYPED_TEST_SUITE_P(
Expand Down
6 changes: 3 additions & 3 deletions folly/detail/FileUtilDetail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ std::string getTemporaryFilePathStringWithoutTempDirectory(

std::string getTemporaryFilePathStringWithTemporaryDirectory(
const std::string& temporaryDirectory) {
#if defined(__linux__) && !FOLLY_MOBILE
#if !defined(_WIN32) && !FOLLY_MOBILE
return (temporaryDirectory.back() == '/')
? (temporaryDirectory + std::string{"tempForAtomicWrite.XXXXXX"})
: (temporaryDirectory + std::string{"/tempForAtomicWrite.XXXXXX"});
#else
// The implementation currently, does not support any platform other than
// linux for temporary directory based atomic file writes.
// The implementation currently does not support win32 or mobile
// for temporary directory based atomic file writes.
static_cast<void>(temporaryDirectory);
assert(false);

Expand Down
2 changes: 1 addition & 1 deletion folly/lang/test/ExceptionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ template <typename Ex>
static std::string message_for_terminate_with(std::string const& what) {
auto const name = folly::pretty_name<Ex>();
std::string const p0 = "terminate called after throwing an instance of";
std::string const p1 = "terminating with uncaught exception of type";
std::string const p1 = "terminating (due to|with) uncaught exception of type";
// clang-format off
return
folly::kIsGlibcxx ? p0 + " '" + name + "'\\s+what\\(\\):\\s+" + what :
Expand Down
1 change: 1 addition & 0 deletions folly/stats/DigestBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include <memory>
#include <vector>

#include <folly/Memory.h>
#include <folly/SpinLock.h>
Expand Down
1 change: 1 addition & 0 deletions folly/test/ConstexprMathTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <folly/ConstexprMath.h>

#include <array>
#include <cmath>
#include <limits>
#include <type_traits>
Expand Down

0 comments on commit 33c32b5

Please sign in to comment.