blob: fa971f38c858ce29f22ba2065a0274708c16a804 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001# LLVM does not provide ABI stability between different versions. For this
2# reason OE makes it possible to build and install different llvm versions
3# at the same time.
4#
5# This is true for the normal recipes as well as the native ones.
6#
7# All regular installation directories are prefixed with 'llvm${LLVM_RELEASE}'
8# e.g. "${STAGING_BINDIR}/llvm2.5" or "${STAGING_INCDIR}/llvm2.5"
9#
10# For your program or library that makes use of llvm you do should not need to
11# modify anything as long as it uses the results of various llvm-config
12# invocations. If you need customizations something is wrong and it needs to be
13# fixed (report bug).
14#
15# However the *recipe* for your program/library *must* declare
16# export WANT_LLVM_RELEASE = "<valid version number>"
17# The version number is picked up by a generic wrapper script which just calls
18# the variant of the specified version.
19
20DESCRIPTION = "The Low Level Virtual Machine"
21HOMEPAGE = "http://llvm.org"
22
23# 3-clause BSD-like
24# University of Illinois/NCSA Open Source License
25LICENSE = "NCSA"
26LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=d0a3ef0d3e0e8f5cf59e5ffc273ab1f8"
27
28DEPENDS = "libffi libxml2-native llvm-common"
29
30inherit perlnative pythonnative autotools
31
32LLVM_RELEASE = "${PV}"
33LLVM_DIR = "llvm${LLVM_RELEASE}"
34
35SRC_URI = "http://llvm.org/releases/${PV}/llvm-${PV}.src.tar.gz"
36S = "${WORKDIR}/llvm-${PV}.src"
37
38LLVM_BUILD_DIR = "${WORKDIR}/llvm-${PV}.build"
39LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
40
41EXTRA_OECONF += "--disable-assertions \
42 --enable-debug-runtime \
43 --disable-expensive-checks \
44 --enable-bindings=none \
45 --enable-keep-symbols \
46 --enable-libffi \
47 --enable-optimized \
48 --enable-shared \
49 --enable-targets=host-only"
50EXTRA_OEMAKE += "REQUIRES_RTTI=1 VERBOSE=1"
51
52do_configure_prepend() {
53 # Remove RPATHs
54 sed -i 's:$(RPATH) -Wl,$(\(ToolDir\|LibDir\|ExmplDir\))::g' ${S}/Makefile.rules
55
56 # Drop "svn" suffix from version string
57 sed -i 's/${PV}svn/${PV}/g' ${S}/configure
58
59 # Fix paths in llvm-config
60 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
61 sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g" ${S}/tools/llvm-config/llvm-config.cpp
62
63 # Fix the hardcoded libdir in llvm-config
64 sed -i 's:/lib\>:/${baselib}:g' ${S}/tools/llvm-config/llvm-config.cpp
65
66 # Fails to build unless using separate directory from source
67 mkdir -p ${LLVM_BUILD_DIR}
68 cd ${LLVM_BUILD_DIR}
69}
70
71do_compile() {
72 cd ${LLVM_BUILD_DIR}
73
74 # Fix libdir for multilib
75 sed -i 's:(PROJ_prefix)/lib:(PROJ_prefix)/${baselib}:g' Makefile.config
76
77 oe_runmake \
78 AR="${BUILD_AR}" \
79 CC="${BUILD_CC}" \
80 CFLAGS="${BUILD_CFLAGS}" \
81 CXX="${BUILD_CXX}" \
82 CXXFLAGS="${BUILD_CXXFLAGS}" \
83 CPP="${BUILD_CPP}" \
84 CPPFLAGS="${BUILD_CPPFLAGS}" \
85 NM="${BUILD_NM}" \
86 RANLIB="${BUILD_RANLIB}" \
87 PATH="${STAGING_BINDIR_NATIVE}:$PATH" \
88 cross-compile-build-tools
89 oe_runmake
90}
91
92do_install() {
93 cd ${LLVM_BUILD_DIR}
94 oe_runmake DESTDIR=${LLVM_INSTALL_DIR} install
95
96 mv ${LLVM_INSTALL_DIR}${bindir}/${HOST_SYS}-llvm-config-host ${LLVM_INSTALL_DIR}/llvm-config-host
97
98 install -d ${D}${bindir}/${LLVM_DIR}
99 mv ${LLVM_INSTALL_DIR}${bindir}/* ${D}${bindir}/${LLVM_DIR}/
100
101 install -d ${D}${includedir}/${LLVM_DIR}
102 mv ${LLVM_INSTALL_DIR}${includedir}/* ${D}${includedir}/${LLVM_DIR}/
103
104 install -d ${D}${libdir}/${LLVM_DIR}
105 mv ${LLVM_INSTALL_DIR}${libdir}/* ${D}${libdir}/${LLVM_DIR}/
106 ln -s ${LLVM_DIR}/libLLVM-${PV}.so ${D}${libdir}/libLLVM-${PV}.so
107
108 install -d ${D}${docdir}/${LLVM_DIR}
109 mv ${LLVM_INSTALL_DIR}${prefix}/docs/llvm/* ${D}${docdir}/${LLVM_DIR}
110}
111
112SYSROOT_PREPROCESS_FUNCS += "llvm_sysroot_preprocess"
113
114llvm_sysroot_preprocess() {
115 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}
116 mv ${LLVM_INSTALL_DIR}/llvm-config-host ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV}
117}
118
119PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
120ALLOW_EMPTY_${PN} = "1"
121ALLOW_EMPTY_${PN}-staticdev = "1"
122FILES_${PN} = ""
123FILES_${PN}-staticdev = ""
124FILES_${PN}-dbg = " \
125 ${bindir}/${LLVM_DIR}/.debug \
126 ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
127 ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
128 /usr/src/debug \
129"
130
131FILES_${PN}-dev = " \
132 ${bindir}/${LLVM_DIR} \
133 ${includedir}/${LLVM_DIR} \
134"
135RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
136
137FILES_${PN}-bugpointpasses = "\
138 ${libdir}/${LLVM_DIR}/BugpointPasses.so \
139"
140FILES_${PN}-llvmhello = "\
141 ${libdir}/${LLVM_DIR}/LLVMHello.so \
142"
143
144PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
145NOAUTOPACKAGEDEBUG = "1"
146
147INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE} += "dev-so"
148
149python llvm_populate_packages() {
150 libdir = bb.data.expand('${libdir}', d)
151 libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
152 split_dbg_packages = do_split_packages(d, libllvm_libdir+'/.debug', '^lib(.*)\.so$', 'libllvm${LLVM_RELEASE}-%s-dbg', 'Split debug package for %s', allow_dirs=True)
153 split_packages = do_split_packages(d, libdir, '^lib(.*)\.so$', 'libllvm${LLVM_RELEASE}-%s', 'Split package for %s', allow_dirs=True, allow_links=True, recursive=True)
154 split_staticdev_packages = do_split_packages(d, libllvm_libdir, '^lib(.*)\.a$', 'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev package for %s', allow_dirs=True)
155 if split_packages:
156 pn = d.getVar('PN', True)
157 d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
158 d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+' '.join(split_dbg_packages))
159 d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+' '.join(split_staticdev_packages))
160}
161
162PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "