Cannot Build clang Plugin - plugins

I would like to build a clang source to source translator plugin for cuda language.Unfortunately i am not able to build the clang plugin itself.I have tried the method suggested by google to copy and paste the PrintFunctionNames and build the same and the other one suggested by http://getoffmylawnentertainment.com/blog/2011/10/01/clang-plugin-development-tutorial/ website did not work for me.
While building with google method I get:
../../../../Makefile.common:61: ../../../../Makefile.config: No such file or directory ../../../../Makefile.common:69: /Makefile.rules: No such file or directory make: * No rule to make target `/Makefile.rules'. Stop.
This did not work for me How to build clang/examples/PrintFunctionNames?
I am getting this error when built using cmake:
teddy#ubuntu:~/dev-lib/example/build$ make
printer/CMakeFiles/PrintFunctionNames.dir/flags.make:6: * commands commence before first target. Stop.
make[1]: * [printer/CMakeFiles/PrintFunctionNames.dir/all] Error 2
make: *** [all] Error 2
I am using ubuntu 10.10 and cmake 2.8.1 to build the clang plugin.
Clang Version:3.1
please help me to build the clang plugin...
Thank you

Building programs that link with Clang can be tricky, especially if you want to do it "out of source" - i.e. in your own source tree, not as part of Clang's.
I'm maintaining a Github repo called llvm-clang-samples that provides samples of linking with LLVM and Clang, and has an example Clang plugin. This repository tries to keep up to date with top-of-tree LLVM & Clang and has branches for earlier released versions.

this error is coming because you have plainly copied the contents of CMakeLists.txt. Particularly the LLVM_LIBS and the CLANG_LIBS part.
What you have to do is simply put backslashed after every line like this
set( CLANG_LIBS \
libclang \
clangFrontend \
.. \
...
)
Or you can bring all the library names to one single line, whichever suits you.
hope this helps

First steps are always hard. Created a toy repo on github, which does pin down the build system issues for a clang plugin. Checkout the 'empty' tag.

Related

Xcode 13.3 Build Failed because of Cycle in Dependencies between targets libsignal-protocol-swift

After updating to Xcode 13.3 facing Build failed issues with libsignal-protocol-swift library.
This is happening while building second time while after cleaning and building for first time it is working fine. Also, Xcode 13.2.1 has no such errors.
Xcode Error as below :
Cycle inside libsignal-protocol-swift iOS; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.
Cycle details:
→ Target 'libsignal-protocol-swift iOS' has link command with output '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/SignalProtocol'
○ Target 'libsignal-protocol-swift iOS' has compile command for Swift source files
○ Target 'libsignal-protocol-swift iOS' has copy command from '/Users/ankitkhanna/Documents/Project-Files/Desk-Factors-Project-Files/BlueChats-IOS-master/libsignal-protocol-swift-master/libsignal-protocol-swift/SignalProtocol.h' to '/Users/ankitkhanna/Library/Developer/Xcode/DerivedData/BlueSecures-brawgzawheasvqbvhxxglfnlvdlw/Build/Products/Debug-iphoneos/SignalProtocol.framework/Headers/SignalProtocol.h'
After struggling for sometime the solution was actually the same as mentioned in Xcode suggestions.
i.e. to Move the Headers in project Target -> Build Phases on top Compiled sources.
Drag and move Headers above Compile Sources fixed the error.
Please see the image for reference.
I've faced the same issue after updating to Xcode 13.3; however, in my case, I didn't have Headers in Build Phases.
I've followed these steps to solve it:
Precondition: Xcode must be closed.
Delete the DerivedData folder:
rm -rf ~/Library/Developer/Xcode/DerivedData
In the Terminal, type the following command:
defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

How to generate C API for onnxruntime on Linux

I am trying to build onnxruntime from source on Linux. According to this instruction I have successfully built python wheels and shared libs. But I have not seen headers for C API.
There is a build option --build_csharp which seems to enable C#/C packages. I tried to add this option but got following errors.
CMake Warning at CMakeLists.txt:137 (message):
Language Csharp is not found in the system
I installed dotnet-sdk-3.1 but still got this error. Can I ask how to properly generate onnxruntime C API on Linux? Thanks!
Please try the following steps:
- Steps to build ONNX from source code:
1. git clone --recursive https://github.com/Microsoft/onnxruntime
2. Get the commit ID of the version you want to build (In case you want older version)
3. git checkout "your commitID"
4. Install the required version of Cmake on your system
6. Run: <path>\build.sh --config Release --build_shared_lib --parallel
7. A build folder will be created in the onnxruntime.
5. Get the onnxruntime.dll from the dir: \onnxruntime\build\Windows\Release\Release
6. Get the required headers (onnxruntime_c_api.h, onnxruntime_cxx_api.h, onnxruntime_cxx_inline.h)
from the dir: \onnxruntime\include\onnxruntime\core\session and put it in the unit location.

Building Swift on CentOS

I am building Swift compiler from source on CentOS 6, and am running into a library issue. After fighting with the build script for a while I have got where running ./utils/build-script eventually gives:
+ /home/src/cmake-3.4.1-Linux-x86_64/bin/cmake --build /home/src/swift/build/Ninja-DebugAssert/cmark-linux-x86_64 -- all
ninja: no work to do.
llvm: using standard linker
+ cd /home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64
+ /home/src/cmake-3.4.1-Linux-x86_64/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=clang -DCMAKE_CXX_COMPILER:PATH=clang++ '-DCMAKE_C_FLAGS= ' '-DCMAKE_CXX_FLAGS= ' -DCMAKE_BUILD_TYPE:STRING=Debug -DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE -DLLVM_TOOL_SWIFT_BUILD:BOOL=NO '-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64' -DLLVM_INCLUDE_TESTS:BOOL=TRUE -LLVM_INCLUDE_DOCS:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINTERNAL_INSTALL_PREFIX=local /home/src/swift/llvm
CMake Error at cmake/modules/CheckAtomic.cmake:36 (message):
Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
cmake/config-ix.cmake:296 (include)
CMakeLists.txt:403 (include)
-- Configuring incomplete, errors occurred!
See also "/home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/CMakeFiles/CMakeOutput.log".
See also "/home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/CMakeFiles/CMakeError.log".
./utils/build-script: command terminated with a non-zero exit status 1, aborting
(gcc-4.8.2 was what I compiled llvm with)
libatomic is there:
$ locate libatomic
/opt/gcc-4.8.2/lib64/libatomic.a
/opt/gcc-4.8.2/lib64/libatomic.la
/opt/gcc-4.8.2/lib64/libatomic.so
/opt/gcc-4.8.2/lib64/libatomic.so.1
/opt/gcc-4.8.2/lib64/libatomic.so.1.0.0
I just don't know how to tell the build system where to look. I have tried the usual CMAKE_LIBRARY_PATH (exporting on the command line - I am not sure if cmake works like the way LD_LIBRARY_PATH, LIBRARY_PATH work) but it can't seem to find it.
I also don't have root on the machine.
I had not tried building from source on CentOS 6 until I saw this question, but I have been able to build Swift 2.2 on CentOS 7.1 and Ubuntu 14.04, with partial success. A few things to think about:
You will need numerous dependencies required to build Swift, and unless
they happen to be already on the system, you will need root access to
install them.
Use -R flag with the build-script to create a release build.
Building in DebugAssert (the default) will require a lot of memory. In my case even 14 GB was not sufficient. A release build
can be done with about 6 GB.
As for your specific problem, it is related to Clang's dependency on GCC-related packages for headers and libraries. See, for example, Fedora 21 with clang, without gcc.
Even if you installed GCC 4.8.2 and adjusted the path to use gcc and g++ from 4.8.2, Clang may still be looking in the old GCC directories for headers and libraries. CMake first tries to compile a C++ test file that includes the header atomic, which does not exist in the old GCC. So, it then tries to link a C test program that uses the library libatomic, which again doesn't exist in the old GCC. You can see this by looking at llvm/cmake/modules/CheckAtomic.cmake mentioned by usr1234567. CMakeError.log and CMakeOutput.log can also provide valuable insight. BTW, when I was building Swift on CentOS 7.1, I didn't run into this problem because GCC 4.8.2 was used by Clang for headers and libraries and the atomic header was found, so the C++ file got compiled. However, had the libatomic check been done, it would have failed, because libatomic.so in the repository-provided 4.8.2 has INPUT ( <name of some non-existent file> ), so trying to link with libatomic errors out.
I'm sure there are various ways of dealing with this issue, but what solved the problem for me was setting the following environment variables, please adjust to your specific setup:
export CPLUS_INCLUDE_PATH=/opt/gcc-4.8.2/include/c++/4.8.2:/opt/gcc-4.8.2/include/c++/4.8.2/x86_64-unknown-linux-gnu
export LIBRARY_PATH=/opt/gcc-4.8.2/lib64:/opt/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Also make sure that your 4.8.2 version of libstdc++.so is available to the dynamic linker at runtime. Since you don't have root, do
export LD_LIBRARY_PATH=/opt/gcc-4.8.2/lib64
If you had root, you could use ldconfig.
Before you start building Swift, you may want to try building, using Clang, a simple C program linking it with libatomic (the code doesn't actually have to use any symbols from the lib) and a simple C++ program that includes the <atomic> header. When compiling the C++ program, use the -std=c++11 compiler flag. If the C++ program compiles successfully, then it is not necessary for the libatomic linking test to be successful.
Interestingly, the CMakeOutput.log file still did not report finding GCC 4.8.2 as a candidate GCC installation, but the configuration/build worked well past the error.
Hopefully this helps. Please let us know if you run into something else.
CheckAtomic.cmake seems to be part of LLVM. I found a file at Github and it tries to find '__atomic_fetch_add_4' from libatomic
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
This fails for you. Check CMakeFiles/CMakeError.log to get more details why this test failed. Or try this line in a new project.

Eclipse juno + cuda plugin error

I am using Eclipse Juno parallel version. I have installed
cuda plugin. But while building a sample cuda helloworld
program I am getting error -
make all
make: *** No rule to make target `exe_cuda', needed by `all'. Stop.
******Makefile snapshot**************
all: exe_cuda
# Tool invocations
#echo 'No tool found that can build the extension specified with the build
artifact name $#'
# Other Targets
clean:
-$(RM) $(OBJS)$(C_DEPS) exe_cuda
-#echo ' '
Any suggestion......
I agree that the toolchain does not appear to be set up properly for C projects.
My suggestions are:
Create a C++ project instead. That seems to work.
Use Nsight Eclipse Edition instead. It is installed automatically with the linux CUDA 5 package (just type nsight from a terminal window).
You could report the problem to fixstars corporation, the developer of that cuda plugin. It seems they have not updated it since 2011, so I don't know if it's actively maintained. But the help page is here which includes a link for a mailing list you could use.

GCC 4.7 on OS X Lion: cannot compute suffix of object files

I know this issue already discussed (include there), and no one time. But, unfortunately, I cannot solve this problem.
So, I have OS X Lion, i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1, and I try to build gcc-4.7.0.
First of all, I've already built this compiler on Debian GNU/Linux, so I was sure any problems will not be...
So, I read this GCC manual and I did all exactly as described:
cd gcc-4.7.0
./contrib/download_prerequisites
cd ..
mkdir gcc_build
cd gcc_build
/Users/dshevchenko/Downloads/gcc-4.7.0/configure --prefix=/Users/dshevchenko/Tools/GCC
make
So, MPC, MPFR and GMP was successfully downloaded, and ./configure was OK. But after few minutes after make I get this error:
checking for suffix of object files... configure: error:
in `/Users/dshevchenko/Downloads/gcc_build/x86_64-apple-darwin11.4.0/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
As I understand this can't be due error of dynamic linking with MPFR, MPC or GMP, because these libs was built inside of GCC source code tree.
In my ~/.bash_profile:
export DYLD_LIBRARY_PATH=/Users/dshevchenko/Tools/GCC/lib
Help me please, I'll be grateful for any advice.
Be sure you have the latest Xcode (4.4 at the time of this writing). There is a bug in the llvm compiler in some versions of Xcode (including 4.1, which I had). For Xcode 4.4, the command line tools must be downloaded from the Xcode preferences.
the follow solution helped me out:
$ export CC="gcc -D_FORTIFY_SOURCE=0”
$ $srcdir/configure ...
$ make
source: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50342