Hi all,
I am looking for a LLVM/Clang compiler suite that works under Win32.
These I tried, but they all fail with crashes, missing libraries or alike:
1.) http://llvm.org/releases/download.html (http://llvm.org/releases/download.html)
-> http://llvm.org/releases/3.2/clang+llvm-3.2-x86-mingw32-EXPERIMENTAL.tar.gz (http://llvm.org/releases/3.2/clang+llvm-3.2-x86-mingw32-EXPERIMENTAL.tar.gz)
2.) http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/ (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/)
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.2-release/i686-w64-mingw32-clang-3.2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.2-release/i686-w64-mingw32-clang-3.2-release-win32_rubenvb.7z/download)
...with:
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.6-release/i686-w64-mingw32-gcc-dw2-4.6.3-2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.6-release/i686-w64-mingw32-gcc-dw2-4.6.3-2-release-win32_rubenvb.7z/download)
...or:
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.7-release/i686-w64-mingw32-gcc-dw2-4.7.2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.7-release/i686-w64-mingw32-gcc-dw2-4.7.2-release-win32_rubenvb.7z/download)
...or:
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.7-release/i686-w64-mingw32-gcc-4.7.2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.7-release/i686-w64-mingw32-gcc-4.7.2-release-win32_rubenvb.7z/download)
What combination does work for you reliable on Windows? I would like to test the ability of C::B to drive this compiler, btw...
You can build it yourself. configure or cmake based builds works out of the box..
I do have two modifications to the source code, one pertaining to clang unable to find
mingw header files (4.7.2, 4.7.3 etc) and one about calling convention if you happen upon
some problems..
Interestingly I'd come to report nullptr causing problems with clang because definition in
prep.h does not consider clang.
#if !(__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined __GXX_EXPERIMENTAL_CXX0X__)
// it is a const object...
const class nullptr_t
{
public:
// constructor
nullptr_t() {}
// convertible to any type of null non-member pointer...
template<typename T> operator T* () const{ return (T*)0; }
// or any type of null member pointer...
template<typename C, typename T> operator T C::* () const { return (T C::*)0; }
// support operator overloading (== and !=)
template<typename T> bool equals(T const& rhs) const { return rhs == 0; }
private:
// can't take address of nullptr
void operator&() const;
// can't copyable
nullptr_t(const nullptr_t&);
const nullptr_t& operator=(const nullptr_t&);
} nullptr_;
#define nullptr nullptr_
#endif
it needs also something like
#if !(__has_feature(cxx_nullptr))
Clang does not use something like GXX_EXPERIMENTAL_CXX0X or version numbers but instead opts for
__has_feature macro to query if certain language features are enabled.
http://clang.llvm.org/docs/LanguageExtensions.html#checking_upcoming_features
Quote from: MortenMacFly on January 22, 2013, 07:30:14 AM
Hi all,
I am looking for a LLVM/Clang compiler suite that works under Win32.
These I tried, but they all fail with crashes, missing libraries or alike:
1.) http://llvm.org/releases/download.html (http://llvm.org/releases/download.html)
-> http://llvm.org/releases/3.2/clang+llvm-3.2-x86-mingw32-EXPERIMENTAL.tar.gz (http://llvm.org/releases/3.2/clang+llvm-3.2-x86-mingw32-EXPERIMENTAL.tar.gz)
2.) http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/ (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/)
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.2-release/i686-w64-mingw32-clang-3.2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.2-release/i686-w64-mingw32-clang-3.2-release-win32_rubenvb.7z/download)
...with:
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.6-release/i686-w64-mingw32-gcc-dw2-4.6.3-2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.6-release/i686-w64-mingw32-gcc-dw2-4.6.3-2-release-win32_rubenvb.7z/download)
...or:
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.7-release/i686-w64-mingw32-gcc-dw2-4.7.2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.7-release/i686-w64-mingw32-gcc-dw2-4.7.2-release-win32_rubenvb.7z/download)
...or:
-> http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.7-release/i686-w64-mingw32-gcc-4.7.2-release-win32_rubenvb.7z (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.7-release/i686-w64-mingw32-gcc-4.7.2-release-win32_rubenvb.7z/download)
What combination does work for you reliable on Windows? I would like to test the ability of C::B to drive this compiler, btw...
i686-w64-mingw32-clang-3.1-release-win32_rubenvb.7z (http://ftp.jaist.ac.jp/pub/sourceforge/m/project/mi/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.1-release/) with i686-w64-mingw32-gcc-dw2-4.6.3-2-release-win32_rubenvb.7z (http://ftp.jaist.ac.jp/pub/sourceforge/m/project/mi/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.6-release/)
Create a dir LLVM and copy in that dir.
QuoteI am looking for a LLVM/Clang compiler suite that works under Win32.
These I tried, but they all fail with crashes, missing libraries or alike:
I have it self compiled on my machine with TDM-GCC-4.7.1. i.e. in order for it to work you also need to install TDM-GCC-4.7.1
HOWEVER, (and this is a big _HOWEVER_): gdb (Windows only) can not debug binaries created with clang under Windows
I opened a bug for this here:
http://llvm.org/bugs/show_bug.cgi?id=13636 (http://llvm.org/bugs/show_bug.cgi?id=13636)
There is patch for this bug which I am not sure it was applied...( I will test with latest trunk tonight):
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-November/056009.html (http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-November/056009.html)
Drop me a message if you want me to upload my compiled version
Eran
Quote from: eranif on May 01, 2013, 12:57:59 PM
There is patch for this bug which I am not sure it was applied...( I will test with latest trunk tonight):
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-November/056009.html (http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-November/056009.html)
Is the patch effective for debugging after your test?
Hi xunxun,
I did not apply the patch locally...so I can't really answer your question
I settled for opening a ticket to the clang devs
Eran
Quote from: eranif on May 01, 2013, 12:57:59 PM
Drop me a message if you want me to upload my compiled version
Drop. :-)
Maybe there is already a 3.2 version? I also read the current dev-version supports c++11 completely - that would be interesting, too.
The thing with gdb is bad, indeed. :-/
Updating clang/llvm to their latest trunk and building
I will also check if gdb is working with latest trunk.. (thought I doubt it will work...)
Eran
Hi,
I built clang latest trunk + I did some minor change to allow debugging - with the my build you can compile and debug a C program.
For C++: Its not usable.
- Exceptions are not supported (you need to compile your code with -fno-exceptions)
- You need to explicitly set -lstd++ in the linker
- After you successfully link, your program will crash ;) ( in debug and release mode with no optimizations ) with non helpful backtrace. Note that the crash happens with or without my change
To summarize:
- Is usable for C
- Don't bother with it for C++ / Windows
Linux is another story:
- Works like a charm (I even got a separate codelite build which compiles with clang)
- Its x2 faster than g++ on linux (for comparison, compiling codelite ~1200 sources with PCH enabled takes about 3 mins on my 8 core machine with g++ and ~1.3 min with clang++)
- A drop in replacement for g++/gcc (just set CXX=clang++ / CC=clang and you are done)
Eran
how do you build it on linux ? I know it is in the repos, but I think their new libstd++ is missing for linux, and that one should be build , right ?
And does the C++11 stuff work ?
Building on Linux is quite straight forward:
http://codelite.org/Developers/HomePage#toc2 (http://codelite.org/Developers/HomePage#toc2)
Once you have completed the above steps - just run
sudo make install
To build their libc++ (this is what I am using to build it on my linux box):
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
cd libcxx
mkdir build-release
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make -j8
sudo make install
You can get more details here:
http://libcxx.llvm.org/ (http://libcxx.llvm.org/)
Eran
Quote from: eranif on May 03, 2013, 06:01:14 AM
For C++: Its not usable.
So: Am I getting it right that I am still lost on Windows? :-(
Yes you are ;)
Maybe building clang with Visual Studio will help - but you mentioned that you wanted a MinGW version...
Eran
Quote from: eranif on May 03, 2013, 10:16:04 AMMaybe building clang with Visual Studio will help - but you mentioned that you wanted a MinGW version...
Yes, that's explicitely what I am looking for. The VS version I use works flawlessly. I am using the one from here:
http://www.ishani.org/web/articles/code/clang-win32/
BTW:
Quote from: vali29 on May 01, 2013, 10:47:22 AM
i686-w64-mingw32-clang-3.1-release-win32_rubenvb.7z (http://ftp.jaist.ac.jp/pub/sourceforge/m/project/mi/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/clang-3.1-release/) with i686-w64-mingw32-gcc-dw2-4.6.3-2-release-win32_rubenvb.7z (http://ftp.jaist.ac.jp/pub/sourceforge/m/project/mi/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-dw2-4.6-release/)
Create a dir LLVM and copy in that dir.
...does not work, too. I can compile a simple main doing nothing, but as soon as you start to use C++ it fails miserably as all others.
Nevermind... seems there is no prime time yet... But thanks anyways...
Quote from: MortenMacFly on May 03, 2013, 10:29:55 AM
...does not work, too. I can compile a simple main doing nothing, but as soon as you start to use C++ it fails miserably as all others.
Some time ago, I built it with MinGW and got C++ to work. There are some hard-coded search paths for STL headers that I had to modify first (sorry, I cannot recall which file they were in).
on your instructions for building libcxx :
mkdir build-release
cd build-release <======================
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
build and installed clang and libc++ with your instructions, then let CB autodetect it, it finds it in /usr/local/clang.
But when trying a "hello world" , it fails to compile since it doesn't ind the headers (iostream).
What should be the correct location ?
Timestamps wise I think this was a result of the build too : /usr/local/include/c++/v1/ ? => when using this , compiles but now linker problems (eg . : main.cpp:4: undefined reference to `std::__1::cout')
Also my linux shell doesn't seem to know about clang (yet), though I did ldconfig, and /usr/local/bin is already in my path (this is also where codeblocks executable is).
EDIT : on the linking problem : added to Cb for clang compiler settings :
linker path : /usr/local/lib
link lib : c++
==> links but at run time : error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory
I forgot to mention that you will need libc++abi as well.., building it on linux does not work "out-of-the-box" but requires a small tweak:
First, checkout libcxxabi:
svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi
Next:
cd libcxxabi/lib
Now you need to add some include paths... otherwise it will not compile:
run:
g++ -v -x c++ /dev/null -fsyntax-only
Locate the output line which is similar to this:
/usr/lib/gcc/x86_64-linux-gnu/4.7/include
Adjust CXX environment variable so it will be something similar to this:
export CXX='clang++ -I/usr/local/include/c++/v1 -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include'
and compile libcxxabi by simply typing:
./buildit
once the compilation is done, you should have a new lib: libc++abi.so.1.0
I could not find a simple way of installing so I copied it manually to /usr/local/lib and created 2 symlinks:
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so.1
Now compiling with clang++/libc++ should be like this:
clang++ -stdlib=libc++ -c test.cpp -I/usr/local/include/c++/v1
clang++ -stdlib=libc++ test.o -o TestMe -lc++ -lc++abi -I/usr/local/include/c++/v1/
Eran
Thanks Eran, but not yet ok for me :
error while loading shared libraries: libc++abi.so.1: cannot open shared object file: No such file or directory
Did you remember to add /usr/local/lib to LD_LIBRARY_PATH?
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
In addition, note that you should create 2 symlinks
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so
ln -sf /usr/local/lib/libc++abi.so.1.0 /usr/local/lib/libc++abi.so.1
Eran
I did not do the export (export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH) , but it is in my normal path, is that not sufficient ?
And in the compiler settings of clang in CB, I even added that path as the dirs where the linker can go find libs.
I did create the 2 symlinks.
Quotebut it is in my normal path, is that not sufficient
Do you mean its in your PATH environment variable? LD_LIBRARY_PATH is for locating libraries during runtime
PATH is used to locate binaries (unlike Windows...)
QuoteI even added that path as the dirs where the linker can go find libs
And from what I understood the linker did _find_ it. Its just that the runtime linker did not find them (it needs LD_LIBRARY_PATH)
Eran
yes, it is not in my PATH ;-) /usr/local/bin is
In a console I did :
killerbot@XIII:~/Projects/TryOUt/ClangC11/Deliv/Debug> ./ClangC11
./ClangC11: error while loading shared libraries: libc++abi.so.1: cannot open shared object file: No such file or directory
killerbot@XIII:~/Projects/TryOUt/ClangC11/Deliv/Debug> export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
killerbot@XIII:~/Projects/TryOUt/ClangC11/Deliv/Debug> ./ClangC11
Segmentation fault
for a simple
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}
In /usr/local/lin I also have the boost libs from my distro. I think these can be found by programs that need it ?
In /usr/local/lib64, the codeblocks so's end up. And when CB is launched (which is located in /usr/local/bin) that one is however able to find it's so files, while that path is also not in $LD_LIBRARY_PATH
for me it is :
echo $LD_LIBRARY_PATH
/usr/lib64/mpi/gcc/openmpi/lib64
So it seems there might be a few things going wrong, explicit path specification is bneeded, while other libs in there or in lib64 can be found, and in the end crash
BTW, which distro do you use?
I am using Ubuntu 12.10/64
and it is running without a problem...
Can you post the compiler output and the linker ?
Eran
Quote from: killerbot on May 04, 2013, 07:59:19 PM
build and installed clang and libc++ with your instructions, then let CB autodetect it, it finds it in /usr/local/clang.
...
Also my linux shell doesn't seem to know about clang (yet), though I did ldconfig, and /usr/local/bin is already in my path (this is also where codeblocks executable is).
It's probably not installed in /usr/local. Try:
find /usr/local -name clang++
Quote from: killerbot on May 04, 2013, 07:59:19 PM
EDIT : on the linking problem : added to Cb for clang compiler settings :
linker path : /usr/local/lib
link lib : c++
clang++ searches it's
install-path/lib to find default libs.
Quote from: killerbot on May 04, 2013, 07:59:19 PM
==> links but at run time : error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory
A single call to ldconfig [/usr/local/lib] shoud do it. Check if '/usr/local/lib' is in the default lib-path:
grep 'usr/local' /etc/ld.so.conf
- osdt
I can compile C::B with clang (except for thre contrib-plugins, LibFinder, Profiler and NassiShneiderman) without any tweaking or self-compiling of clang on Fedora 18.
And it seems to run (at least it starts without issues.
C::B from inside C::B.
Compiler is detected as gcc 4.1.2 on starthere-page.
If you do not have a particular reason to self-compile Clang, installing it through
apt-get works fine.
Quote from: jens on May 05, 2013, 04:23:49 PM
I can compile C::B with clang (except for thre contrib-plugins, LibFinder, Profiler and NassiShneiderman) without any tweaking or self-compiling of clang on Fedora 18.
And it seems to run (at least it starts without issues.
C::B from inside C::B.
Also works in Ubuntu 12.04 and 13.04.
QuoteIf you do not have a particular reason to self-compile Clang, installing it through apt-get works fine
I think that the problem here is not compiling clang (from what I understand killerbot we are beyond it)
We are trying to make clang to use a different std++ library named "libc++" which on linux also requires libc++abi
both needs to be self compiled (libc++abi build instructions are only available for OSX and not for Linux not to mention Windows...)
Eran
all paths are in :
find /usr/local -name clang++
/usr/local/bin/clang++
grep 'usr/local' /etc/ld.so.conf
/usr/local/lib64
/usr/local/lib
so why does it not find the .so's
Quote from: killerbot on May 06, 2013, 08:00:32 PM
grep 'usr/local' /etc/ld.so.conf
/usr/local/lib64
/usr/local/lib
so why does it not find the .so's
Hmm ... did you run ldconfig after installation of libc++
successfully? Try ...
# run ldconfig
sudo /sbin/ldconfig
# check if libc++ has been found
sudo /sbin/ldconfig -p | grep 'libc++'
- osdt
one step further, I indeed forgot to rerun ldconfig, after I had build the libc++abi !
So now it links, and runs from within CB, and shell without LD_LIBRARY_PATH execution.
Well the "runs" ==> crashes
According to the debugger : in libcxxabi/src/cxa_exception.cpp
LIBCXXABI_NORETURN
void
__cxa_throw(void* thrown_object, std::type_info* tinfo, void (*dest)(void*))
{ /// <====================================== on this line stack ponter
during the call of : std::cout << "Hello world!" << std::endl;
just having a main that does return 0 ==> that doesn't crash