Skip to content

Commit

Permalink
Visual Studio/MSVC build fixes (#4443)
Browse files Browse the repository at this point in the history
# Description

This solves a number of issue that have broken MSVC build:

- VS project fixes
- Duplicate object names
- Some MSVC-exclusive compile errors
- Notably, MSVC has reached the limit of the code branching in
Config.cpp. I did a small fix, but probably we should adapt the map
pattern to more parameters

# Checklist
- [ ] Reviewed the
[contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes)
document
- [ ] Rebased on top of master (no merge commits)
- [ ] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio
extension)
- [ ] Compiles
- [ ] Ran all tests
- [ ] If change impacts performance, include supporting evidence per the
[performance
document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)
  • Loading branch information
dmkozh authored Aug 27, 2024
2 parents f1e0c55 + 5a1e73f commit 052c40b
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 43 deletions.
57 changes: 50 additions & 7 deletions Builds/VisualStudio/stellar-core.vcxproj

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions Builds/VisualStudio/stellar-core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
<Filter Include="generated">
<UniqueIdentifier>{f421dda1-de1d-43af-b5b8-138a24c87cd2}</UniqueIdentifier>
</Filter>
<Filter Include="lib\httpthreaded">
<UniqueIdentifier>{feb33c2b-4955-4db8-b62d-72cbc3129a44}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\lib\util\getopt_long.c">
Expand Down Expand Up @@ -1347,6 +1350,33 @@
<ClCompile Include="..\..\src\overlay\Hmac.cpp">
<Filter>overlay</Filter>
</ClCompile>
<ClCompile Include="..\..\src\transactions\test\TransactionTestFrame.cpp">
<Filter>transactions\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\util\BinaryFuseFilter.cpp">
<Filter>util</Filter>
</ClCompile>
<ClCompile Include="..\..\src\util\test\BinaryFuseTests.cpp">
<Filter>util\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\transactions\MutableTransactionResult.cpp">
<Filter>transactions</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\httpthreaded\connection.cpp">
<Filter>lib\httpthreaded</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\httpthreaded\reply.cpp">
<Filter>lib\httpthreaded</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\httpthreaded\request_parser.cpp">
<Filter>lib\httpthreaded</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\httpthreaded\server.cpp">
<Filter>lib\httpthreaded</Filter>
</ClCompile>
<ClCompile Include="..\..\src\main\QueryServer.cpp">
<Filter>main</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\lib\util\cpptoml.h">
Expand Down Expand Up @@ -2342,6 +2372,36 @@
<ClInclude Include="..\..\src\overlay\Hmac.h">
<Filter>overlay</Filter>
</ClInclude>
<ClInclude Include="..\..\src\transactions\test\TransactionTestFrame.h">
<Filter>transactions\tests</Filter>
</ClInclude>
<ClInclude Include="..\..\src\util\BinaryFuseFilter.h">
<Filter>util</Filter>
</ClInclude>
<ClInclude Include="..\..\src\transactions\MutableTransactionResult.h">
<Filter>transactions</Filter>
</ClInclude>
<ClInclude Include="..\..\lib\httpthreaded\connection.hpp">
<Filter>lib\httpthreaded</Filter>
</ClInclude>
<ClInclude Include="..\..\lib\httpthreaded\header.hpp">
<Filter>lib\httpthreaded</Filter>
</ClInclude>
<ClInclude Include="..\..\lib\httpthreaded\reply.hpp">
<Filter>lib\httpthreaded</Filter>
</ClInclude>
<ClInclude Include="..\..\lib\httpthreaded\request.hpp">
<Filter>lib\httpthreaded</Filter>
</ClInclude>
<ClInclude Include="..\..\lib\httpthreaded\request_parser.hpp">
<Filter>lib\httpthreaded</Filter>
</ClInclude>
<ClInclude Include="..\..\lib\httpthreaded\server.hpp">
<Filter>lib\httpthreaded</Filter>
</ClInclude>
<ClInclude Include="..\..\src\main\QueryServer.h">
<Filter>main</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\AUTHORS" />
Expand Down
2 changes: 1 addition & 1 deletion lib/binaryfusefilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sip_hash24(uint64_t key, binary_fuse_seed_t const& seed)
static inline uint64_t
binary_fuse_rotl64(uint64_t n, unsigned int c)
{
return (n << (c & 63)) | (n >> ((-c) & 63));
return (n << (c & 63)) | (n >> ((0u - c) & 63));
}
static inline uint32_t
binary_fuse_reduce(uint32_t hash, uint32_t n)
Expand Down
2 changes: 1 addition & 1 deletion src/bucket/BucketIndexImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ BucketIndexImpl<IndexT>::BucketIndexImpl(BucketManager& bm,
// the page size ahead of time
if constexpr (std::is_same<IndexT, RangeIndex>::value)
{
auto fileSize = fs::size(filename);
auto fileSize = std::filesystem::file_size(filename);
auto estimatedIndexEntries = fileSize / mData.pageSize;
mData.keysToOffset.reserve(estimatedIndexEntries);
}
Expand Down
2 changes: 1 addition & 1 deletion src/bucket/BucketListSnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SearchableBucketListSnapshot : public NonMovableOrCopyable

SearchableBucketListSnapshot(BucketSnapshotManager const& snapshotManager);

friend std::unique_ptr<SearchableBucketListSnapshot>
friend std::shared_ptr<SearchableBucketListSnapshot>
BucketSnapshotManager::copySearchableBucketListSnapshot() const;

public:
Expand Down
2 changes: 2 additions & 0 deletions src/bucket/BucketManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ BucketManagerImpl::startBackgroundEvictionScan(uint32_t ledgerSeq)
auto const& sas = cfg.stateArchivalSettings();

using task_t = std::packaged_task<EvictionResult()>;
// MSVC gotcha: searchableBL has to be shared_ptr because MSVC wants to
// copy this lambda, otherwise we could use unique_ptr.
auto task = std::make_shared<task_t>(
[bl = std::move(searchableBL), iter = cfg.evictionIterator(), ledgerSeq,
sas, &counters = mBucketListEvictionCounters,
Expand Down
6 changes: 3 additions & 3 deletions src/bucket/BucketSnapshotManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ BucketSnapshotManager::BucketSnapshotManager(
releaseAssert(threadIsMain());
}

std::unique_ptr<SearchableBucketListSnapshot>
std::shared_ptr<SearchableBucketListSnapshot>
BucketSnapshotManager::copySearchableBucketListSnapshot() const
{
// Can't use std::make_unique due to private constructor
return std::unique_ptr<SearchableBucketListSnapshot>(
// Can't use std::make_shared due to private constructor
return std::shared_ptr<SearchableBucketListSnapshot>(
new SearchableBucketListSnapshot(*this));
}

Expand Down
2 changes: 1 addition & 1 deletion src/bucket/BucketSnapshotManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class BucketSnapshotManager : NonMovableOrCopyable
std::unique_ptr<BucketListSnapshot const>&& snapshot,
uint32_t numHistoricalLedgers);

std::unique_ptr<SearchableBucketListSnapshot>
std::shared_ptr<SearchableBucketListSnapshot>
copySearchableBucketListSnapshot() const;

// Checks if snapshot is out of date with mCurrentSnapshot and updates
Expand Down
2 changes: 1 addition & 1 deletion src/ledger/LedgerTxnImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ class LedgerTxnRoot::Impl
mutable BestOffers mBestOffers;
mutable uint64_t mPrefetchHits{0};
mutable uint64_t mPrefetchMisses{0};
mutable std::unique_ptr<SearchableBucketListSnapshot>
mutable std::shared_ptr<SearchableBucketListSnapshot>
mSearchableBucketListSnapshot{};

size_t mBulkLoadBatchSize;
Expand Down
42 changes: 17 additions & 25 deletions src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,17 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
}
std::vector<ValidatorEntry> validators;
UnorderedMap<std::string, ValidatorQuality> domainQualityMap;
UnorderedMap<std::string, uint32_t*> uint32WithMax1Flags = {
{"PEER_READING_CAPACITY", &PEER_READING_CAPACITY},
{"PEER_FLOOD_READING_CAPACITY", &PEER_FLOOD_READING_CAPACITY},
{"FLOW_CONTROL_SEND_MORE_BATCH_SIZE",
&FLOW_CONTROL_SEND_MORE_BATCH_SIZE},
{"PEER_FLOOD_READING_CAPACITY_BYTES",
&PEER_FLOOD_READING_CAPACITY_BYTES},
{"FLOW_CONTROL_SEND_MORE_BATCH_SIZE_BYTES",
&FLOW_CONTROL_SEND_MORE_BATCH_SIZE_BYTES},
{"OUTBOUND_TX_QUEUE_BYTE_LIMIT", &OUTBOUND_TX_QUEUE_BYTE_LIMIT},
};

// cpptoml returns the items in non-deterministic order
// so we need to process items that are potential dependencies first
Expand All @@ -1012,33 +1023,14 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
logIfSet(item,
"node may not function properly with most networks");
}

if (item.first == "PEER_READING_CAPACITY")
{
PEER_READING_CAPACITY = readInt<uint32_t>(item, 1);
}
else if (item.first == "PEER_FLOOD_READING_CAPACITY")
auto uint32WithMax1It = uint32WithMax1Flags.find(item.first);
if (uint32WithMax1It != uint32WithMax1Flags.end())
{
PEER_FLOOD_READING_CAPACITY = readInt<uint32_t>(item, 1);
*uint32WithMax1It->second = readInt<uint32_t>(item, 1);
continue;
}
else if (item.first == "FLOW_CONTROL_SEND_MORE_BATCH_SIZE")
{
FLOW_CONTROL_SEND_MORE_BATCH_SIZE = readInt<uint32_t>(item, 1);
}
else if (item.first == "PEER_FLOOD_READING_CAPACITY_BYTES")
{
PEER_FLOOD_READING_CAPACITY_BYTES = readInt<uint32_t>(item, 1);
}
else if (item.first == "FLOW_CONTROL_SEND_MORE_BATCH_SIZE_BYTES")
{
FLOW_CONTROL_SEND_MORE_BATCH_SIZE_BYTES =
readInt<uint32_t>(item, 1);
}
else if (item.first == "OUTBOUND_TX_QUEUE_BYTE_LIMIT")
{
OUTBOUND_TX_QUEUE_BYTE_LIMIT = readInt<uint32_t>(item, 1);
}
else if (item.first == "PEER_PORT")

if (item.first == "PEER_PORT")
{
PEER_PORT = readInt<unsigned short>(item, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/QueryServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class QueryServer
httpThreaded::server::server mServer;

std::unordered_map<std::thread::id,
std::unique_ptr<SearchableBucketListSnapshot>>
std::shared_ptr<SearchableBucketListSnapshot>>
mBucketListSnapshots;

bool safeRouter(HandlerRoute route, std::string const& params,
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ pub fn get_soroban_version_info(core_max_proto: u32) -> SorobanVersionInfo {
}
if core_max_proto != env_max_proto {
warn!(
"soroban version {} XDR module built with 'next' feature, \
"soroban version {} XDR module for env version {} built with 'next' feature, \
even though this is not the newest core protocol ({})",
VERSION.pkg, core_max_proto
VERSION.pkg, env_max_proto, core_max_proto
);
warn!(
"this can happen if multiple soroban crates depend on the \
Expand Down

0 comments on commit 052c40b

Please sign in to comment.