Add option to enable clang Asan build. 05/162905/4
authorKonstantin Baladurin <k.baladurin@partner.samsung.com>
Wed, 6 Dec 2017 06:18:22 +0000 (09:18 +0300)
committerKonstantin Baladurin <k.baladurin@partner.samsung.com>
Fri, 8 Dec 2017 08:14:53 +0000 (11:14 +0300)
Now we can add '--define "asan_enabled 1"' option for gbs to enable
Asan build.

Change-Id: Iac347386c26e3a72aa1275c312550df809aff003

NativeLauncher/CMakeLists.txt
packaging/dotnet-launcher.spec

index 6d78c6f..166e542 100644 (file)
@@ -52,14 +52,21 @@ IF(NOT_USE_FUNCTION)
 ENDIF(NOT_USE_FUNCTION)
 
 
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread -std=c++11 -Wl,--no-as-needed -ggdb")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread -std=c++11 -ggdb")
 #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D_FILE_OFFSET_BITS=64")
 #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHING_TIME_MEASURE")
 
+IF(ASAN_ENABLED)
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fno-omit-frame-pointer -fsanitize=address")
+ELSE(ASAN_ENABLED)
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs")
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,--no-as-needed")
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,--gc-sections")
+ENDIF(ASAN_ENABLED)
+
 SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g")
 SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
@@ -129,4 +136,4 @@ IF(NOT DEFINED NO_TIZEN)
     INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR})
     INSTALL(FILES dotnet.launcher DESTINATION ${LOADERDIR})
     INSTALL(FILES dotnet.debugger DESTINATION ${LOADERDIR})
-ENDIF(NOT DEFINED NO_TIZEN)
+ENDIF(NOT DEFINED NO_TIZEN)
\ No newline at end of file
index 369d243..66bb45d 100644 (file)
@@ -20,6 +20,11 @@ BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: aul-devel
 BuildRequires: dotnet-build-tools
 
+%if 0%{?asan_enabled}
+BuildRequires: clang >= 3.8
+BuildRequires: compiler-rt
+%endif
+
 Requires: aul
 Requires: launchpad
 
@@ -52,8 +57,24 @@ Launchpad plugin for launching dotnet apps
 %endif
 
 %build
+
+%if 0%{?asan_enabled}
+%define _dotnet_build_conf Debug
+export CFLAGS=" --target=%{_host} "
+export CXXFLAGS=" --target=%{_host} "
+%ifarch %{ix86}
+export CFLAGS=$(echo $CFLAGS | sed -e 's/--target=i686/--target=i586/')
+export CXXFLAGS=$(echo $CXXFLAGS | sed -e 's/--target=i686/--target=i586/')
+%endif
+%endif
+
 cmake \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+%if 0%{?asan_enabled}
+       -DCMAKE_C_COMPILER=clang \
+       -DCMAKE_CXX_COMPILER=clang++ \
+       -DASAN_ENABLED=TRUE \
+%endif
        -DPACKAGE_NAME=%{name} \
        -DLIBDIR=%{_libdir} \
        -DBINDIR=%{_bindir} \