Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KSP2] Running from command line never finishes #2176

Closed
oscarthecat opened this issue Oct 26, 2024 · 3 comments · Fixed by #2203
Closed

[KSP2] Running from command line never finishes #2176

oscarthecat opened this issue Oct 26, 2024 · 3 comments · Fixed by #2203
Milestone

Comments

@oscarthecat
Copy link

oscarthecat commented Oct 26, 2024

we used to repeat ksp command when using ksp1, from args print by gradle with --debug options
the output like

2024-10-27T02:16:47.936+0800 [DEBUG] [org.jetbrains.kotlin.compilerRunner.KotlinNativeCompilerRunner_Decorated] Run in-process tool "konanc"
Entry point method = org.jetbrains.kotlin.cli.utilities.MainKt.daemonMain
Classpath = [
	/Users/myname/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.21/konan/lib/kotlin-native-compiler-embeddable.jar
	/Users/myname/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.21/konan/lib/trove4j.jar
]
Arguments = [
	-g
	-enable-assertions
	-library
Transformed arguments = [
	konanc
	-g
	-enable-assertions
	-library

but when we set ksp.useKSP2=true, --debug do not generate any konanc args. I understand that's because ksp2 is no longer a compiler plugin like the docs said, but https://github.com/google/ksp/blob/2.0.21-1.0.26/docs/ksp2cmdline.md is not clear enough for a new ksp user without gradle in ci environment like me (for example i don't know what kotlin-analysis-api-2.0.0-1.0.21.jar is, and can't find it in kotlinc/kotlin-native/ksp downloaded). Can we still have a direct view on what command is exec now, pls... Thank you very much.

@oscarthecat oscarthecat changed the title Any way to see how to run ksp2 cmd like gradle did? ksp2 run in cli never ends Nov 4, 2024
@oscarthecat
Copy link
Author

oscarthecat commented Nov 4, 2024

We found that integration-tests/src/test/kotlin/com/google/devtools/ksp/test/KSPCmdLineOptionsIT.kt has an example of running KSP2 from the command line, which is executed via Gradle TestKit in the integration tests. We tried to reproduce it directly in the command line, but it never completes.

ksp version 2.0.21-1.0.26

/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java  -cp "/Users/myname/projects/ksp/integration-tests/../build/repos/test/com/google/devtools/ksp/symbol-processing-common-deps/2.0.255-SNAPSHOT/symbol-processing-common-deps-2.0.255-20241103.122206-9.jar:/Users/myname/projects/ksp/integration-tests/../build/repos/test/com/google/devtools/ksp/symbol-processing-aa-embeddable/2.0.255-SNAPSHOT/symbol-processing-aa-embeddable-2.0.255-20241103.122206-9.jar:/Users/myname/projects/ksp/integration-tests/../build/repos/test/com/google/devtools/ksp/symbol-processing-api/2.0.255-SNAPSHOT/symbol-processing-api-2.0.255-20241103.122206-9.jar:/Users/myname/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.0.21/618b539767b4899b4660a83006e052b63f1db551/kotlin-stdlib-2.0.21.jar" com.google.devtools.ksp.cmdline.KSPJvmMain -module-name=main -project-base-dir /var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514 -source-roots /var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/workload/src/ -output-base-dir=/var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/build/out -caches-dir=/var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/build/out -class-output-dir=/var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/build/out -kotlin-output-dir=/var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/build/out -resource-output-dir /var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/build/out -language-version=2.0 -api-version=2.0 -java-output-dir /var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/build/out -jvm-target 11 /var/folders/w3/fvm0bhqn3tnf576y1kcjc8tr0000gn/T/junit679361217183761514/processors/build/libs/processors-1.0-SNAPSHOT.jar -processor-options error=true

It works successfully when run with Gradle TestKit, but it doesn’t complete when using the command line. Even after adding -processor-options error=true in the arguments, it never finishes. A quick check with jstack suggests a deadlock involving ApplicationImpl pooled thread 1 and ForkJoinPool.commonPool-worker-1 and Periodic tasks thread(at ksp.com.intellij.util.concurrency.AppDelayQueue$TransferThread.run(AppDelayQueue.java:81)). We’re running KSP from the command line, so could you take a look or let me know if there’s something I’m doing wrong? Thanks so much!

@oscarthecat oscarthecat changed the title ksp2 run in cli never ends ksp2 run in cli dead locked Nov 4, 2024
@joffrey-bion
Copy link

I also noticed the CLI never ends when I tried upgrading KSP. I don't have a reproducer at hand but this is indeed a significant issue for us

@oscarthecat oscarthecat changed the title ksp2 run in cli dead locked ksp2 run in command line never ends Nov 4, 2024
@oscarthecat oscarthecat changed the title ksp2 run in command line never ends [KSP2] Running from command line never finishes Nov 4, 2024
@ting-yuan ting-yuan added this to the 1.0.28 milestone Nov 8, 2024
@ting-yuan
Copy link
Collaborator

Thanks for reporting this issue. I can reproduce it. Something seems wrong when returning from KSPJvmMain.main according to the debugger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants