Add GCC log wrapper 95/169295/8
authorOleg Ogurtsov <o.ogurtsov@samsung.com>
Mon, 5 Feb 2018 13:05:29 +0000 (16:05 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Fri, 28 Dec 2018 10:44:09 +0000 (10:44 +0000)
Change-Id: I304ad9af069ffe133d23e798a2ce707704ed5dd2

packaging/cc1 [new file with mode: 0755]
packaging/gcc-contrib.spec

diff --git a/packaging/cc1 b/packaging/cc1
new file mode 100755 (executable)
index 0000000..7d27eef
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+#echo "test 0" > /tmp/0000.log
+# Test 1:
+#exec $0.orig $@
+# Test 2:
+#$0.orig $@
+#RET=$?
+#exit $RET
+
+BASENAME_WRAPPER=/tmp/`basename $0`.$$.log
+# Note 1: Below does not works in the build root
+#BASENAME_WRAPPER=/tmp/`basename $0`.$BASHPID.log
+
+# Warning: only for debug, else it's linkage error for compile option '-o -' output to stdout
+#echo "$0 $@" >> $BASENAME_WRAPPER
+
+# Note 2: Inject additional params is incorrect - it's does not works with autotool tests
+#DUMPBASE_PARAM=`echo "$@"|sed -rn "s|\-dumpbase ([^ ]*) |\-dumpbase \1 -Wall -Wprint-abs-path |p"`
+
+DUMPBASE_OUT=`echo "$@" | grep -e "\-dumpbase \+\-" -e "\-dumpbase \+null" -e "\-o \+/dev/null"`
+#echo "DUMPBASE_OUT=$DUMPBASE_OUT" >> $BASENAME_WRAPPER
+[ "x$DUMPBASE_OUT" != "x" ] && BASENAME_WRAPPER=/dev/null
+
+# Note 3: Below does not works, stdout may be redefined
+#$0.orig $@ |& tee -a $BASENAME_WRAPPER
+#$0.orig $@ | tee -a $BASENAME_WRAPPER 1>&2
+
+# See note 2
+# $0.orig $DUMPBASE_PARAM 2>> $BASENAME_WRAPPER
+
+# Note 3: Below does not works in the SVACE environment
+#         The SVACE tool can't capture the data if a wrapper is symlink
+#exec $0.orig $@ 2>> $BASENAME_WRAPPER
+
+$0.orig $@ 2>> $BASENAME_WRAPPER
+RET=$?
+cat $BASENAME_WRAPPER >&2
+exit $RET
index c6177d8..1be2f2d 100644 (file)
@@ -77,6 +77,7 @@ Source24: lsan.supp
 Source25: TSAN_OPTIONS
 Source26: macros.asan
 Source27: ESAN_OPTIONS
+Source28: cc1
 Group:         Development/Building
 Summary:       GCC related scripts
 License:       MIT
@@ -493,6 +494,45 @@ BuildArch:  noarch
 %description -n sanitizer-sources
 Sanitizer family tools sources for external tools.
 
+%package -n gcc-log-wrapper
+Summary:    GCC wrapper for logs saving
+Group:      Development/Tools
+BuildArch:  noarch
+Requires:   gcc
+
+%description -n gcc-log-wrapper
+GCC wrapper for logs saving
+
+%post -n gcc-log-wrapper
+# Warning: below for SVACE tool - it can't capture the data if a wrapper is symlink
+PATHCC1=$(gcc -v 2>&1|grep COLLECT_LTO_WRAPPER|sed 's/COLLECT_LTO_WRAPPER=//') ; \
+PATHCC1=$(dirname $PATHCC1) ; \
+if [ ! -f $PATHCC1/cc1.orig ] ; then \
+  mv $PATHCC1/cc1{,.orig} ; \
+else \
+  rm $PATHCC1/cc1 ; \
+fi ; \
+if [ ! -f $PATHCC1/cc1plus.orig ] ; then \
+  mv $PATHCC1/cc1plus{,.orig} ; \
+else \
+  rm $PATHCC1/cc1plus ; \
+fi ; \
+ln /usr/lib/gcc-log-wrapper/cc1 $PATHCC1/cc1 ; \
+ln /usr/lib/gcc-log-wrapper/cc1 $PATHCC1/cc1plus
+
+%preun -n gcc-log-wrapper
+PATHCC1=$(gcc -v 2>&1|grep COLLECT_LTO_WRAPPER|sed 's/COLLECT_LTO_WRAPPER=//') ; \
+PATHCC1=$(dirname $PATHCC1) ; \
+if [ -f $PATHCC1/cc1.orig ] ; then \
+  rm -f $PATHCC1/cc1 ; \
+  mv $PATHCC1/cc1{.orig,} ; \
+fi ; \
+if [ -f $PATHCC1/cc1plus.orig ] ; then \
+  rm -f $PATHCC1/cc1plus ; \
+  mv $PATHCC1/cc1plus{.orig,} ; \
+fi
+
+
 %prep
 
 %build
@@ -532,6 +572,9 @@ install -m 0644 %{SOURCE22} %{buildroot}/%{_rpmconfigdir}/
 install -m 0644 %{SOURCE26} %{buildroot}/%{_rpmconfigdir}/
 install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/
 
+mkdir -p %{buildroot}/usr/lib/gcc-log-wrapper
+install -m 0755 %{SOURCE28} %{buildroot}/usr/lib/gcc-log-wrapper/
+
 %files
 #%manifest gcc-contrib.manifest
 
@@ -629,4 +672,8 @@ install -m 0755 %{SOURCE23} %{buildroot}/%{_rpmconfigdir}/tizen/
 %defattr(-,root,root,-)
 %{_prefix}/bin/asan_symbolize.py
 
+%files -n gcc-log-wrapper
+%defattr(-,root,root,-)
+/usr/lib/gcc-log-wrapper/cc1
+
 %changelog