mirror of
https://abf.rosa.ru/djam/llvm12.git
synced 2025-02-23 15:22:50 +00:00
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/sh
|
|
# Author: mikhailnov
|
|
# Remove flags that clang does not know but which cannot be removed properly
|
|
# https://bugzilla.rosalinux.ru/show_bug.cgi?id=9567
|
|
|
|
set -efu
|
|
|
|
echo_err() {
|
|
echo "$@" 1>&2
|
|
}
|
|
|
|
# %noclang_optflags
|
|
NOCLANG_OPTFLAGS="${NOCLANG_OPTFLAGS:-}"
|
|
# which flags to remove in addition to %noclang_optflags,
|
|
# set custom REMOVE_CFLAGS in %build or redefine %noclang_optflags
|
|
REMOVE_CFLAGS="${REMOVE_CFLAGS:-}"
|
|
# convert flags list to regexp
|
|
REMOVE="$(echo "$NOCLANG_OPTFLAGS $REMOVE_CFLAGS" | sed -e 's, ,|,g' -e 's,|$,,g')"
|
|
|
|
# _CLANG_ must be changed to /usr/bin/clang++ and then to /usr/bin/clang in another copy of this wrapper
|
|
if echo "$@" | grep -qE -- "${REMOVE}"
|
|
then
|
|
echo_err "DEBUG: clang-wrapper: arguements will be cut-out!"
|
|
echo_err "DEBUG: arguements were: "
|
|
echo_err "========================="
|
|
echo_err "$@"
|
|
echo_err "========================="
|
|
new_args="$(echo "$@" | sed -r -e "s,${REMOVE},,g")"
|
|
echo_err "DEBUG: new arguements are: "
|
|
echo_err "========================="
|
|
echo_err ${new_args}
|
|
# https://stackoverflow.com/a/37141139 (??)
|
|
_CLANG_ ${new_args}
|
|
else
|
|
_CLANG_ "$@"
|
|
fi
|