summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/llvm
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2022-04-07 19:00:15 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-19 14:14:11 +0100
commit9481976d8020f593220a79531bc2dd56a17539f3 (patch)
tree59bfd60d05af5f2624889dc802ef7569b627f01d /meta/recipes-devtools/llvm
parentcbb01bd465ceca64cd48c315f86b9239b742999e (diff)
downloadpoky-9481976d8020f593220a79531bc2dd56a17539f3.tar.gz
llvm: use default install paths
There was a very brittle sed hack against cpp source code that allowed installing multiple llvm versions into the same target/sysroot. Patching with sed is prone to silent regressions as it can change both too little and too much, and it indeed it broke with llvm 14. It's also difficult to tell what the 'right' change should look like. If this feature is actually needed somewhere, please do it properly: proper patch and upstream first. (From OE-Core rev: 974f67b18a2f1a15c76785d69e7234594af97a88) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/llvm')
-rw-r--r--meta/recipes-devtools/llvm/llvm_git.bb58
1 files changed, 16 insertions, 42 deletions
diff --git a/meta/recipes-devtools/llvm/llvm_git.bb b/meta/recipes-devtools/llvm/llvm_git.bb
index 13f7fb763e..e10348a7f2 100644
--- a/meta/recipes-devtools/llvm/llvm_git.bb
+++ b/meta/recipes-devtools/llvm/llvm_git.bb
@@ -24,7 +24,6 @@ PV = "14.0.0"
24MAJOR_VERSION = "${@oe.utils.trim_version("${PV}", 1)}" 24MAJOR_VERSION = "${@oe.utils.trim_version("${PV}", 1)}"
25 25
26LLVM_RELEASE = "${PV}" 26LLVM_RELEASE = "${PV}"
27LLVM_DIR = "llvm${LLVM_RELEASE}"
28 27
29BRANCH = "release/${MAJOR_VERSION}.x" 28BRANCH = "release/${MAJOR_VERSION}.x"
30SRCREV = "329fda39c507e8740978d10458451dcdb21563be" 29SRCREV = "329fda39c507e8740978d10458451dcdb21563be"
@@ -91,13 +90,6 @@ EXTRA_OECMAKE:append:class-nativesdk = "\
91 -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \ 90 -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \
92 " 91 "
93 92
94do_configure:prepend() {
95# Fix paths in llvm-config
96 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
97 sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g" ${S}/tools/llvm-config/llvm-config.cpp
98 sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g" ${S}/tools/llvm-config/llvm-config.cpp
99}
100
101# patch out build host paths for reproducibility 93# patch out build host paths for reproducibility
102do_compile:prepend:class-target() { 94do_compile:prepend:class-target() {
103 sed -i -e "s,${WORKDIR},,g" ${B}/tools/llvm-config/BuildVariables.inc 95 sed -i -e "s,${WORKDIR},,g" ${B}/tools/llvm-config/BuildVariables.inc
@@ -112,34 +104,17 @@ do_compile:class-native() {
112} 104}
113 105
114do_install() { 106do_install() {
115 DESTDIR=${LLVM_INSTALL_DIR} ninja -v install 107 DESTDIR=${D} ninja -v install
116 install -D -m 0755 ${B}/bin/llvm-config ${D}${libdir}/${LLVM_DIR}/llvm-config
117
118 install -d ${D}${bindir}/${LLVM_DIR}
119 cp -r ${LLVM_INSTALL_DIR}${bindir}/* ${D}${bindir}/${LLVM_DIR}/
120
121 install -d ${D}${includedir}/${LLVM_DIR}
122 cp -r ${LLVM_INSTALL_DIR}${includedir}/* ${D}${includedir}/${LLVM_DIR}/
123
124 install -d ${D}${libdir}/${LLVM_DIR}
125
126 # The LLVM sources have "/lib" embedded and so we cannot completely rely on the ${libdir} variable
127 if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
128 cp -r ${LLVM_INSTALL_DIR}${libdir}/* ${D}${libdir}/${LLVM_DIR}/
129 elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
130 cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/* ${D}${libdir}/${LLVM_DIR}/
131 elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
132 cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/* ${D}${libdir}/${LLVM_DIR}/
133 fi
134 108
135 # Remove unnecessary cmake files 109 # llvm harcodes usr/lib as install path, so this corrects it to actual libdir
136 rm -rf ${D}${libdir}/${LLVM_DIR}/cmake 110 mv -T -n ${D}/${prefix}/lib ${D}/${libdir} || true
137 111
138 ln -s ${LLVM_DIR}/libLLVM-${MAJOR_VERSION}${SOLIBSDEV} ${D}${libdir}/libLLVM-${MAJOR_VERSION}${SOLIBSDEV} 112 # Remove opt-viewer: https://llvm.org/docs/Remarks.html
113 rm -rf ${D}${datadir}/opt-viewer
114 rmdir ${D}${datadir}
139 115
140 # We'll have to delete the libLLVM.so due to multiple reasons... 116 # reproducibility
141 rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so 117 sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake
142 rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
143} 118}
144 119
145do_install:class-native() { 120do_install:class-native() {
@@ -152,34 +127,33 @@ PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptrema
152RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks" 127RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks"
153 128
154FILES:${PN}-bugpointpasses = "\ 129FILES:${PN}-bugpointpasses = "\
155 ${libdir}/${LLVM_DIR}/BugpointPasses.so \ 130 ${libdir}/BugpointPasses.so \
156" 131"
157 132
158FILES:${PN}-libllvm = "\ 133FILES:${PN}-libllvm = "\
159 ${libdir}/${LLVM_DIR}/libLLVM-${MAJOR_VERSION}.so \
160 ${libdir}/libLLVM-${MAJOR_VERSION}.so \ 134 ${libdir}/libLLVM-${MAJOR_VERSION}.so \
161" 135"
162 136
163FILES:${PN}-liblto += "\ 137FILES:${PN}-liblto += "\
164 ${libdir}/${LLVM_DIR}/libLTO.so.* \ 138 ${libdir}/libLTO.so.* \
165" 139"
166 140
167FILES:${PN}-liboptremarks += "\ 141FILES:${PN}-liboptremarks += "\
168 ${libdir}/${LLVM_DIR}/libRemarks.so.* \ 142 ${libdir}/libRemarks.so.* \
169" 143"
170 144
171FILES:${PN}-llvmhello = "\ 145FILES:${PN}-llvmhello = "\
172 ${libdir}/${LLVM_DIR}/LLVMHello.so \ 146 ${libdir}/LLVMHello.so \
173" 147"
174 148
175FILES:${PN}-dev += " \ 149FILES:${PN}-dev += " \
176 ${libdir}/${LLVM_DIR}/llvm-config \ 150 ${libdir}/llvm-config \
177 ${libdir}/${LLVM_DIR}/libRemarks.so \ 151 ${libdir}/libRemarks.so \
178 ${libdir}/${LLVM_DIR}/libLLVM-${PV}.so \ 152 ${libdir}/libLLVM-${PV}.so \
179" 153"
180 154
181FILES:${PN}-staticdev += "\ 155FILES:${PN}-staticdev += "\
182 ${libdir}/${LLVM_DIR}/*.a \ 156 ${libdir}/*.a \
183" 157"
184 158
185INSANE_SKIP:${PN}-libllvm += "dev-so" 159INSANE_SKIP:${PN}-libllvm += "dev-so"