diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-30 17:41:35 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-31 10:37:11 +0100 |
commit | 193ee1973f613b72f7f99660aecf652b07652d18 (patch) | |
tree | d275c1bfba8ffb3a5529c9644b053d91f0845830 /meta/recipes-devtools/llvm | |
parent | 5e07e6c376cf46d2788dcef53e9feba890c0236d (diff) | |
download | openembedded-core-193ee1973f613b72f7f99660aecf652b07652d18.tar.gz |
llvm: Add llvm-config wrapper to improve flags handling
Add a wrapper for llvm-config which provides flags from the current envrionment
instead of the values hardcoded into llvm-native at compile time. Inspiration
taken from the wrapper in meta-clang but I had to totally rewrite it as:
* the TARGET_* prefixes weren't in our environment
* meson uses --libs --ldflags XXX which didn't work
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/llvm')
-rw-r--r-- | meta/recipes-devtools/llvm/llvm/llvm-config | 42 | ||||
-rw-r--r-- | meta/recipes-devtools/llvm/llvm_git.bb | 10 |
2 files changed, 52 insertions, 0 deletions
diff --git a/meta/recipes-devtools/llvm/llvm/llvm-config b/meta/recipes-devtools/llvm/llvm/llvm-config new file mode 100644 index 0000000000..a45f38c650 --- /dev/null +++ b/meta/recipes-devtools/llvm/llvm/llvm-config @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# +# Wrap llvm-config since the native llvm-config will remap some values correctly +# if placed in the target sysroot but for flags, it would provide the native ones. +# Provide ours from the environment instead. + +NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)" +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}" + ;; + *) + remain="${remain} ${arg}" + ;; + esac +done + +if [ "${remain}" != "" ]; then + output="${output} "$("$NEXT_LLVM_CONFIG" ${remain}) +fi + +echo "${output}" diff --git a/meta/recipes-devtools/llvm/llvm_git.bb b/meta/recipes-devtools/llvm/llvm_git.bb index bdea95db96..4c7fadb667 100644 --- a/meta/recipes-devtools/llvm/llvm_git.bb +++ b/meta/recipes-devtools/llvm/llvm_git.bb @@ -31,6 +31,7 @@ SRC_URI = "git://github.com/llvm/llvm-project.git;branch=${BRANCH};protocol=http file://0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch;striplevel=2 \ file://0007-llvm-allow-env-override-of-exe-path.patch;striplevel=2 \ file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch;striplevel=2 \ + file://llvm-config \ " UPSTREAM_CHECK_GITTAGREGEX = "llvmorg-(?P<pver>\d+(\.\d+)+)" @@ -124,6 +125,15 @@ do_install() { do_install:class-native() { install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV} install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV} + ln -sf llvm-config${PV} ${D}${bindir}/llvm-config +} + +SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess" + +llvm_sysroot_preprocess() { + install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/ + install -m 0755 ${WORKDIR}/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/ + ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} } PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto" |