Compiler-RT on Buildbots

Folks,

I realised there's a "checkout_compiler_rt" option on ClangBuilder,
which does checkout the sources, but couldn't build them on ARM. I
also don't build them during releases (yet) because the configure
script doesn't prepare the Makefiles for compiler-rt.

A while ago I got it running on ARM with CMake files, but since these
are buildbots, I'm not sure it'll be of any help. AFACT, all RT
builders do use CMake, but ClangBuilder only uses it on Windows.

Is it possible to build compiler-rt with autoconf? Do I need some
special configure flags?

If not, how hard would it be to add CMake support to ClangBuilder?
Would that be the best course of action?

cheers,
--renato

Renato Golin <renato.golin@linaro.org> writes:

I realised there's a "checkout_compiler_rt" option on ClangBuilder,
which does checkout the sources, but couldn't build them on ARM. I
also don't build them during releases (yet) because the configure
script doesn't prepare the Makefiles for compiler-rt.

A while ago I got it running on ARM with CMake files, but since these
are buildbots, I'm not sure it'll be of any help. AFACT, all RT
builders do use CMake, but ClangBuilder only uses it on Windows.

Is it possible to build compiler-rt with autoconf? Do I need some
special configure flags?

In the autoconf system, I'm pretty sure compiler-rt's build is triggered
by a Makefile in clang, tools/clang/runtime/compiler-rt/Makefile. This
Makefile comments "We currently only try to generate runtime libraries
on x86", so I guess that's the place to start if you want to get it to
build on ARM.

Ha! Thanks! I was looking on the LLVM side.

I'll give it a try, cheers!

--renato

Hi Renato,

+Alexey

If not, how hard would it be to add CMake support to ClangBuilder?

Is "clang/runtime/CMakeLists.txt" what you're looking for?
Specifically, LLVM_BUILD_EXTERNAL_COMPILER_RT.

tools/clang/runtime/compiler-rt/Makefile

Does anyone maintain the autotools build on compiler-rt anymore?

-Greg

Hi Renato,

I'm slightly out of context. What problem are you working on?

Hi Renato,

+Alexey

> If not, how hard would it be to add CMake support to ClangBuilder?

Is "clang/runtime/CMakeLists.txt" what you're looking for?
Specifically, LLVM_BUILD_EXTERNAL_COMPILER_RT.

> tools/clang/runtime/compiler-rt/Makefile

Does anyone maintain the autotools build on compiler-rt anymore?

Well, we kind of keep autotools-build of compiler-rt in a working state,
but try to touch it
as little as possible. For example, it doesn't (and will not) support
building/running sanitizer
unit- and lit-tests.

Hi Renato,

I assume you're working on setting up the buildbot for compiler-rt on ARM.
If yes, what configuration are you going to build/test there?
Can you re-use SanitizerBuilder from here:
https://llvm.org/svn/llvm-project/zorg/trunk/zorg/buildbot/builders/SanitizerBuilder.py?
This builder is very simple and just checks-out and runs build steps from
http://address-sanitizer.googlecode.com
It was used to setup
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux

Hi Renato,

+Alexey

> If not, how hard would it be to add CMake support to ClangBuilder?

Is "clang/runtime/CMakeLists.txt" what you're looking for?
Specifically, LLVM_BUILD_EXTERNAL_COMPILER_RT.

> tools/clang/runtime/compiler-rt/Makefile

Does anyone maintain the autotools build on compiler-rt anymore?

Well, we kind of keep autotools-build of compiler-rt in a working state,
but try to touch it
as little as possible. For example, it doesn't (and will not) support
building/running sanitizer
unit- and lit-tests.

Hi Renato,

I'm slightly out of context. What problem are you working on?

Hi,

I'm trying to start building compiler-rt on our buildbots (check-all,
self-host and LNT), not start a new sanitizer bots.

Well, we kind of keep autotools-build of compiler-rt in a working state, but
try to touch it as little as possible. For example, it doesn't (and will not) support
building/running sanitizer unit- and lit-tests.

That's ok, for those buildbots, I'm only interested in compiler-rt as
a replacement for libgcc, not the sanitizers.

cheers,
--renato

Hi Justin,

I'm having a go at autoconf-driven RT on ARM.

Without any change, autoconf doesn't even know compiler-rt is there.
Then, I added this:

ifeq ($(ARCH),ARM)
RuntimeLibrary.linux.Configs += builtins-ARM.a # rest to come once
this is working
endif

And I do get the build system to recognise, complain about ld not
supporting x86 on darwin:

warning: clang_darwin.mk: dropping arch 'i386' from lib '10.4' (ld
does not support it)
warning: clang_darwin.mk: dropping arch 'x86_64' from lib '10.4' (ld
does not support it)

and then the following error:

make[5]: Entering directory `/work/llvm/src/projects/compiler-rt'
make[5]: Nothing to be done for `clang_linux'.
make[5]: Leaving directory `/work/llvm/src/projects/compiler-rt'
llvm[4]: Copying runtime library linux/builtins-ARM to build dir
cp: cannot stat
‘/work/llvm/build/tools/clang/runtime/compiler-rt/clang_linux/builtins-ARM/libcompiler_rt.a’:
No such file or directory
make[4]: *** [/work/llvm/build/Release+Asserts/lib/clang/3.5.0/lib/linux/libclang_rt.builtins-ARM.a]
Error 1
rm /work/llvm/build/Release+Asserts/lib/clang/3.5.0/lib/linux/.dir
make[4]: Leaving directory `/work/llvm/build/tools/clang/runtime/compiler-rt'

I'm guessing the "nothing to be done" is the real culprit here, and comes from:

BuildRuntimeLibraries:
        $(Verb) $(MAKE) -C $(COMPILERRT_SRC_ROOT) \
          ProjSrcRoot=$(COMPILERRT_SRC_ROOT) \
          ProjObjRoot=$(PROJ_OBJ_DIR) \
          CC="$(ToolDir)/clang" \
          LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \
          $(COMPILERRT_MAKE_FLAGS) \
          $(RuntimeDirs:%=clang_%)

which executes the compiler-rt Makefile, which is where the
compiler-rt files are built.

This is what comes out:

make -C /work/llvm/src/projects/compiler-rt \
ProjSrcRoot=/work/llvm/src/projects/compiler-rt \
ProjObjRoot=/work/llvm/build/tools/clang/runtime/compiler-rt \
CC="/work/llvm/build/Release+Asserts/bin/clang" \
LLVM_ANDROID_TOOLCHAIN_DIR="" \
  \
clang_linux

When I run "make info-platforms" in compiler-rt, "clang_linux" is one
of them, so I added some ARM stuff to make/platform/clang_linux.mk to
no avail.

I'm also curious as to why the ld error mentioned above is on
clang_darwin.mk not clang_linux.mk, since this is clearly what it
should be running...

Any ideas? I'm not the most knowledgeable on autoconf/cmake stuff, as
you can see. :slight_smile:

Thanks!
--renato