summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2019-06-06 22:08:10 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2019-09-07 09:42:39 +0200
commit0cfaf3a959cf45406423279f285da7c9453478ca (patch)
tree03228f4dbe3ddce2138017c8a315565e3d282d39 /scripts
parentd5ee00c09b826bbafe9bec2227d5aca7bf3a24bd (diff)
downloadptxdist-0cfaf3a959cf45406423279f285da7c9453478ca.tar.gz
ptxdist-0cfaf3a959cf45406423279f285da7c9453478ca.tar.xz
wrapper: add support for clang with OSELAS.Toolchain
This is a bit complex: Clang does not have default CPU features that can be specified at build-time. Instead the some features are derived from the compiler name (e.g. via a symlink with target triple). Others must be specified on the command-line (e.g. -mfpu=...). The toolchain provides wrapper scripts with the target triple to do this. However, using those is incompatible with icecc, because this only works if the actuall binary is called. So we let the toolchain provide the extra options and call clang directly. And fall back to just the target triple if necessary. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/ptxd_make_00-init.sh4
-rwxr-xr-xscripts/wrapper/clang++-wrapper16
-rwxr-xr-xscripts/wrapper/clang-wrapper16
-rwxr-xr-xscripts/wrapper/g++-wrapper2
-rwxr-xr-xscripts/wrapper/gcc-wrapper2
-rwxr-xr-xscripts/wrapper/host-g++-wrapper2
-rwxr-xr-xscripts/wrapper/host-gcc-wrapper2
-rw-r--r--scripts/wrapper/libwrapper.sh30
8 files changed, 64 insertions, 10 deletions
diff --git a/scripts/lib/ptxd_make_00-init.sh b/scripts/lib/ptxd_make_00-init.sh
index ca10831ad..4f13e104c 100644
--- a/scripts/lib/ptxd_make_00-init.sh
+++ b/scripts/lib/ptxd_make_00-init.sh
@@ -211,7 +211,7 @@ ptxd_init_cross_env() {
# add "-L<DIR>/lib -Wl,-rpath-link -Wl,<DIR>"
local -a ldflags
ldflags=( "${prefix[@]/%//${lib_dir}}" )
- ldflags=( "${ldflags[@]/#/-B}" "${ldflags[@]/#/-Wl,-rpath-link -Wl,}" )
+ ldflags=( "${ldflags[@]/#/-B}" "${ldflags[@]/#/-L}" "${ldflags[@]/#/-Wl,-rpath-link -Wl,}" )
export \
PTXDIST_CROSS_CPPFLAGS="${cppflags[*]}" \
@@ -302,7 +302,9 @@ ptxd_init_save_wrapper_env() {
PTXDIST_HOST_CPPFLAGS="${PTXDIST_HOST_CPPFLAGS}"
PTXDIST_HOST_LDFLAGS="${PTXDIST_HOST_LDFLAGS}"
PTXDIST_PLATFORMDIR="${PTXDIST_PLATFORMDIR}"
+ PTXDIST_SYSROOT_TOOLCHAIN="${PTXDIST_SYSROOT_TOOLCHAIN}"
PTXDIST_ICECC_REMOTE_CPP="${PTXDIST_ICECC_REMOTE_CPP}"
+ PTXDIST_ICECC_CLANG="${PTXDIST_ICECC_CLANG}"
EOF
}
diff --git a/scripts/wrapper/clang++-wrapper b/scripts/wrapper/clang++-wrapper
new file mode 100755
index 000000000..ae5f97bb0
--- /dev/null
+++ b/scripts/wrapper/clang++-wrapper
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit
+
+cc_check_args "${@}"
+
+cc_add_target_clang
+cc_add_target_reproducible
+cxx_add_target_extra
+cc_add_target_ld_args
+cc_add_fortify
+cc_add_pie
+cc_add_glibcxx
+cxx_add_target_icecc clang
+
+wrapper_exec "$@"
diff --git a/scripts/wrapper/clang-wrapper b/scripts/wrapper/clang-wrapper
new file mode 100755
index 000000000..bc4fde9b7
--- /dev/null
+++ b/scripts/wrapper/clang-wrapper
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. "$(dirname "$(readlink -f "$0")")/libwrapper.sh" || exit
+
+cc_check_args "${@}"
+
+cc_add_target_clang
+cc_add_target_reproducible
+cc_add_target_extra
+cc_add_target_ld_args
+cc_add_fortify
+cc_add_pie
+cc_add_glibcxx
+cc_add_target_icecc clang
+
+wrapper_exec "$@"
diff --git a/scripts/wrapper/g++-wrapper b/scripts/wrapper/g++-wrapper
index f957c1d80..fb5b4b63b 100755
--- a/scripts/wrapper/g++-wrapper
+++ b/scripts/wrapper/g++-wrapper
@@ -11,6 +11,6 @@ cc_add_fortify
cc_add_stack
cc_add_pie
cc_add_glibcxx
-cxx_add_target_icecc "${@}"
+cxx_add_target_icecc
wrapper_exec "$@"
diff --git a/scripts/wrapper/gcc-wrapper b/scripts/wrapper/gcc-wrapper
index 5645b8e17..624938f98 100755
--- a/scripts/wrapper/gcc-wrapper
+++ b/scripts/wrapper/gcc-wrapper
@@ -11,6 +11,6 @@ cc_add_fortify
cc_add_stack
cc_add_pie
cc_add_glibcxx
-cc_add_target_icecc "${@}"
+cc_add_target_icecc
wrapper_exec "$@"
diff --git a/scripts/wrapper/host-g++-wrapper b/scripts/wrapper/host-g++-wrapper
index ca8d561c7..de4444abe 100755
--- a/scripts/wrapper/host-g++-wrapper
+++ b/scripts/wrapper/host-g++-wrapper
@@ -8,6 +8,6 @@ cc_check_args "${@}"
cc_add_host_ld_args
cxx_add_host_extra
-cxx_add_host_icecc "${@}"
+cxx_add_host_icecc
wrapper_exec "$@"
diff --git a/scripts/wrapper/host-gcc-wrapper b/scripts/wrapper/host-gcc-wrapper
index 9b2979858..9887abe8c 100755
--- a/scripts/wrapper/host-gcc-wrapper
+++ b/scripts/wrapper/host-gcc-wrapper
@@ -8,6 +8,6 @@ cc_check_args "${@}"
cc_add_host_ld_args
cc_add_host_extra
-cc_add_host_icecc "${@}"
+cc_add_host_icecc
wrapper_exec "$@"
diff --git a/scripts/wrapper/libwrapper.sh b/scripts/wrapper/libwrapper.sh
index 887e89c2d..d54e923dd 100644
--- a/scripts/wrapper/libwrapper.sh
+++ b/scripts/wrapper/libwrapper.sh
@@ -277,7 +277,12 @@ cxx_add_host_extra() {
add_icecc_args() {
if [ -n "${PTXDIST_ICECC}" ]; then
- add_late_arg "-fno-diagnostics-show-caret"
+ if [ "${1}" != clang ]; then
+ add_late_arg "-fno-diagnostics-show-caret"
+ elif [ "${PTXDIST_ICECC_CLANG}" != 1 ]; then
+ unset PTXDIST_ICECC
+ return
+ fi
if [ "${PTXDIST_ICECC_REMOTE_CPP}" != 1 -o "${ICECC_REMOTE_CPP}" = "0" ]; then
add_late_arg "-Wno-implicit-fallthrough"
fi
@@ -285,25 +290,40 @@ add_icecc_args() {
}
cc_add_target_icecc() {
- add_icecc_args
+ add_icecc_args "${@}"
export ICECC_VERSION="${ICECC_VERSION_TARGET}"
export ICECC_CC="${FULL_CMD}"
}
cxx_add_target_icecc() {
- add_icecc_args
+ add_icecc_args "${@}"
export ICECC_VERSION="${ICECC_VERSION_TARGET}"
export ICECC_CXX="${FULL_CMD}"
}
cc_add_host_icecc() {
- add_icecc_args
+ add_icecc_args "${@}"
export ICECC_VERSION="${ICECC_VERSION_HOST}"
export ICECC_CC="${FULL_CMD}"
}
cxx_add_host_icecc() {
- add_icecc_args
+ add_icecc_args "${@}"
export ICECC_VERSION="${ICECC_VERSION_HOST}"
export ICECC_CXX="${FULL_CMD}"
}
+
+cc_add_target_clang() {
+ triple="${CMD%-*}"
+ FULL_CMD=$(readlink "${0%/*}/real/${CMD}")
+ if [ -n "${PTXDIST_SYSROOT_TOOLCHAIN}" ]; then
+ add_arg --sysroot="${PTXDIST_SYSROOT_TOOLCHAIN}"
+ fi
+ env="$(dirname "${FULL_CMD}")/.${triple}.flags"
+ if [ -e "${env}" ]; then
+ . "${env}"
+ add_arg ${flags}
+ else
+ add_arg --target ${triple}
+ fi
+}