llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.96k stars 11.94k forks source link

Why clang don't output objfile when I use clang PluginASTAction? #73645

Open XQianCode opened 11 months ago

XQianCode commented 11 months ago

compiler cmd

"/home/wasm/Desktop/wasm/cgcl_wasm/llvm-project/build/bin/clang-16" -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/wasm/Desktop/wasm/cgcl_wasm/llvm-project/build -resource-dir /home/wasm/Desktop/wasm/cgcl_wasm/llvm-project/build/lib/clang/16 -c-isystem . -c-isystem /home/wasm/Desktop/pjh/wasi-sdk/src/llvm-project/llvm/include -c-isystem /home/wasm/Desktop/pjh/wasi-sdk/src/llvm-project/llvm/include -c-isystem /home/wasm/Desktop/pjh/wasi-sdk/src/llvm-project/llvm/include -cxx-isystem . -cxx-isystem /home/wasm/Desktop/pjh/wasm-micro-runtime/core/deps/llvm/llvm/include -cxx-isystem /home/wasm/Desktop/pjh/wasm-micro-runtime/core/deps/llvm/llvm/include -cxx-isystem /home/wasm/Desktop/pjh/wasm-micro-runtime/core/deps/llvm/llvm/include -internal-isystem /home/wasm/Desktop/wasm/cgcl_wasm/llvm-project/build/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/home/wasm/Desktop/wasm/cgcl_wasm/llvm-project/build -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -load ./TernaryConverterPlugin.so -plugin ternary-converter -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o test.ll -x c test.c

If I remove the plugin args "-load ./TernaryConverterPlugin.so -plugin ternary-converter". It will output the test.ll file.

question:

Is it that clang will stop CodeGen Action when use PluginASTAction?

XQianCode commented 11 months ago

Yes. I see. When I load plugin, the ProgramAction will be PluginAction and don't run the CodeGen Action. But I want to load my plugin to process AST without impacting the normal CodeGen Action. Is there any suggestions?