Skip to content

Commit 1d063c1

Browse files
committed
Downgrade from c++20 to c++17
This makes c++ compiler behavior more consistent with the distro packaged compiler on debian bullseye, which is clang 11. If we want to drop the LLVM prebuilt, we'll have to support that compiler version. Bug: b/407854179
1 parent ea931a1 commit 1d063c1

File tree

8 files changed

+42
-36
lines changed

8 files changed

+42
-36
lines changed

base/cvd/build_variables.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
COPTS = [
2-
"-std=c++20",
2+
"-std=c++17",
33
# https://cs.android.com/android/platform/superproject/main/+/main:build/soong/cc/config/global.go;l=428;drc=27f57506c28cc8e4f6a0c0b8ac22c85aa9140688
44
"-ftrivial-auto-var-init=zero",
55
]

base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ Result<void> RestoreHostFiles(const std::string& cuttlefish_root_dir,
193193
CF_EXPECT(GuestSnapshotDirectories(snapshot_dir_path));
194194
auto filter_guest_dir =
195195
[&guest_snapshot_dirs](const std::string& src_dir) -> bool {
196-
if (src_dir.ends_with("logs") && Contains(guest_snapshot_dirs, src_dir)) {
196+
if (android::base::EndsWith(src_dir, "logs") &&
197+
Contains(guest_snapshot_dirs, src_dir)) {
197198
return false;
198199
}
199200
return !Contains(guest_snapshot_dirs, src_dir);

base/cvd/cuttlefish/host/commands/assemble_cvd/flags.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,7 @@ Result<void> SetDefaultFlagsForQemu(
21202120
// it's presented.
21212121
if (!FileExists(curr_bootloader)) {
21222122
// Fallback to default bootloader
2123-
curr_bootloader = DefaultHostArtifactsPath(std::format(
2123+
curr_bootloader = DefaultHostArtifactsPath(fmt::format(
21242124
"etc/bootloader_{}/bootloader.qemu",
21252125
DefaultBootloaderArchDir(guest_configs[instance_index].target_arch)));
21262126
}
@@ -2202,7 +2202,7 @@ Result<void> SetDefaultFlagsForCrosvm(
22022202
// it's presented.
22032203
if (!FileExists(curr_bootloader)) {
22042204
// Fallback to default bootloader
2205-
curr_bootloader = DefaultHostArtifactsPath(std::format(
2205+
curr_bootloader = DefaultHostArtifactsPath(fmt::format(
22062206
"etc/bootloader_{}/bootloader.crosvm",
22072207
DefaultBootloaderArchDir(guest_configs[instance_index].target_arch)));
22082208
}

base/cvd/cuttlefish/host/commands/run_cvd/launch/vhost_input_devices.cpp

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
namespace cuttlefish {
4444
namespace {
4545

46-
using Subprocess::StdIOChannel::kStdErr;
47-
4846
// Holds all sockets related to a single vhost user input device process.
4947
struct DeviceSockets {
5048
// Device end of the connection between device and streamer.
@@ -129,18 +127,20 @@ class VhostInputDevices : public CommandSource,
129127
std::vector<MonitorCommand> commands;
130128
Command rotary_cmd =
131129
NewVhostUserInputCommand(rotary_sockets_, DefaultRotaryDeviceSpec());
132-
Command rotary_log_tee = CF_EXPECT(
133-
log_tee_.CreateLogTee(rotary_cmd, "vhost_user_rotary", kStdErr),
134-
"Failed to create log tee command for rotary device");
130+
Command rotary_log_tee =
131+
CF_EXPECT(log_tee_.CreateLogTee(rotary_cmd, "vhost_user_rotary",
132+
Subprocess::StdIOChannel::kStdErr),
133+
"Failed to create log tee command for rotary device");
135134
commands.emplace_back(std::move(rotary_cmd));
136135
commands.emplace_back(std::move(rotary_log_tee));
137136

138137
if (instance_.enable_mouse()) {
139138
Command mouse_cmd =
140139
NewVhostUserInputCommand(mouse_sockets_, DefaultMouseSpec());
141-
Command mouse_log_tee = CF_EXPECT(
142-
log_tee_.CreateLogTee(mouse_cmd, "vhost_user_mouse", kStdErr),
143-
"Failed to create log tee command for mouse device");
140+
Command mouse_log_tee =
141+
CF_EXPECT(log_tee_.CreateLogTee(mouse_cmd, "vhost_user_mouse",
142+
Subprocess::StdIOChannel::kStdErr),
143+
"Failed to create log tee command for mouse device");
144144
commands.emplace_back(std::move(mouse_cmd));
145145
commands.emplace_back(std::move(mouse_log_tee));
146146
}
@@ -149,17 +149,19 @@ class VhostInputDevices : public CommandSource,
149149
instance_.custom_keyboard_config().value_or(DefaultKeyboardSpec());
150150
Command keyboard_cmd =
151151
NewVhostUserInputCommand(keyboard_sockets_, keyboard_spec);
152-
Command keyboard_log_tee = CF_EXPECT(
153-
log_tee_.CreateLogTee(keyboard_cmd, "vhost_user_keyboard", kStdErr),
154-
"Failed to create log tee command for keyboard device");
152+
Command keyboard_log_tee =
153+
CF_EXPECT(log_tee_.CreateLogTee(keyboard_cmd, "vhost_user_keyboard",
154+
Subprocess::StdIOChannel::kStdErr),
155+
"Failed to create log tee command for keyboard device");
155156
commands.emplace_back(std::move(keyboard_cmd));
156157
commands.emplace_back(std::move(keyboard_log_tee));
157158

158159
Command switches_cmd =
159160
NewVhostUserInputCommand(switches_sockets_, DefaultSwitchesSpec());
160-
Command switches_log_tee = CF_EXPECT(
161-
log_tee_.CreateLogTee(switches_cmd, "vhost_user_switches", kStdErr),
162-
"Failed to create log tee command for switches device");
161+
Command switches_log_tee =
162+
CF_EXPECT(log_tee_.CreateLogTee(switches_cmd, "vhost_user_switches",
163+
Subprocess::StdIOChannel::kStdErr),
164+
"Failed to create log tee command for switches device");
163165
commands.emplace_back(std::move(switches_cmd));
164166
commands.emplace_back(std::move(switches_log_tee));
165167

@@ -185,11 +187,11 @@ class VhostInputDevices : public CommandSource,
185187
"Failed to write touchscreen spec to file: {}", spec_path);
186188
Command touchscreen_cmd =
187189
NewVhostUserInputCommand(touchscreen_sockets_[i], spec_path);
188-
Command touchscreen_log_tee =
189-
CF_EXPECTF(log_tee_.CreateLogTee(
190-
touchscreen_cmd,
191-
fmt::format("vhost_user_touchscreen_{}", i), kStdErr),
192-
"Failed to create log tee for touchscreen device", i);
190+
Command touchscreen_log_tee = CF_EXPECTF(
191+
log_tee_.CreateLogTee(touchscreen_cmd,
192+
fmt::format("vhost_user_touchscreen_{}", i),
193+
Subprocess::StdIOChannel::kStdErr),
194+
"Failed to create log tee for touchscreen device", i);
193195
commands.emplace_back(std::move(touchscreen_cmd));
194196
commands.emplace_back(std::move(touchscreen_log_tee));
195197
}
@@ -212,10 +214,11 @@ class VhostInputDevices : public CommandSource,
212214
"Failed to write touchpad spec to file: {}", spec_path);
213215
Command touchpad_cmd =
214216
NewVhostUserInputCommand(touchpad_sockets_[i], spec_path);
215-
Command touchpad_log_tee = CF_EXPECTF(
216-
log_tee_.CreateLogTee(
217-
touchpad_cmd, fmt::format("vhost_user_touchpad_{}", i), kStdErr),
218-
"Failed to create log tee for touchpad {}", i);
217+
Command touchpad_log_tee =
218+
CF_EXPECTF(log_tee_.CreateLogTee(
219+
touchpad_cmd, fmt::format("vhost_user_touchpad_{}", i),
220+
Subprocess::StdIOChannel::kStdErr),
221+
"Failed to create log tee for touchpad {}", i);
219222
commands.emplace_back(std::move(touchpad_cmd));
220223
commands.emplace_back(std::move(touchpad_log_tee));
221224
}

base/cvd/cuttlefish/host/libs/screen_connector/composition_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void CompositionManager::OnFrame(std::uint32_t display_number,
209209
// layers are updated, the user will see the blended result.
210210
void CompositionManager::ComposeFrame(
211211
int display_index, std::shared_ptr<VideoFrameBuffer> buffer) {
212-
if (!last_frame_info_map_.contains(display_index)) {
212+
if (!last_frame_info_map_.count(display_index)) {
213213
return;
214214
}
215215
LastFrameInfo& last_frame_info = last_frame_info_map_[display_index];

base/cvd/cuttlefish/host/libs/screen_connector/ring_buffer_manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Result<void> DisplayRingBufferManager::CreateLocalDisplayBuffer(
127127
int vm_index, int display_index, int display_width, int display_height) {
128128
auto buffer_key = std::make_pair(vm_index, display_index);
129129

130-
if (!display_buffer_cache_.contains(buffer_key)) {
130+
if (!display_buffer_cache_.count(buffer_key)) {
131131
std::string shmem_name = MakeLayerName(display_index);
132132

133133
auto shm_buffer = CF_EXPECT(DisplayRingBuffer::Create(
@@ -153,7 +153,7 @@ std::uint8_t* DisplayRingBufferManager::WriteFrame(int vm_index,
153153
std::uint8_t* frame_data,
154154
int size) {
155155
auto buffer_key = std::make_pair(vm_index, display_index);
156-
if (display_buffer_cache_.contains(buffer_key)) {
156+
if (display_buffer_cache_.count(buffer_key)) {
157157
return display_buffer_cache_[buffer_key]->WriteNextFrame(frame_data, size);
158158
}
159159
// It's possible to request a write to buffer that doesn't yet exist.
@@ -168,7 +168,7 @@ std::uint8_t* DisplayRingBufferManager::ReadFrame(int vm_index,
168168

169169
// If this buffer was read successfully in the past, that valid pointer is
170170
// returned from the cache
171-
if (!display_buffer_cache_.contains(buffer_key)) {
171+
if (!display_buffer_cache_.count(buffer_key)) {
172172
// Since no cache found, next step is to request from OS to map a new IPC
173173
// buffer. It may not yet exist so we want this method to only cache if it
174174
// is a non-null pointer, to retrigger this logic continually every request.
@@ -195,7 +195,7 @@ std::string DisplayRingBufferManager::MakeLayerName(int display_index,
195195
if (vm_index == -1) {
196196
vm_index = local_group_index_;
197197
}
198-
return std::format("/cf_shmem_display_{}_{}_{}", vm_index, display_index,
198+
return fmt::format("/cf_shmem_display_{}_{}_{}", vm_index, display_index,
199199
group_uuid_);
200200
}
201201

base/cvd/cuttlefish/host/libs/vm_manager/crosvm_cpu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <vector>
2020

2121
#include <android-base/strings.h>
22+
#include <fmt/format.h>
2223
#include <json/value.h>
2324

2425
#include "common/libs/utils/json.h"
@@ -41,7 +42,7 @@ std::string SerializeFreqDomains(
4142
freq_domain_arg << "[" << android::base::Join(pair.second, ",") << "]";
4243
}
4344

44-
return {std::format("[{}]", freq_domain_arg.str())};
45+
return {fmt::format("[{}]", freq_domain_arg.str())};
4546
}
4647

4748
} // namespace

base/cvd/libziparchive/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package(
22
default_visibility = ["//:android_cuttlefish"],
33
)
44

5-
load("//:build_variables.bzl", "COPTS")
6-
75
cc_library(
86
name = "libziparchive",
97
srcs = [
@@ -23,7 +21,10 @@ cc_library(
2321
"include/ziparchive/zip_archive_stream_entry.h",
2422
"include/ziparchive/zip_writer.h",
2523
],
26-
copts = COPTS + [
24+
copts = [
25+
"-std=c++20",
26+
# https://cs.android.com/android/platform/superproject/main/+/main:build/soong/cc/config/global.go;l=428;drc=27f57506c28cc8e4f6a0c0b8ac22c85aa9140688
27+
"-ftrivial-auto-var-init=zero",
2728
"-Wno-vla-cxx-extension",
2829
"-Wno-c99-designator",
2930
],

0 commit comments

Comments
 (0)