-
Notifications
You must be signed in to change notification settings - Fork 64
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
How to compile with these clang tools? #33
Comments
Thank you for your kind words!
Sorry, but I won't be able to help. I've not worked with Clang for a few years now and I'd need to spend some time trying this myself. Sadly I don't have the spare cycles to try that :( |
Thank you very much for your reply. I am currently studying To meet my needs, a possible solution might be to use tools like I am not sure whether the Finally, I would like to express my gratitude to you once again! |
This makes me realise ... Running a plugin in Clang means running a specific "frontend action". Clang allows only one "action" at a time and it sounds like you are trying to run two actions - sadly that's not supported. Hope this helps :) |
Sorry I don't quite understand what you mean. After our last communication, I made some more attempts, and I believe I have achieved my requirements. I can now compile as follows: $ clang -fplugin=../lib/libCodeStyleChecker.so -o test.o -c ../../test/LACFloat.cpp
../../test/LACFloat.cpp:7:16: warning: Type and variable names should start with upper-case letter
void foo(float some_arg);
^~~~~~~~~
Some_arg
../../test/LACFloat.cpp:7:20: warning: `_` in names is not allowed
void foo(float some_arg);
~~~~^~~~~
somearg
2 warnings generated.
$ nm test.o
0000000000000000 r .LCPI0_0
0000000000000000 T _Z3barv
U _Z3foof It seems that I have successfully compiled this file and successfully used the CodeStyleChecker tool to give me hints during the compilation process. Furthermore, I tried to compile a real project, $ ./configure --prefix=../build --cc="clang -fplugin=/home/waji/Workspace/Testspace/clang-ast/clang-tutor/build/lib/libCodeStyleChecker.so" --cxx="clang -fplugin=/home/waji/Workspace/Testspace/clang-ast/clang-tutor/build/lib/libCodeStyleChecker.so" --disable-asm
$ make
$ ./ffmpeg -version
...
libswscale/output.c:2175:52: warning: Type and variable names should start with upper-case letter
yuv2anyX_fn *yuv2anyX)
^~~~~~~~~
Yuv2anyX
libswscale/output.c:2177:24: warning: Type and variable names should start with upper-case letter
enum AVPixelFormat dstFormat = c->dstFormat;
^~~~~~~~~
DstFormat
libswscale/output.c:2178:31: warning: Type and variable names should start with upper-case letter
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
^~~~
Desc
3414 warnings generated.
AR libswscale/libswscale.a
LD ffmpeg_g
LD ffprobe_g
LD ffserver_g
CP ffserver
STRIP ffserver
CP ffprobe
CP ffmpeg
STRIP ffprobe
STRIP ffmpeg
$ ./ffmpeg -version
ffmpeg version n3.2.1 Copyright (c) 2000-2016 the FFmpeg developers
built with clang version 12.0.1 (https://gitee.com/mirrors/LLVM.git fed41342a82f5a3a9201819a82bf7a48313e296b)
configuration: --prefix=../build --cc='clang -fplugin=/home/waji/Workspace/Testspace/clang-ast/clang-tutor/build/lib/libCodeStyleChecker.so' --cxx='clang -fplugin=/home/waji/Workspace/Testspace/clang-ast/clang-tutor/build/lib/libCodeStyleChecker.so' --disable-asm
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100 It can be seen that I have successfully compiled ffmpeg (although the compilation process has significantly slowed down), and obtained a binary program that can be executed normally. This meets my needs:
My modification is very simple. On the official website of the Clang Plugin, I found the answer. You can automatically add a plugin in the // Automatically run the plugin after the main AST action
PluginASTAction::ActionType getActionType() override {
return AddAfterMainAction;
} PR in #34 |
I found something new: $ clang -cc1 -help | grep "plugin"
-add-plugin <name> Use the named plugin action in addition to the default action
-fpass-plugin=<dsopath> Load pass plugin from a dynamic shared object file (only with new pass manager).
-load <dsopath> Load the named plugin (dynamic shared object)
-plugin-arg-<name> <arg>
Pass <arg> to plugin <name>
-plugin <name> Use the named plugin action instead of the default action (use "help" to list available options) When we passing plugin with So, I can make clang -Xclang -load -Xclang lib/libCodeStyleChecker.so -Xclang -add-plugin -Xclang CSC -o 1.o -c ../test/CodeStyleCheckerFunction.cpp I'm now study how to write test suits with |
Thank you very much for this anazing project. I've successfully run all the examples. But I still have some confusion. How should I use these tools to compile a real project?
For example, I want to use
libCodeStyleChecker.so
into a real compilation process of a large project. Normally, I can do this by modifying the system environment variableCC
, such as:CC="clang -cc1 -load /path/to/libCodeStyleChecker.so -plugin CSC " make
But I can't get any output files. Further more, I made the following attempt:
I got the following result:
As we can see that the
-o
option I entered did not work, and I couldn't compile anycpp
files.Please tell me what should I do to be able to compile a large project while using
clang plugins
?The text was updated successfully, but these errors were encountered: