Hi All,
I need to build clang/llvm from source on an Ubuntu Linux system, in order to build the gnustep Objective-C environment. I was able to build clang using cmake without a problem (following the instructions at clang.llvm.org/get_started.html), but when I tried to build gnustep, I found that clang failed to compile an autoconf-generated program. The compile error in the configure log was:
configure:14781: checking for _Block_copy
configure:14837: clang -o conftest -m64 -march=opteron -mno-3dnow -ggdb -O2 -Wall -I/home/dlobron/build/clangport/akamai/common/GNUstep/Local/Library/Headers -I/home/dlobron/build/clangport/akamai/common/GNUstep/Local/Library/Headers -I/home/dlobron/build/clangport/akamai/common/GNUstep/System/Library/Headers -fgnu-runtime -x objective-c -m64 -L/home/dlobron/build/clangport/akamai/common/GNUstep/Local/Library/Libraries -L/home/dlobron/build/clangport/akamai/common/GNUstep/Local/Library/Libraries -L/home/dlobron/build/clangport/akamai/common/GNUstep/System/Library/Libraries conftest.c -lrt -ldl -lpthread -rdynamic -m64 -fgnu-runtime -L/home/dlobron/GNUstep/Library/Libraries -L/home/dlobron/build/clangport/akamai/common/GNUstep/Local/Library/Libraries -L/home/dlobron/build/clangport/akamai/common/GNUstep/System/Library/Libraries -lobjc -lm >&5
/tmp/conftest-a47ae0.o: In function `main':
/home/dlobron/build/clangport/akamai/gnustep-base/gnustep-base-1.24.8/conftest.c:140: undefined reference to `_Block_copy'
The line in the auto-generated conftest.c that caused the failure is:
return _Block_copy ();
I repeated the above command from the command line, and verified that I get the same error.
I did some searching of docs and comments, and I it sounds like I need the realtime project to be built. I did download the llvm/projects/compiler-rt source, but the Makefile in llvm/projects filters it out:
# Don't build compiler-rt, it isn't designed to be built directly.
DIRS := $(filter-out compiler-rt,$(DIRS))
The main source dir of llvm has an LLVM_BUILD_EXTERNAL_COMPILER_RT option, but I wasn't sure if I that would put RT support into clang (which I'd like) or rather, irf it would build a separate RT compiler.
Can you guys advise me how to build clang on Linux so that _Block_copy will be useable?
Thank you,
David
As far as I know the makefile in there isn't the makefile that gets executed during the cmake build -- cmake generates its own build files from CMakeLists.txt and runs those instead. Having the compiler-rt source in projects/compiler-rt should be enough to have its functionality built into clang when building with cmake.
-Alex
Building the BlocksRuntime isn’t supported via CMake at the moment. It should be pretty straightforward to make it work, but it currently isn’t supported.
-Chris
I dug a little deeper into the history here. It looks like the blocks runtime hasn’t built in the CMake build system in a long time, and I don’t think it has ever been supported in the autoconf system.
Support for building it with CMake was removed in April 2012 along with the old CMake build system (r154059) because it was broken. The old CMake support could probably be used as a base for bringing it back, but I would caution that you’re wading into seriously uncharted territory.
-Chris
Hi Chris and Alex,
Many thanks for these replies.
I dug a little deeper into the history here. It looks like the blocks runtime hasn’t built in the CMake build system in a long time, and I don’t think it has ever been supported in the autoconf system.
Support for building it with CMake was removed in April 2012 along with the old CMake build system (r154059) because it was broken. The old CMake support could probably be used as a base for bringing it back, but I would caution that you’re wading into seriously uncharted territory.
Is there an alternative build method I could use in order to create the blocks runtime on Linux? The docs seemed to recommend cmake ('cmake -G "Unix Makefiles" ../llvm'), but I'd be more than glad to try another way. I think blocks are required for GNUstep, since it's an Objective-C runtime.
Thanks,
David
Unfortunately you’ll need to either modify the LLVM build system to build it, or you’ll need to build it yourself by hand. We don’t currently support building the blocks runtime.
I’m guessing the Docs are about 3 years out of date.
You can feel free to file a bug at https://llvm.org/bugs/, but I don’t know when it will be addressed, ant it is unlikely we will back port it to 3.7.
-Chris
Unfortunately you’ll need to either modify the LLVM build system to build it, or you’ll need to build it yourself by hand. We don’t currently support building the blocks runtime.
Thanks! I'm working on a modified build now.
Out of curiosity: is cmake still the preferred way to build on Linux? You mentioned that the doc is out-of-date, so I thought perhaps there might be a newer way to do it.
Thank you again,
David
We are actively working toward depreciating the autoconf build system in favor of CMake on all platforms, so it is the preferred way to build LLVM.
I imagine if you look at the CMake scripts relating to the blocks runtime from before r154059, that will probably give you a good start on getting the runtime working now. If you end up with patches that make this work for you please share them as there are probably other people that will benefit from this too.
Thanks,
-Chris
We are actively working toward depreciating the autoconf build system in favor of CMake on all platforms, so it is the preferred way to build LLVM.
I imagine if you look at the CMake scripts relating to the blocks runtime from before r154059, that will probably give you a good start on getting the runtime working now. If you end up with patches that make this work for you please share them as there are probably other people that will benefit from this too.
Thanks! It turns out that GNUstep's version of libobjc2 has the blocks code in it, so I should be able to pick it up from there. I think I'm thus all set, but I will let you guys know if I end up creating a working patch for clang that adds blocks on Linux via cmake.
Thank you again for the friendly support,
David