From b992008994d2ccaf4397a0cbf8d8836ec9d06504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Date: Mon, 5 Aug 2024 11:16:56 +0200 Subject: [PATCH] clang16: Apply libunwind.pc.in and llvm-config via a patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this will simplify things with UNPACKDIR and shared sources for all llvm derived recipes Signed-off-by: Khem Raj Signed-off-by: Zoltán Böszörményi --- ...unwind.pc.in-and-llvm-config-scripts.patch | 90 +++++++++++++++++++ .../clang16/clang/libunwind.pc.in | 9 -- recipes-devtools/clang16/clang/llvm-config | 52 ----------- recipes-devtools/clang16/clang16_git.bb | 2 +- recipes-devtools/clang16/common.inc | 3 +- .../clang16/libcxx16-initial_git.bb | 2 +- 6 files changed, 93 insertions(+), 65 deletions(-) create mode 100644 recipes-devtools/clang16/clang/0036-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch delete mode 100644 recipes-devtools/clang16/clang/libunwind.pc.in delete mode 100644 recipes-devtools/clang16/clang/llvm-config diff --git a/recipes-devtools/clang16/clang/0036-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch b/recipes-devtools/clang16/clang/0036-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch new file mode 100644 index 00000000..84a0d2bc --- /dev/null +++ b/recipes-devtools/clang16/clang/0036-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch @@ -0,0 +1,90 @@ +From e54d4a15f31b8f84dc24ae14efc65713b1a6d6d7 Mon Sep 17 00:00:00 2001 +From: Khem Raj +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 +--- + 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}" diff --git a/recipes-devtools/clang16/clang/libunwind.pc.in b/recipes-devtools/clang16/clang/libunwind.pc.in deleted file mode 100644 index a93d6766..00000000 --- a/recipes-devtools/clang16/clang/libunwind.pc.in +++ /dev/null @@ -1,9 +0,0 @@ -prefix=/usr -exec_prefix=/usr -libdir=@LIBDIR@ -includedir=/usr/include - -Name: libunwind -Description: libunwind base library -Version: @VERSION@ -Libs: -lunwind diff --git a/recipes-devtools/clang16/clang/llvm-config b/recipes-devtools/clang16/clang/llvm-config deleted file mode 100644 index bfdc61a8..00000000 --- a/recipes-devtools/clang16/clang/llvm-config +++ /dev/null @@ -1,52 +0,0 @@ -#!/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 - -if [[ $1 == "--libs" ]]; then - exec "$NEXT_LLVM_CONFIG" $@ -fi - -if [[ $1 == "--bindir" ]]; then - unset YOCTO_ALTERNATE_EXE_PATH - exec "$NEXT_LLVM_CONFIG" $@ -fi - -if [[ $1 == "--libfiles" ]]; then - exec "$NEXT_LLVM_CONFIG" $@ -fi - - -for arg in "$@"; do - case "$arg" in - --cppflags) - echo $CPPFLAGS - ;; - --cflags) - echo $CFLAGS - ;; - --cxxflags) - echo $CXXFLAGS - ;; - --ldflags) - echo $LDFLAGS - ;; - *) - echo "$("$NEXT_LLVM_CONFIG" "$arg")" - ;; - esac -done diff --git a/recipes-devtools/clang16/clang16_git.bb b/recipes-devtools/clang16/clang16_git.bb index f7b403e4..3cf1463d 100644 --- a/recipes-devtools/clang16/clang16_git.bb +++ b/recipes-devtools/clang16/clang16_git.bb @@ -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} diff --git a/recipes-devtools/clang16/common.inc b/recipes-devtools/clang16/common.inc index cb16e5aa..2186f655 100644 --- a/recipes-devtools/clang16/common.inc +++ b/recipes-devtools/clang16/common.inc @@ -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 \ @@ -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 \ diff --git a/recipes-devtools/clang16/libcxx16-initial_git.bb b/recipes-devtools/clang16/libcxx16-initial_git.bb index aa3c1663..940ad3e5 100644 --- a/recipes-devtools/clang16/libcxx16-initial_git.bb +++ b/recipes-devtools/clang16/libcxx16-initial_git.bb @@ -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 }