Skip to content

Commit

Permalink
clang16: Apply libunwind.pc.in and llvm-config via a patch
Browse files Browse the repository at this point in the history
this will simplify things with UNPACKDIR and shared sources for all llvm
derived recipes

Signed-off-by: Khem Raj <[email protected]>
Signed-off-by: Zoltán Böszörményi <[email protected]>
  • Loading branch information
zboszor committed Aug 5, 2024
1 parent f725e59 commit b992008
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
From e54d4a15f31b8f84dc24ae14efc65713b1a6d6d7 Mon Sep 17 00:00:00 2001
From: Khem Raj <[email protected]>
Date: Tue, 14 May 2024 22:04:43 -0700
Subject: [PATCH] llvm: Add libunwind.pc.in and llvm-config scripts

These are added by OE project

Upstream-Status: Inappropriate [ OE-Specific ]

Signed-off-by: Khem Raj <[email protected]>
---
libunwind/libunwind.pc.in | 9 ++++++
llvm/tools/llvm-config/llvm-config | 52 ++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
create mode 100644 libunwind/libunwind.pc.in
create mode 100644 llvm/tools/llvm-config/llvm-config

diff --git a/libunwind/libunwind.pc.in b/libunwind/libunwind.pc.in
new file mode 100644
index 000000000000..a93d676604f9
--- /dev/null
+++ b/libunwind/libunwind.pc.in
@@ -0,0 +1,9 @@
+prefix=/usr
+exec_prefix=/usr
+libdir=@LIBDIR@
+includedir=/usr/include
+
+Name: libunwind
+Description: libunwind base library
+Version: @VERSION@
+Libs: -lunwind
diff --git a/llvm/tools/llvm-config/llvm-config b/llvm/tools/llvm-config/llvm-config
new file mode 100644
index 000000000000..6a0dd54b8eab
--- /dev/null
+++ b/llvm/tools/llvm-config/llvm-config
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# Wrapper script for llvm-config. Supplies the right environment variables
+# for the target and delegates to the native llvm-config for anything else. This
+# is needed because arguments like --ldflags, --cxxflags, etc. are set by the
+# native compile rather than the target compile.
+#
+SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
+NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
+export YOCTO_ALTERNATE_EXE_PATH="${YOCTO_ALTERNATE_EXE_PATH:="$(readlink -f "$SCRIPT_DIR/../llvm-config")"}"
+if [ -n "$( echo $base_libdir | sed -n '/lib64/p')" ]; then
+ export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib64"}"
+else
+ export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib"}"
+fi
+if [[ $# == 0 ]]; then
+ exec "$NEXT_LLVM_CONFIG"
+fi
+
+remain=""
+output=""
+for arg in "$@"; do
+ case "$arg" in
+ --cppflags)
+ output="${output} ${CPPFLAGS}"
+ ;;
+ --cflags)
+ output="${output} ${CFLAGS}"
+ ;;
+ --cxxflags)
+ output="${output} ${CXXFLAGS}"
+ ;;
+ --ldflags)
+ output="${output} ${LDFLAGS}"
+ ;;
+ --shared-mode)
+ output="${output} shared"
+ ;;
+ --link-shared)
+ break
+ ;;
+ *)
+ remain="${remain} ${arg}"
+ ;;
+ esac
+done
+
+if [ "${remain}" != "" ]; then
+ output="${output} "$("$NEXT_LLVM_CONFIG" ${remain})
+fi
+
+echo "${output}"
9 changes: 0 additions & 9 deletions recipes-devtools/clang16/clang/libunwind.pc.in

This file was deleted.

52 changes: 0 additions & 52 deletions recipes-devtools/clang16/clang/llvm-config

This file was deleted.

2 changes: 1 addition & 1 deletion recipes-devtools/clang16/clang16_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ SYSROOT_PREPROCESS_FUNCS:append:class-target = " clang_sysroot_preprocess"

clang_sysroot_preprocess() {
install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
install -m 0755 ${S}/../llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
install -m 0755 ${S}/llvm/tools/llvm-config/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV}
# LLDTargets.cmake references the lld executable(!) that some modules/plugins link to
install -d ${SYSROOT_DESTDIR}${bindir}
Expand Down
3 changes: 1 addition & 2 deletions recipes-devtools/clang16/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ LICENSE = "Apache-2.0-with-LLVM-exception"
BASEURI ??= "${LLVM_GIT}/llvm-project;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH}"
SRC_URI = "\
${BASEURI} \
file://llvm-config \
file://libunwind.pc.in \
file://0001-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch \
file://0002-compiler-rt-support-a-new-embedded-linux-target.patch \
file://0003-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch \
Expand Down Expand Up @@ -46,6 +44,7 @@ SRC_URI = "\
file://0034-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \
file://0035-compiler-rt-Fix-stat-struct-s-size-for-O32-ABI.patch \
file://0036-compiler-rt-Undef-_TIME_BITS-along-with-_FILE_OFFSET.patch \
file://0036-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch \
file://0037-Call-printName-to-get-name-of-Decl.patch \
file://0038-Apply-fmacro-prefix-map-to-anonymous-tags-in-templat.patch \
file://0039-lld-RISCV-Handle-relaxation-reductions-of-more-than-.patch \
Expand Down
2 changes: 1 addition & 1 deletion recipes-devtools/clang16/libcxx16-initial_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ do_install:append() {
install -Dm 0644 ${S}/libunwind/include/$f ${D}${includedir}/$f
done
install -d ${D}${libdir}/pkgconfig
sed -e 's,@LIBDIR@,${libdir},g;s,@VERSION@,${PV},g' ${S}/../libunwind.pc.in > ${D}${libdir}/pkgconfig/libunwind.pc
sed -e 's,@LIBDIR@,${libdir},g;s,@VERSION@,${PV},g' ${S}/libunwind/libunwind.pc.in > ${D}${libdir}/pkgconfig/libunwind.pc
fi
}

Expand Down

0 comments on commit b992008

Please sign in to comment.