%post -n asan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %asan_force_options -fno-common
# Add ASan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n asan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
%package -n ubsan-force-options
%post -n ubsan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %ubsan_force_options
# Add UBSan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n ubsan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
%package -n ubsan-build-env
%post -n lsan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %lsan_force_options
# Add LSan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n lsan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
[ -d /emul/ ] && chmod a-w /emul/usr/bin/
%post -n asan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %asan_force_options -fno-common
# Add ASan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n asan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
%package -n ubsan-force-options
%post -n ubsan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %ubsan_force_options
# Add UBSan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n ubsan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
%package -n ubsan-build-env
%post -n lsan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %lsan_force_options
# Add LSan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n lsan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
[ -d /emul/ ] && chmod a-w /emul/usr/bin/
exit 1
fi
-FLAGS="$@"
-
if [ $(find $(dirname $0) -name \*-real | wc -l) -gt 0 ]; then
echo >&2 "$(basename $0): directory was already processed, aborting"
exit 1
fi
+FLAGS=""
+LD_FLAGS=""
+
+function divide_flags {
+ NEED_LIB_NAME="N"
+ for f in "$@"; do
+ case $f in
+ -l)
+ NEED_LIB_NAME="Y"
+ ;;
+
+ -l*)
+ LDFLAGS="$LDFLAGS $f"
+ ;;
+
+ -Wl,*)
+ LDFLAGS="$LDFLAGS ${f:4}"
+ ;;
+
+ *)
+ if [ "$NEED_LIB_NAME" = "Y" ]; then
+ LDFLAGS="$LDFLAGS -l$f"
+ NEED_LIB_NAME="N"
+ else
+ FLAGS="$FLAGS $f"
+ fi
+ esac
+ done
+}
+
case "$1" in
prepend)
shift
- PREFLAGS="$@"
+ divide_flags $@
+ PREFLAGS=$FLAGS
POSTFLAGS=
+ LD_PREFLAGS=$LDFLAGS
+ LD_POSTFLAGS=
;;
append)
shift
+ divide_flags $@
PREFLAGS=
- POSTFLAGS="$@"
+ POSTFLAGS=$FLAGS
+ LD_PREFLAGS=
+ LD_POSTFLAGS=$LDFLAGS
;;
*)
+ divide_flags $@
PREFLAGS=
- POSTFLAGS="$@"
+ POSTFLAGS=$FLAGS
+ LD_PREFLAGS=
+ LD_POSTFLAGS=$LDFLAGS
;;
esac
# Use readlink in order to follow symlinks if any
\$(readlink -f \$0)-real $PREFLAGS "\$@" $POSTFLAGS
else
- \$(readlink -f \$0)-real "\$@"
+ # -Wl,--tizen-no-force-options is used to tell collect2 to not add force
+ # options. It will be removed in collect2.
+ \$(readlink -f \$0)-real "\$@" -Wl,--tizen-no-force-options
fi
EOF
chmod +x $TMP
cp $TMP $tool
done
+LD_TMP=$(pwd)/ld_tmp.$$
+cat > $LD_TMP << EOF
+#!/bin/sh
+if ! echo "\$@" | grep -q -e \-\-tizen\-no\-force\-options; then
+ # Use readlink in order to follow symlinks if any
+ \$(readlink -f \$0)-real $LD_PREFLAGS "\$@" $LD_POSTFLAGS
+else
+ # Remove --tizen-no-force-options from the argument list
+ FLAGS=\$(echo \$@ | sed -e 's/--tizen-no-force-options//g')
+ \$(readlink -f \$0)-real \$FLAGS
+fi
+EOF
+chmod +x $LD_TMP
+
+find -L /usr/*/gcc -type f -a -perm -a=x -name 'collect2' | 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\+\+)$' | while read tool; do
+ find -L /emul -type f -a -perm -a=x | grep -E '(gcc|g\+\+|c\+\+|collect2)$' | while read tool; do
ln -sf $(basename $tool) $tool-real
done
fi
rm $TMP
+rm $LD_TMP
exit 1
fi
-find $(dirname $0) -name \*-real | while read tool_real; do
+find $(dirname $0) /usr/*/gcc -name \*-real | while read tool_real; do
tool=$(echo "$tool_real" | sed -e 's/-real$//')
mv $tool_real $tool
done
%post -n asan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %asan_force_options -fno-common
# Add ASan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n asan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
%package -n ubsan-force-options
%post -n ubsan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %ubsan_force_options
# Add UBSan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n ubsan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
%package -n ubsan-build-env
%post -n lsan-force-options
# Change mode to allow all users to run gcc-force/unforce-options
chmod a+w /usr/bin
-[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a+w %{libsubdir}
+[ -d /emul/ ] && chmod a+w /emul/usr/bin/ && chmod a+w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a+w
/usr/bin/gcc-force-options %lsan_force_options
# Add LSan-related macros
cat >> /usr/lib/rpm/tizen_macros << EOF
%preun -n lsan-force-options
# Restore read-only mode
chmod a-w /usr/bin
-[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/
+chmod a-w %{libsubdir}
+[ -d /emul/ ] && chmod a-w /emul/usr/bin/ && chmod a-w /emul/home/abuild/rpmbuild/BUILD/gcc-%{version}/obj/gcc/ \
+ && find -L /emul/usr/*/gcc -name 'collect2' | xargs dirname | xargs chmod a-w
/usr/bin/gcc-unforce-options
[ -d /emul/ ] && chmod a-w /emul/usr/bin/