Kaydet (Commit) eae3f52f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

New --disable-runtime-optimizations

...to better serve the needs of tools like -fsanitize=address

Change-Id: Ic2f2b981b2f5c1bc95ff91bc7a8d21fbb695dc8d
üst 6d14a2c2
...@@ -159,6 +159,7 @@ export ENABLE_PDFIMPORT=@ENABLE_PDFIMPORT@ ...@@ -159,6 +159,7 @@ export ENABLE_PDFIMPORT=@ENABLE_PDFIMPORT@
export ENABLE_RANDR=@ENABLE_RANDR@ export ENABLE_RANDR=@ENABLE_RANDR@
export ENABLE_RELEASE_BUILD=@ENABLE_RELEASE_BUILD@ export ENABLE_RELEASE_BUILD=@ENABLE_RELEASE_BUILD@
export ENABLE_REPORTBUILDER=@ENABLE_REPORTBUILDER@ export ENABLE_REPORTBUILDER=@ENABLE_REPORTBUILDER@
export ENABLE_RUNTIME_OPTIMIZATIONS=@ENABLE_RUNTIME_OPTIMIZATIONS@
export ENABLE_SCRIPTING_BEANSHELL=@ENABLE_SCRIPTING_BEANSHELL@ export ENABLE_SCRIPTING_BEANSHELL=@ENABLE_SCRIPTING_BEANSHELL@
export ENABLE_SCRIPTING_JAVASCRIPT=@ENABLE_SCRIPTING_JAVASCRIPT@ export ENABLE_SCRIPTING_JAVASCRIPT=@ENABLE_SCRIPTING_JAVASCRIPT@
export ENABLE_SDREMOTE=@ENABLE_SDREMOTE@ export ENABLE_SDREMOTE=@ENABLE_SDREMOTE@
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
* Whether we want to link as many object files as possible into one big object. * Whether we want to link as many object files as possible into one big object.
* True in case of --enable-lto or --enable-mergelibs. * True in case of --enable-lto or --enable-mergelibs.
*/ */
#define STATIC_LINKING 0 #define STATIC_LINKING 0
#define ENABLE_RUNTIME_OPTIMIZATIONS 0
#endif #endif
...@@ -967,6 +967,15 @@ AC_ARG_ENABLE(symbols, ...@@ -967,6 +967,15 @@ AC_ARG_ENABLE(symbols,
This enables -g compiler flag for GCC or equivalent, This enables -g compiler flag for GCC or equivalent,
without changing anything else compared to productive code.])) without changing anything else compared to productive code.]))
AC_ARG_ENABLE(runtime-optimizations,
AS_HELP_STRING([--disable-runtime-optimizations],
[Statically disable certain runtime optimizations (like rtl/alloc.h or
JVM JIT) that are known to interact badly with certain dynamic analysis
tools (like -fsanitize=address or Valgrind). By default, disabled iff
CC contains "-fsanitize=address". (For Valgrind, those runtime
optimizations are typcially disabled dynamically via
RUNNING_ON_VALGRIND.)]))
AC_ARG_ENABLE(compiler-plugins, AC_ARG_ENABLE(compiler-plugins,
AS_HELP_STRING([--enable-compiler-plugins], AS_HELP_STRING([--enable-compiler-plugins],
[Enable compiler plugins that will perform additional checks during [Enable compiler plugins that will perform additional checks during
...@@ -5624,6 +5633,30 @@ AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2) ...@@ -5624,6 +5633,30 @@ AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT2,$SAL_TYPES_ALIGNMENT2)
AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4) AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT4,$SAL_TYPES_ALIGNMENT4)
AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8) AC_DEFINE_UNQUOTED(SAL_TYPES_ALIGNMENT8,$SAL_TYPES_ALIGNMENT8)
dnl ===================================================================
dnl Check whether to enable runtime optimizations
dnl ===================================================================
ENABLE_RUNTIME_OPTIMIZATIONS=
AC_MSG_CHECKING([whether to enable runtime optimizations])
if test -z "$enable_runtime_optimizations"; then
for i in $CC; do
case $i in
-fsanitize=address)
enable_runtime_optimizations=no
break
;;
esac
done
fi
if test "$enable_runtime_optimizations" != no; then
ENABLE_RUNTIME_OPTIMIZATIONS=TRUE
AC_DEFINE(ENABLE_RUNTIME_OPTIMIZATIONS)
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_SUBST([ENABLE_RUNTIME_OPTIMIZATIONS])
dnl =================================================================== dnl ===================================================================
dnl Check if valgrind headers are available dnl Check if valgrind headers are available
dnl =================================================================== dnl ===================================================================
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <string.h> #include <string.h>
#include "boost/scoped_array.hpp" #include "boost/scoped_array.hpp"
#include "config_options.h"
#include "osl/diagnose.h" #include "osl/diagnose.h"
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
#include "rtl/ustrbuf.hxx" #include "rtl/ustrbuf.hxx"
...@@ -58,10 +59,13 @@ ...@@ -58,10 +59,13 @@
#ifdef ANDROID #ifdef ANDROID
#include <osl/detail/android-bootstrap.h> #include <osl/detail/android-bootstrap.h>
#else #else
#if defined HAVE_VALGRIND_HEADERS #if !ENABLE_RUNTIME_OPTIMIZATIONS
#define FORCE_INTERPRETED 1
#elif defined HAVE_VALGRIND_HEADERS
#include <valgrind/valgrind.h> #include <valgrind/valgrind.h>
#define FORCE_INTERPRETED RUNNING_ON_VALGRIND
#else #else
#define RUNNING_ON_VALGRIND 0 #define FORCE_INTERPRETED 0
#endif #endif
#endif #endif
...@@ -627,7 +631,7 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( ...@@ -627,7 +631,7 @@ javaPluginError jfw_plugin_startJavaVirtualMachine(
// Valgrind typically emits many false errors when executing JIT'ed JVM // Valgrind typically emits many false errors when executing JIT'ed JVM
// code, so force the JVM into interpreted mode: // code, so force the JVM into interpreted mode:
bool forceInterpreted = RUNNING_ON_VALGRIND > 0; bool forceInterpreted = FORCE_INTERPRETED > 0;
// Some testing with Java 1.4 showed that JavaVMOption.optionString has to // Some testing with Java 1.4 showed that JavaVMOption.optionString has to
// be encoded with the system encoding (i.e., osl_getThreadTextEncoding): // be encoded with the system encoding (i.e., osl_getThreadTextEncoding):
......
...@@ -20,7 +20,7 @@ $(eval $(call gb_Library_set_include,sal,\ ...@@ -20,7 +20,7 @@ $(eval $(call gb_Library_set_include,sal,\
)) ))
$(eval $(call gb_Library_add_defs,sal,\ $(eval $(call gb_Library_add_defs,sal,\
$(if $(filter $(ALLOC),SYS_ALLOC TCMALLOC JEMALLOC), \ $(if $(filter $(ALLOC),SYS_ALLOC TCMALLOC JEMALLOC)$(filter-out X$(ENABLE_RUNTIME_OPTIMIZATIONS),XTRUE), \
-DFORCE_SYSALLOC \ -DFORCE_SYSALLOC \
) \ ) \
$(if $(filter $(OS),IOS), \ $(if $(filter $(OS),IOS), \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment