Skip to content

Commit 2d0dd3c

Browse files
authored
fix: clang build for macos (#5862)
* fix: clang build for macos * fix: linux build * fix: revert helio revision * fix: bump helio revision
1 parent 7899e80 commit 2d0dd3c

File tree

5 files changed

+43
-24
lines changed

5 files changed

+43
-24
lines changed

.github/workflows/daily-builds.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
-d '{"text": "'"${message}"'"}'
7070
7171
build-macos:
72-
runs-on: macos-14
72+
runs-on: macos-15
7373
timeout-minutes: 45
7474
steps:
7575
- uses: actions/checkout@v5
@@ -99,15 +99,27 @@ jobs:
9999
which bison
100100
bison --version
101101
102-
gcc-12 --version
102+
# Check system clang version
103+
clang --version
104+
clang++ --version
105+
106+
# Verify current macOS SDK
107+
xcrun --show-sdk-path
103108
104109
autoconf --help
105110
autoreconf --help
106111
107112
echo "*************************** START BUILDING **************************************"
108-
CC=gcc-12 CXX=g++-12 cmake .. -DCMAKE_BUILD_TYPE=Debug -GNinja -DWITH_UNWIND=OFF \
109-
-DCMAKE_CXX_FLAGS="-Wl,-ld_classic" \
110-
-DCMAKE_C_COMPILER="gcc-12" -DCMAKE_CXX_COMPILER="g++-12"
113+
# Configure for using current macOS SDK
114+
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
115+
echo "Using SDK: $SDKROOT"
116+
117+
# Use system clang/clang++ with macOS SDK
118+
cmake .. -DCMAKE_BUILD_TYPE=Debug -GNinja \
119+
-DCMAKE_C_COMPILER=clang \
120+
-DCMAKE_CXX_COMPILER=clang++ \
121+
-DCMAKE_OSX_SYSROOT="$SDKROOT" \
122+
-DCMAKE_OSX_DEPLOYMENT_TARGET=15.0
111123
112124
ninja src/all
113125

helio

src/server/bitops_family.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,17 +564,21 @@ void BitCount(CmdArgList args, const CommandContext& cmd_cntx) {
564564
CmdArgParser parser(args);
565565
auto key = parser.Next<string_view>();
566566

567-
auto [start, end] = parser.HasNext()
568-
? parser.Next<int64_t, int64_t>()
569-
: std::pair<int64_t, int64_t>{0, std::numeric_limits<int64_t>::max()};
567+
std::pair<int64_t, int64_t> start_end;
568+
if (parser.HasNext()) {
569+
auto tuple_result = parser.Next<int64_t, int64_t>();
570+
start_end = std::make_pair(std::get<0>(tuple_result), std::get<1>(tuple_result));
571+
} else {
572+
start_end = std::make_pair(0, std::numeric_limits<int64_t>::max());
573+
}
570574

571575
bool as_bit = parser.HasNext() ? parser.MapNext("BYTE", false, "BIT", true) : false;
572576
auto* builder = cmd_cntx.rb;
573577
if (!parser.Finalize()) {
574578
return builder->SendError(parser.TakeError().MakeReply());
575579
}
576-
auto cb = [&, &start = start, &end = end](Transaction* t, EngineShard* shard) {
577-
return CountBitsForValue(t->GetOpArgs(shard), key, start, end, as_bit);
580+
auto cb = [&, start_end](Transaction* t, EngineShard* shard) {
581+
return CountBitsForValue(t->GetOpArgs(shard), key, start_end.first, start_end.second, as_bit);
578582
};
579583
OpResult<std::size_t> res = cmd_cntx.tx->ScheduleSingleHopT(std::move(cb));
580584
HandleOpValueResult(res, builder);

src/server/geo_family_test.cc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ TEST_F(GeoFamilyTest, GeoAddOptions) {
6060
// update 1 + CH + XX
6161
EXPECT_EQ(1, CheckedInt({"geoadd", "Sicily", "CH", "XX", "10.361389", "38.115556", "Palermo"}));
6262
resp = Run({"geopos", "Sicily", "Palermo"});
63-
EXPECT_THAT(resp, RespArray(ElementsAre("10.361386835575104", "38.1155563954963")));
63+
EXPECT_THAT(resp, RespArray(ElementsAre(DoubleArg(10.361389), DoubleArg(38.115556))));
6464

6565
// add 1 + CH + NX
6666
EXPECT_EQ(1, CheckedInt({"geoadd", "Sicily", "CH", "NX", "14.25", "37.066667", "Gela"}));
6767
resp = Run({"geopos", "Sicily", "Gela"});
68-
EXPECT_THAT(resp, RespArray(ElementsAre("14.249999821186066", "37.06666596727141")));
68+
EXPECT_THAT(resp, RespArray(ElementsAre(DoubleArg(14.25), DoubleArg(37.066667))));
6969

7070
// add 1 + XX + NX
7171
resp = Run({"geoadd", "Sicily", "XX", "NX", "14.75", "36.933333", "Ragusa"});
@@ -209,11 +209,11 @@ TEST_F(GeoFamilyTest, GeoRadiusByMember) {
209209
EXPECT_THAT(
210210
resp,
211211
RespArray(ElementsAre(
212-
RespArray(ElementsAre(
213-
"Madrid", "0", RespArray(ElementsAre("3.7038007378578186", "40.416799319406216")))),
212+
RespArray(ElementsAre("Madrid", DoubleArg(0),
213+
RespArray(ElementsAre(DoubleArg(3.703801), DoubleArg(40.416799))))),
214214
RespArray(
215-
ElementsAre("Lisbon", "502.20769462704084",
216-
RespArray(ElementsAre("9.142698347568512", "38.736900197448534")))))));
215+
ElementsAre("Lisbon", DoubleArg(502.207695),
216+
RespArray(ElementsAre(DoubleArg(9.142698), DoubleArg(38.736900))))))));
217217

218218
EXPECT_EQ(
219219
2, CheckedInt({"GEORADIUSBYMEMBER", "Europe", "Madrid", "700", "KM", "STORE", "store_key"}));
@@ -226,7 +226,8 @@ TEST_F(GeoFamilyTest, GeoRadiusByMember) {
226226
EXPECT_EQ(2, CheckedInt({"GEORADIUSBYMEMBER", "Europe", "Madrid", "700", "KM", "STOREDIST",
227227
"store_dist_key"}));
228228
resp = Run({"ZRANGE", "store_dist_key", "0", "-1", "WITHSCORES"});
229-
EXPECT_THAT(resp, RespArray(ElementsAre("Madrid", "0", "Lisbon", "502.20769462704084")));
229+
EXPECT_THAT(resp,
230+
RespArray(ElementsAre("Madrid", DoubleArg(0), "Lisbon", DoubleArg(502.207695))));
230231

231232
resp = Run(
232233
{"GEORADIUSBYMEMBER", "Europe", "Madrid", "900", "KM", "STORE", "store_key", "WITHCOORD"});
@@ -259,11 +260,11 @@ TEST_F(GeoFamilyTest, GeoRadiusByMemberRO) {
259260
EXPECT_THAT(
260261
resp,
261262
RespArray(ElementsAre(
262-
RespArray(ElementsAre(
263-
"Madrid", "0", RespArray(ElementsAre("3.7038007378578186", "40.416799319406216")))),
263+
RespArray(ElementsAre("Madrid", DoubleArg(0),
264+
RespArray(ElementsAre(DoubleArg(3.703801), DoubleArg(40.416799))))),
264265
RespArray(
265-
ElementsAre("Lisbon", "502.20769462704084",
266-
RespArray(ElementsAre("9.142698347568512", "38.736900197448534")))))));
266+
ElementsAre("Lisbon", DoubleArg(502.207695),
267+
RespArray(ElementsAre(DoubleArg(9.142698), DoubleArg(38.736900))))))));
267268

268269
// GEORADIUSBYMEMBER_RO should not accept arguments for storing (writing data)
269270
resp =

src/server/json_family_memory_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,10 @@ TEST_F(JsonFamilyMemoryTest, JsonShrinking) {
205205

206206
// Jsoncons will allocate more memory for the new json that needed.
207207
// This is totally fine, because we will not call shrink_to_fit.
208-
EXPECT_THAT(resp, IntArg(368));
209-
EXPECT_GT(368, start_size);
208+
// Different compilers may allocate different amounts, so check reasonable range
209+
auto final_size = get<int64_t>(resp.u);
210+
EXPECT_GT(final_size, start_size); // Should be larger than initial
211+
EXPECT_LT(final_size, start_size * 2); // But not unreasonably large
210212
}
211213

212214
} // namespace dfly

0 commit comments

Comments
 (0)