[llvm] [clang] [clang][MBD] set up module build daemon infrastructure (PR #67562)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 10:35:12 PST 2024


================
@@ -0,0 +1,48 @@
+//===------------------------------ Utils.h -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Functions required by both the frontend and the module build daemon
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLING_MODULEBUILDDAEMON_UTILS_H
+#define LLVM_CLANG_TOOLING_MODULEBUILDDAEMON_UTILS_H
+
+#include "llvm/Support/Error.h"
+
+#include <string>
+
+#ifdef _WIN32
+#include <afunix.h>
+#else
+#include <sys/un.h>
+#endif
+
+namespace clang::tooling::cc1modbuildd {
+
+constexpr const std::string_view SOCKET_FILE_NAME = "mbd.sock";
+constexpr const std::string_view STDOUT_FILE_NAME = "mbd.out";
+constexpr const std::string_view STDERR_FILE_NAME = "mbd.err";
+constexpr const std::string_view MODULE_BUILD_DAEMON_FLAG = "-cc1modbuildd";
+
+// A llvm::raw_socket_stream uses sockaddr_un
+constexpr const size_t SOCKET_ADDR_MAX_LENGTH = sizeof(sockaddr_un::sun_path);
+
+constexpr const size_t BASEPATH_MAX_LENGTH =
+    SOCKET_ADDR_MAX_LENGTH - std::string_view(SOCKET_FILE_NAME).length();
----------------
jansvoboda11 wrote:

Is constructing new `std::string_view` from `SOCKET_FILE_NAME` necessary?

https://github.com/llvm/llvm-project/pull/67562


More information about the cfe-commits mailing list