Skip to content

Commit 9407f52

Browse files
16bit-ykikoclaude
andcommitted
feat: add master stderr logger, simplify build flow, wait for AST in workers
- Add stderr_logger for master server in pipe/socket modes so logs are visible - Remove scan_file, compile_graph deps check, and background indexer from build flow (not needed until PCH/PCM support is added) - Add ast_ready event to stateful worker so feature handlers wait for compilation instead of returning null immediately - Remove dirty document early-return in feature handlers (stale results > null) - Rewrite integration tests with pygls and stronger assertions for features - Format all changed files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9a7b01f commit 9407f52

22 files changed

+984
-1243
lines changed

pixi.lock

Lines changed: 86 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ scripts = ["scripts/activate_asan.bat"]
4949
[feature.test.pypi-dependencies]
5050
pytest = "*"
5151
pytest-asyncio = ">=1.1.0"
52+
pygls = ">=2.0.0"
53+
lsprotocol = ">=2024.0.0"
5254

5355
[feature.package.dependencies]
5456
xz = ">=5.8.1,<6"

src/clice.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ int main(int argc, const char** argv) {
7878
return 1;
7979
}
8080

81+
std::string self_path = llvm::sys::fs::getMainExecutable(argv[0], (void*)main);
82+
if(!clice::fs::init_resource_dir(self_path)) {
83+
LOG_ERROR("Cannot find the resource dir: {}", self_path);
84+
}
85+
8186
auto& mode = *opts.mode;
8287

8388
if(mode == "stateless-worker") {
@@ -90,6 +95,8 @@ int main(int argc, const char** argv) {
9095
}
9196

9297
if(mode == "pipe") {
98+
clice::logging::stderr_logger("master", clice::logging::options);
99+
93100
namespace et = eventide;
94101
et::event_loop loop;
95102

@@ -99,8 +106,6 @@ int main(int argc, const char** argv) {
99106
return 1;
100107
}
101108

102-
std::string self_path = llvm::sys::fs::getMainExecutable(argv[0], (void*)main);
103-
104109
et::ipc::JsonPeer peer(loop, std::move(*transport));
105110
clice::MasterServer server(loop, peer, std::move(self_path));
106111
server.register_handlers();
@@ -110,6 +115,8 @@ int main(int argc, const char** argv) {
110115
}
111116

112117
if(mode == "socket") {
118+
clice::logging::stderr_logger("master", clice::logging::options);
119+
113120
namespace et = eventide;
114121
et::event_loop loop;
115122

@@ -124,8 +131,6 @@ int main(int argc, const char** argv) {
124131

125132
LOG_INFO("Listening on {}:{} ...", host, port);
126133

127-
std::string self_path = llvm::sys::fs::getMainExecutable(argv[0], (void*)main);
128-
129134
auto task = [&]() -> et::task<> {
130135
auto client = co_await acceptor->accept();
131136
if(!client.has_value()) {
@@ -142,6 +147,7 @@ int main(int argc, const char** argv) {
142147
server.register_handlers();
143148

144149
co_await peer.run();
150+
peer.close();
145151
loop.stop();
146152
};
147153

src/compile/compilation.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ std::unique_ptr<clang::CompilerInvocation>
4444

4545
std::unique_ptr<clang::CompilerInvocation> invocation;
4646

47-
/// Arguments from compilation database are already cc1
48-
if(params.arguments_from_database) {
47+
/// If the second argument is "-cc1", the arguments are already expanded
48+
/// (e.g. from compilation database + query_toolchain). Skip driver and "-cc1"
49+
/// and create invocation directly from the cc1 args.
50+
bool is_cc1 = params.arguments.size() >= 2 && llvm::StringRef(params.arguments[1]) == "-cc1";
51+
if(is_cc1) {
4952
invocation = std::make_unique<clang::CompilerInvocation>();
50-
if(!clang::CompilerInvocation::CreateFromArgs(*invocation,
51-
llvm::ArrayRef(params.arguments).drop_front(),
52-
*diagnostic_engine,
53-
params.arguments[0])) {
53+
if(!clang::CompilerInvocation::CreateFromArgs(
54+
*invocation,
55+
llvm::ArrayRef(params.arguments).drop_front(2),
56+
*diagnostic_engine,
57+
params.arguments[0])) {
5458
LOG_ERROR_RET(nullptr,
5559
" Fail to create invocation, arguments list is: {}",
5660
print_argv(params.arguments));

src/compile/compilation.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ struct CompilationParams {
7575

7676
std::string directory;
7777

78-
bool arguments_from_database = false;
79-
8078
/// Responsible for storing the arguments.
8179
std::vector<const char*> arguments;
8280

src/compile/toolchain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ std::vector<const char*> query_toolchain(const QueryParams& params) {
382382
query_driver(params_copy.arguments,
383383
[&](const char* driver, llvm::ArrayRef<const char*> cc1_args) {
384384
result.emplace_back(params.callback(driver));
385+
result.emplace_back(params.callback("-cc1"));
385386
for(auto arg: cc1_args) {
386387
result.emplace_back(params.callback(arg));
387388
}
@@ -435,6 +436,7 @@ std::vector<const char*> query_gcc_toolchain(const QueryParams& params) {
435436
std::vector<const char*> result;
436437
query_driver(query_arguments, [&](const char* driver, llvm::ArrayRef<const char*> cc1_args) {
437438
result.emplace_back(params.callback(driver));
439+
result.emplace_back(params.callback("-cc1"));
438440
for(auto arg: cc1_args) {
439441
result.emplace_back(params.callback(arg));
440442
}

0 commit comments

Comments
 (0)