Skip to content

Commit

Permalink
Intial commit
Browse files Browse the repository at this point in the history
Add clang recipes

Signed-off-by: Khem Raj <raj.khem@gmail.com>
  • Loading branch information
kraj committed Sep 12, 2014
0 parents commit 7d75cff
Show file tree
Hide file tree
Showing 8 changed files with 428 additions and 0 deletions.
17 changes: 17 additions & 0 deletions COPYING.MIT
@@ -0,0 +1,17 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
71 changes: 71 additions & 0 deletions README.md
@@ -0,0 +1,71 @@
# meta-clang (a C language family frontend and LLVM compiler backend)

This layer provides [clang/llvm](http://clang.llvm.org/) as alternative to your system
C/C++ compiler for OpenEmbedded based distributions along with gcc

# Getting Started

```shell
git clone git://github.com/openembedded/openembedded-core.git
cd openembeeded-core
git clone git://github.com/openembedded/bitbake.git
git clone git://github.com/kraj/meta-clang.git

$ . ./oe-init-build-env
```

Edit conf/bblayers.conf to add meta-musl to layer mix e.g.

```python
BBLAYERS ?= " \
/home/kraj/openembedded-core/meta-clang \
/home/kraj/openembedded-core/meta \
"
```

# Building

Below we build for qemuarm machine as an example

```shell
$ MACHINE=qemuarm bitbake core-image-minimal
```
# Running

```shell
$ runqemu qemuarm
```

# Limitations

Currently core-image-minimal is buildable/bootable for ARM, x86, x86_64
based qemu machines
MACHINE variable and TCLIBC variables can also be set in conf/local.conf to avoid typing it on commandline on any bitbake invocation


# Dependencies

```
URI: git://github.com/openembedded/openembedded-core.git
branch: master
revision: HEAD
URI: git://github.com/openembedded/bitbake.git
branch: master
revision: HEAD
```

Send pull requests to openembedded-devel@lists.openembedded.org with '[meta-clang]' in the subject'

When sending single patches, please use something like:

'git send-email -M -1 --to openembedded-devel@lists.openembedded.org --subject-prefix=meta-clang][PATCH'

You are encouraged to fork the mirror on [github](https://github.com/kraj/meta-clang/)
to share your patches, this is preferred for patch sets consisting of more than
one patch. Other services like gitorious, repo.or.cz or self hosted setups are
of course accepted as well, 'git fetch <remote>' works the same on all of them.
We recommend github because it is free, easy to use, has been proven to be reliable
and has a really good web GUI.

Layer Maintainer: Khem Raj <raj.khem@gmail.com>
9 changes: 9 additions & 0 deletions conf/layer.conf
@@ -0,0 +1,9 @@
# We have a conf and classes directory, append to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have a recipes directory, add to BBFILES
BBFILES += "${LAYERDIR}/recipes*/*/*.bb ${LAYERDIR}/recipes*/*/*.bbappend"

BBFILE_COLLECTIONS += "clang-layer"
BBFILE_PATTERN_clang-layer := "^${LAYERDIR}/"
BBFILE_PRIORITY_clang-layer = "7"
58 changes: 58 additions & 0 deletions recipes-devtools/clang/clang.inc
@@ -0,0 +1,58 @@
# LLVM does not provide ABI stability between different versions. For this
# reason OE makes it possible to build and install different llvm versions
# at the same time.
#
# This is true for the normal recipes as well as the native ones.
#
# All regular installation directories are prefixed with 'llvm${LLVM_RELEASE}'
# e.g. "${STAGING_BINDIR}/llvm2.5" or "${STAGING_INCDIR}/llvm2.5"
#
# For your program or library that makes use of llvm you do should not need to
# modify anything as long as it uses the results of various llvm-config
# invocations. If you need customizations something is wrong and it needs to be
# fixed (report bug).
#
# However the *recipe* for your program/library *must* declare
# export WANT_LLVM_RELEASE = "<valid version number>"
# The version number is picked up by a generic wrapper script which just calls
# the variant of the specified version.

DEPENDS = "libffi libxml2-native llvm-native zlib"

inherit perlnative pythonnative cmake


EXTRA_OECMAKE="-DLLVM_ENABLE_RTTI=True \
-DLLVM_ENABLE_FFI=False \
-DCMAKE_SYSTEM_NAME=Linux \
"

EXTRA_OECMAKE_append_class-native = "\
-DLLVM_TARGETS_TO_BUILD=host \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${prefix} \
"
EXTRA_OECMAKE_append_class-target = "\
-DCMAKE_CROSSCOMPILING=True \
"
EXTRA_OEMAKE += "REQUIRES_RTTI=1 VERBOSE=1"

do_configure() {
# Remove RPATHs
sed -i 's:$(RPATH) -Wl,$(\(ToolDir\|LibDir\|ExmplDir\))::g' ${S}/Makefile.rules
# Drop "svn" suffix from version string
sed -i 's/${PV}svn/${PV}/g' ${S}/configure

# Fix paths in llvm-config
sed -i "s|sys::path::parent_path(CurrentPath))\.str()|sys::path::parent_path(sys::path::parent_path(CurrentPath))).str()|g" ${S}/tools/llvm-config/llvm-config.cpp
sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g" ${S}/tools/llvm-config/llvm-config.cpp
cmake ${S}
}

do_compile_class-native () {
oe_runmake
}

do_install_class-native () {
oe_runmake install DESTDIR=${D}
}
208 changes: 208 additions & 0 deletions recipes-devtools/clang/clang/disable-xml2-config.patch
@@ -0,0 +1,208 @@
Index: git/autoconf/configure.ac
===================================================================
--- git.orig/autoconf/configure.ac 2014-08-26 12:58:29.187543502 -0700
+++ git/autoconf/configure.ac 2014-08-26 13:18:55.484200981 -0700
@@ -1560,16 +1560,13 @@
dnl Check for libxml2
dnl Right now we're just checking for the existence, we could also check for a
dnl particular version via --version on xml2-config
-AC_CHECK_PROGS(XML2CONFIG, xml2-config)
-
-AC_MSG_CHECKING(for libxml2 includes)
-if test "x$XML2CONFIG" = "x"; then
- AC_MSG_RESULT(xml2-config not found)
-else
- LIBXML2_INC=`$XML2CONFIG --cflags`
- AC_MSG_RESULT($LIBXML2_INC)
- AC_CHECK_LIB(xml2, xmlReadFile,[AC_DEFINE([CLANG_HAVE_LIBXML],1,[Define if we have libxml2])
- LIBXML2_LIBS="-lxml2"])
+PKG_CHECK_MODULES(LIBXML2, [libxml-2.0],,
+ [AC_MSG_ERROR([Could not find libxml-2.0])]
+)
+if test "x$LIBXML2_CFLAGS" != "x"; then
+ LIBXML2_INC=${LIBXML2_CFLAGS}
+ LIBXML2_LIBS=${LIBXML2_LIBS}
+ AC_DEFINE([CLANG_HAVE_LIBXML],1,[Define if we have libxml2])
fi
AC_SUBST(LIBXML2_LIBS)
AC_SUBST(LIBXML2_INC)
Index: git/configure
===================================================================
--- git.orig/configure 2014-08-26 12:58:29.194210168 -0700
+++ git/configure 2014-08-26 13:19:00.424200963 -0700
@@ -769,7 +769,6 @@
HAVE_TERMINFO
USE_OPROFILE
USE_INTEL_JITEVENTS
-XML2CONFIG
LIBXML2_LIBS
LIBXML2_INC
CXXCPP
@@ -10164,144 +10163,17 @@
_ACEOF


-for ac_prog in xml2-config
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
-if test "${ac_cv_prog_XML2CONFIG+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$XML2CONFIG"; then
- ac_cv_prog_XML2CONFIG="$XML2CONFIG" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_XML2CONFIG="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-XML2CONFIG=$ac_cv_prog_XML2CONFIG
-if test -n "$XML2CONFIG"; then
- { echo "$as_me:$LINENO: result: $XML2CONFIG" >&5
-echo "${ECHO_T}$XML2CONFIG" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-
- test -n "$XML2CONFIG" && break
-done
-
-
-{ echo "$as_me:$LINENO: checking for libxml2 includes" >&5
-echo $ECHO_N "checking for libxml2 includes... $ECHO_C" >&6; }
-if test "x$XML2CONFIG" = "x"; then
- { echo "$as_me:$LINENO: result: xml2-config not found" >&5
-echo "${ECHO_T}xml2-config not found" >&6; }
-else
- LIBXML2_INC=`$XML2CONFIG --cflags`
- { echo "$as_me:$LINENO: result: $LIBXML2_INC" >&5
-echo "${ECHO_T}$LIBXML2_INC" >&6; }
- { echo "$as_me:$LINENO: checking for xmlReadFile in -lxml2" >&5
-echo $ECHO_N "checking for xmlReadFile in -lxml2... $ECHO_C" >&6; }
-if test "${ac_cv_lib_xml2_xmlReadFile+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lxml2 $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char xmlReadFile ();
-int
-main ()
-{
-return xmlReadFile ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_xml2_xmlReadFile=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_cv_lib_xml2_xmlReadFile=no
-fi
-
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_xml2_xmlReadFile" >&5
-echo "${ECHO_T}$ac_cv_lib_xml2_xmlReadFile" >&6; }
-if test $ac_cv_lib_xml2_xmlReadFile = yes; then
+PKG_CHECK_MODULES(LIBXML2, libxml-2.0,,
+ AC_MSG_ERROR([Could not find libxml-2.0])
+)
+if test "x$LIBXML2_CFLAGS" != "x"; then
+ LIBXML2_INC=${LIBXML2_CFLAGS}
+ LIBXML2_LIBS=${LIBXML2_LIBS}

cat >>confdefs.h <<\_ACEOF
#define CLANG_HAVE_LIBXML 1
_ACEOF

- LIBXML2_LIBS="-lxml2"
-fi
-
fi


@@ -19700,7 +19572,6 @@
HAVE_TERMINFO!$HAVE_TERMINFO$ac_delim
USE_OPROFILE!$USE_OPROFILE$ac_delim
USE_INTEL_JITEVENTS!$USE_INTEL_JITEVENTS$ac_delim
-XML2CONFIG!$XML2CONFIG$ac_delim
LIBXML2_LIBS!$LIBXML2_LIBS$ac_delim
LIBXML2_INC!$LIBXML2_INC$ac_delim
CXXCPP!$CXXCPP$ac_delim
@@ -19729,7 +19600,7 @@
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF

- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 96; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

0 comments on commit 7d75cff

Please sign in to comment.