summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2023-10-19 14:19:09 +0200
committerChristian Marangi <ansuelsmth@gmail.com>2023-10-20 16:13:31 +0200
commit28420cd67bc4c0fe5974ac0336528aea3a443b98 (patch)
tree85b10fe3d9ba60e6070a87e83bf83a6a7e4f7f9a /scripts
parentc0e30b17eb609cb37dc90abfee4ae008ec444ed4 (diff)
downloadopenwrt-28420cd67bc4c0fe5974ac0336528aea3a443b98.tar.gz
openwrt-28420cd67bc4c0fe5974ac0336528aea3a443b98.tar.bz2
openwrt-28420cd67bc4c0fe5974ac0336528aea3a443b98.zip
scripts/ext-toolchain: implement external GCC version detection
Some package may needs to enable compatibility option based on the GCC version. Currently the GCC version is set based on the default value and doesn't actually reflect the real value provided by the external toolchain if used. Fix this by correctly detecting the GCC version in the external toolchain and set the correct value in CONFIG_GCC_VERSION. A new option is added in menuconfig to manually set the GCC version if needed. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ext-toolchain.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh
index fe1024c18e..1fa2e952bb 100755
--- a/scripts/ext-toolchain.sh
+++ b/scripts/ext-toolchain.sh
@@ -27,6 +27,7 @@ CFLAGS=""
TOOLCHAIN="."
LIBC_TYPE=""
+GCC_VERSION=""
# Library specs
@@ -199,6 +200,19 @@ find_bins() {
return 1
}
+find_gcc_version() {
+ if [ -f $TOOLCHAIN/info.mk ]; then
+ GCC_VERSION=$(grep GCC_VERSION $TOOLCHAIN/info.mk | sed 's/GCC_VERSION=//')
+ return 0
+ fi
+
+ echo "Warning! Can't find info.mk, trying to detect with alternative way."
+
+ # Very fragile detection
+ GCC_VERSION=$(find $TOOLCHAIN/bin | grep -oE "gcc-[0-9]+\.[0-9]+\.[0-9]+$" | \
+ head -1 | sed 's/gcc-//')
+}
+
wrap_bin_cc() {
local out="$1"
@@ -383,6 +397,13 @@ print_config() {
return 1
fi
+ if [ -n "$GCC_VERSION" ]; then
+ echo "CONFIG_EXTERNAL_GCC_VERSION=\"$GCC_VERSION\"" >> "$config"
+ else
+ echo "Can't detect GCC version. Aborting!" >&2
+ return 1
+ fi
+
local lib
for lib in C RT PTHREAD GCC STDCPP SSP GFORTRAN GOMP; do
local file
@@ -564,6 +585,7 @@ while [ -n "$1" ]; do
--config)
if probe_cc; then
probe_libc
+ find_gcc_version
print_config "$1"
exit $?
fi