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:40:07 +0100 |
| commit | 13f8a86122cac43cb0084be0ba94c8ccefc72e29 (patch) | |
| tree | 6821fbe949cf37d054d7b3bd83417701d2e90690 /meta/recipes-devtools/llvm | |
| parent | 79cc8584e6e29574ce271eb4a43d0dd9c8879e2c (diff) | |
| download | poky-13f8a86122cac43cb0084be0ba94c8ccefc72e29.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
(From OE-Core rev: 193ee1973f613b72f7f99660aecf652b07652d18)
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 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Copyright OpenEmbedded Contributors | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: MIT | ||
| 6 | # | ||
| 7 | # Wrap llvm-config since the native llvm-config will remap some values correctly | ||
| 8 | # if placed in the target sysroot but for flags, it would provide the native ones. | ||
| 9 | # Provide ours from the environment instead. | ||
| 10 | |||
| 11 | NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)" | ||
| 12 | if [[ $# == 0 ]]; then | ||
| 13 | exec "$NEXT_LLVM_CONFIG" | ||
| 14 | fi | ||
| 15 | |||
| 16 | remain="" | ||
| 17 | output="" | ||
| 18 | for arg in "$@"; do | ||
| 19 | case "$arg" in | ||
| 20 | --cppflags) | ||
| 21 | output="${output} ${CPPFLAGS}" | ||
| 22 | ;; | ||
| 23 | --cflags) | ||
| 24 | output="${output} ${CFLAGS}" | ||
| 25 | ;; | ||
| 26 | --cxxflags) | ||
| 27 | output="${output} ${CXXFLAGS}" | ||
| 28 | ;; | ||
| 29 | --ldflags) | ||
| 30 | output="${output} ${LDFLAGS}" | ||
| 31 | ;; | ||
| 32 | *) | ||
| 33 | remain="${remain} ${arg}" | ||
| 34 | ;; | ||
| 35 | esac | ||
| 36 | done | ||
| 37 | |||
| 38 | if [ "${remain}" != "" ]; then | ||
| 39 | output="${output} "$("$NEXT_LLVM_CONFIG" ${remain}) | ||
| 40 | fi | ||
| 41 | |||
| 42 | 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 | |||
| 31 | file://0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch;striplevel=2 \ | 31 | file://0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch;striplevel=2 \ |
| 32 | file://0007-llvm-allow-env-override-of-exe-path.patch;striplevel=2 \ | 32 | file://0007-llvm-allow-env-override-of-exe-path.patch;striplevel=2 \ |
| 33 | file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch;striplevel=2 \ | 33 | file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch;striplevel=2 \ |
| 34 | file://llvm-config \ | ||
| 34 | " | 35 | " |
| 35 | 36 | ||
| 36 | UPSTREAM_CHECK_GITTAGREGEX = "llvmorg-(?P<pver>\d+(\.\d+)+)" | 37 | UPSTREAM_CHECK_GITTAGREGEX = "llvmorg-(?P<pver>\d+(\.\d+)+)" |
| @@ -124,6 +125,15 @@ do_install() { | |||
| 124 | do_install:class-native() { | 125 | do_install:class-native() { |
| 125 | install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV} | 126 | install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV} |
| 126 | install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV} | 127 | install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV} |
| 128 | ln -sf llvm-config${PV} ${D}${bindir}/llvm-config | ||
| 129 | } | ||
| 130 | |||
| 131 | SYSROOT_PREPROCESS_FUNCS:append:class-target = " llvm_sysroot_preprocess" | ||
| 132 | |||
| 133 | llvm_sysroot_preprocess() { | ||
| 134 | install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/ | ||
| 135 | install -m 0755 ${WORKDIR}/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/ | ||
| 136 | ln -sf llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/llvm-config${PV} | ||
| 127 | } | 137 | } |
| 128 | 138 | ||
| 129 | PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto" | 139 | PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto" |
