Do not apply force-options to clang++ binary 28/193828/1 accepted/tizen/base/20181130.134818 submit/tizen_base/20181128.144839
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Mon, 26 Nov 2018 16:39:23 +0000 (19:39 +0300)
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Mon, 26 Nov 2018 16:47:51 +0000 (19:47 +0300)
"clang++" binary matches "(..|g\+\+|..)$" regex which was not intended for this:
this allows to pass gcc-speciefic options to clang driver resulting in build
errors due to unknown flags.

Fix pattern matching and refactor a bit.

Change-Id: I3fe0cb335f118e61e08399f6bed41232a0c84e17
Signed-off-by: Mikhail Kashkarov <m.kashkarov@partner.samsung.com>
packaging/gcc-force-options

index 5813d78..c8004d5 100644 (file)
@@ -94,7 +94,10 @@ fi
 EOF
 chmod +x $TMP
 
-find -L $(dirname $0) -type f -a -perm -a=x | grep -E '(gcc|g\+\+|c\+\+)$' | while read tool; do
+# Match gcc|g++|c++ with optional cross- preffix and -version ([0-9] and .) # suffix
+GCC_REG='\b(gcc|g\+\+|c\+\+)([-\d\.]?)+'
+
+find -L $(dirname $0) -type f -a -perm -a=x | grep -E "($GCC_REG)$" | while read tool; do
        mv $tool $tool-real
        cp $TMP $tool
 done
@@ -113,13 +116,15 @@ fi
 EOF
 chmod +x $LD_TMP
 
-find -L GCC_LIBSUBDIR -type f -a -perm -a=x -name 'collect2' | while read tool; do
+GCC_REG_EXTRA='collect2'
+
+find -L GCC_LIBSUBDIR -type f -a -perm -a=x -name "$GCC_REG_EXTRA" | while read tool; do
        mv $tool $tool-real
        cp $LD_TMP $tool
 done
 
 if [ -d /emul ]; then
-       find -L /emul -type f -a -perm -a=x | grep -E '(gcc|g\+\+|c\+\+|collect2)$' | while read tool; do
+       find -L /emul -type f -a -perm -a=x | grep -E "($GCC_REG|$GCC_REG_EXTRA)$" | while read tool; do
                ln -sf $(basename $tool) $tool-real
        done
 fi