From d2e1cb779d82a21d2ee0d33f77f4692c5955342f Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 13 Apr 2006 21:42:16 +0000 Subject: [PATCH] tau for windows --- dtool/Config.Win32.pp | 6 +++ dtool/Config.pp | 2 +- dtool/pptempl/Global.gmsvc.pp | 22 +++++++++-- dtool/pptempl/Global.pp | 7 +++- dtool/pptempl/Template.gmsvc.pp | 66 ++++++++++++++++++++++++++----- dtool/pptempl/Template.unix.pp | 2 +- dtool/pptempl/compilerSettings.pp | 15 ++----- dtool/src/dtoolbase/pvector.h | 8 ---- 8 files changed, 92 insertions(+), 36 deletions(-) diff --git a/dtool/Config.Win32.pp b/dtool/Config.Win32.pp index 64f4a5d82e..2ff882be43 100644 --- a/dtool/Config.Win32.pp +++ b/dtool/Config.Win32.pp @@ -10,6 +10,9 @@ // NSPR versions prior to 4.4 used _declspec instead of __declspec. #define SYSTEM_IGATE_FLAGS -longlong __int64 -D_X86_ -DWIN32_VC -D"_declspec(param)=" -D"__declspec(param)=" -D_near -D_far -D__near -D__far -D_WIN32 -D__stdcall -Dvolatile= +// Additional flags to pass to the Tau instrumentor. +#define TAU_INSTRUMENTOR_FLAGS -DWIN32_VC -D_WIN32 -D__cdecl= -D__stdcall= -D__fastcall= -D__i386 -D_MSC_VER=1310 -D_W64= -D_INTEGRAL_MAX_BITS=64 --exceptions --late_tiebreaker --no_class_name_injection --no_warnings --restrict --microsoft --new_for_init + // Is the platform big-endian (like an SGI workstation) or // little-endian (like a PC)? Define this to the empty string to // indicate little-endian, or nonempty to indicate big-endian. @@ -134,6 +137,9 @@ // Must global operator new and delete functions throw exceptions? #define GLOBAL_OPERATOR_NEW_EXCEPTIONS +// MSVC7 does support the latest STL allocator definitions. +#define USE_STL_ALLOCATOR 1 + // can Intel C++ build this directory successfully (if not, change CC to msvc) #define NOT_INTEL_BUILDABLE false diff --git a/dtool/Config.pp b/dtool/Config.pp index 2c05d3a3ce..c3fccfb4ca 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -645,7 +645,7 @@ // The Tau profiler provides a multiplatform, thread-aware profiler. // To use it, define TAU_MAKEFILE appropriately, define USE_TAU to 1, // and rebuild the code with ppremake; make install. -#define TAU_MAKEFILE /usr/local/tau/i386_linux/lib/Makefile.tau-pthread-pdt +#define TAU_MAKEFILE #define TAU_OPTS -optKeepFiles #define TAU_CFLAGS -D_GNU_SOURCE #define USE_TAU diff --git a/dtool/pptempl/Global.gmsvc.pp b/dtool/pptempl/Global.gmsvc.pp index 329fa11e71..801c931b57 100644 --- a/dtool/pptempl/Global.gmsvc.pp +++ b/dtool/pptempl/Global.gmsvc.pp @@ -80,6 +80,8 @@ #defer CDEFINES_OPT3 $[dlink_all_static] $[EXTRA_CDEFS] #defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] $[EXTRA_CDEFS] +#defer cdefines $[CDEFINES_OPT$[OPTIMIZE]] + // Opt1 /GZ disables OPT flags, so make sure its OPT1 only #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPT1FLAGS] #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] $[COMMONFLAGS] $[DEBUGFLAGS] $[OPTFLAGS] @@ -121,8 +123,20 @@ // the defining extra_cflags in individual sources.pp's will not picked up. use END_FLAGS instead #defer extra_cflags /EHsc /Zm500 /DWIN32_VC /DWIN32 $[WARNING_LEVEL_FLAG] $[END_CFLAGS] -#defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH]] -#defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] "$[osfilename $[source]]" +#if $[direct_tau] +#define tau_ipath $[ROOT_TAU]/include +#define tau_cflags /DPROFILING_ON /DTAU_STDCXXLIB +#define tau_lpath $[ROOT_TAU]/lib/VC7 +#define tau_libs tau-profile-static-mt.lib +#else // direct_tau +#define tau_ipath +#define tau_cflags +#define tau_lpath +#define tau_libs +#endif // direct_tau + +#defer DECYGWINED_INC_PATHLIST_ARGS $[decygwin %,/I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH] $[tau_ipath]] +#defer MAIN_C_COMPILE_ARGS /nologo /c $[DECYGWINED_INC_PATHLIST_ARGS] $[flags] $[extra_cflags] $[tau_cflags] "$[osfilename $[source]]" #defer COMPILE_C $[COMPILER] /Fo"$[osfilename $[target]]" $[MAIN_C_COMPILE_ARGS] #defer COMPILE_C++ $[COMPILE_C] @@ -148,10 +162,10 @@ //#defer ver_resource $[directory]\ver.res //#defer SHARED_LIB_C link /nologo /dll /VERBOSE:LIB $[LDFLAGS_OPT$[OPTIMIZE]] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] -#defer SHARED_LIB_C $[LINKER] /nologo /DLL $[LINKER_DEF_FILE_ARG] $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] +#defer SHARED_LIB_C $[LINKER] /nologo /DLL $[LINKER_DEF_FILE_ARG] $[LDFLAGS_OPT$[OPTIMIZE]] $[DLLBASEARG] /OUT:"$[osfilename $[target]]" $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH] $[tau_lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] $[tau_libs] #defer SHARED_LIB_C++ $[SHARED_LIB_C] -#defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]" +#defer LINK_BIN_C $[LINKER] /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath] $[EXTRA_LIBPATH] $[tau_lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] $[tau_libs] /OUT:"$[osfilename $[target]]" #defer LINK_BIN_C++ $[LINK_BIN_C] #if $[ne $[LINK_ALL_STATIC],] diff --git a/dtool/pptempl/Global.pp b/dtool/pptempl/Global.pp index 8045f2b166..50ad0252a5 100644 --- a/dtool/pptempl/Global.pp +++ b/dtool/pptempl/Global.pp @@ -331,7 +331,12 @@ // the target is not to be built. #defer build_target $[BUILD_TARGET] -#if $[USE_TAU] +// If we have USE_TAU but not TAU_MAKEFILE, we invoke the tau +// instrumentor and compiler directly. +#define direct_tau $[and $[USE_TAU],$[not $[TAU_MAKEFILE]]] + +#if $[and $[USE_TAU],$[TAU_MAKEFILE]] + // Use the makefile-based rules to run the tau instrumentor. #defer compile_c $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[COMPILE_C] $[TAU_CFLAGS] #defer compile_c++ $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[COMPILE_C++] $[TAU_CFLAGS] $[TAU_C++FLAGS] #defer link_bin_c $(TAU_COMPILER) $[TAU_OPTS] $[if $[SELECT_TAU],-optTauSelectFile=$[SELECT_TAU]] $[LINK_BIN_C] $[TAU_CFLAGS] diff --git a/dtool/pptempl/Template.gmsvc.pp b/dtool/pptempl/Template.gmsvc.pp index 592b8d7ee9..2c8e3d7149 100644 --- a/dtool/pptempl/Template.gmsvc.pp +++ b/dtool/pptempl/Template.gmsvc.pp @@ -234,6 +234,9 @@ $[TAB] rm -f $[patsubst %.yxx,%.cxx %.h,$[yxx_st_sources]] $[patsubst %.lxx,%.cx #if $[py_sources] $[TAB] rm -f *.pyc *.pyo // Also scrub out old generated Python code. #endif +#if $[USE_TAU] +$[TAB] rm -f *.il *.pdb *.inst.* // scrub out tau-generated files. +#endif // 'cleanall' is intended to undo all the effects of running ppremake // and building. It removes everything except the Makefile. @@ -380,16 +383,16 @@ $[TAB] mkdir -p $[tmpdirname_cyg] // this dir-creation-stuff is leftover from $[TAB] cl /nologo /EP "$[dtool_ver_dir]\verdate.cpp" > "$[tmpdirname_win]\verdate.h" $[TAB] rc /n /I"$[tmpdirname_win]" $[DECYGWINED_INC_PATHLIST_ARGS] /fo$[VER_RESOURCE] $[filter /D%, $[flags]] "$[dtool_ver_dir]\version.rc" #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]] -$[TAB] $[SHARED_LIB_C++] $[VER_RESOURCE] +$[TAB] $[shared_lib_c++] $[VER_RESOURCE] #else -$[TAB] $[SHARED_LIB_C] $[VER_RESOURCE] +$[TAB] $[shared_lib_c] $[VER_RESOURCE] #endif #else .NOTPARALLEL $[target] : $[sources] $[DLLBASEADDRFILENAME:%=$[dtool_ver_dir_cyg]/%] #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]] -$[TAB] $[SHARED_LIB_C++] +$[TAB] $[shared_lib_c++] #else -$[TAB] $[SHARED_LIB_C] +$[TAB] $[shared_lib_c] #endif #endif @@ -506,9 +509,9 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]] #define sources $($[varname]) $[target] : $[sources] $[static_lib_dependencies] $[GENERATED_SOURCES] #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]] -$[TAB] $[SHARED_LIB_C++] $[COMPILED_RESOURCES] +$[TAB] $[shared_lib_c++] $[COMPILED_RESOURCES] #else -$[TAB] $[SHARED_LIB_C] $[COMPILED_RESOURCES] +$[TAB] $[shared_lib_c] $[COMPILED_RESOURCES] #endif #if $[build_dlls] @@ -670,9 +673,9 @@ $[TAB] $[ld] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] #else // Otherwise, we can use the normal linker. #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]] -$[TAB] $[LINK_BIN_C++] +$[TAB] $[link_bin_c++] #else -$[TAB] $[LINK_BIN_C] +$[TAB] $[link_bin_c] #endif #endif @@ -736,9 +739,9 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]] #define sources $($[varname]) $[target] : $[sources] $[static_lib_dependencies] #if $[filter %.cxx %.cpp %.yxx %.lxx,$[get_sources]] -$[TAB] $[LINK_BIN_C++] +$[TAB] $[link_bin_c++] #else -$[TAB] $[LINK_BIN_C] +$[TAB] $[link_bin_c] #endif #end noinst_bin_target test_bin_target test_lib_target @@ -817,9 +820,31 @@ $[TAB] cp $[target_prebuilt] $[target] #set ipath . $[ipath] #endif +#if $[not $[direct_tau]] + $[target] : $[source] $[get_depends $[source]] +$[TAB] $[compile_c] + +#else // direct_tau +// This version is used to invoke the tau compiler directly. +#define il_source $[source].il +#define pdb_source $[source].pdb // Not to be confused with windows .pdb debugger info files. +#define inst_source $[source:%.c=%.inst.c] +$[il_source] : $[source] +$[TAB] $[TAU_MAKE_IL] + +$[pdb_source] : $[il_source] +$[TAB] $[TAU_MAKE_PDB] + +$[inst_source] : $[pdb_source] +$[TAB] $[TAU_MAKE_INST] -c + +$[target] : $[inst_source] $[get_depends $[source]] +#define source $[inst_source] $[TAB] $[COMPILE_C] +#endif // direct_tau + #end file // Rules to compile C++ files. @@ -835,11 +860,32 @@ $[TAB] $[COMPILE_C] #set ipath . $[ipath] #endif +#if $[not $[direct_tau]] // Yacc must run before some files can be compiled, so all files // depend on yacc having run. $[target] : $[source] $[get_depends $[source]] $[yxx_sources:%.yxx=%.h] +$[TAB] $[compile_c++] + +#else // direct_tau +// This version is used to invoke the tau compiler directly. +#define il_source $[source].il +#define pdb_source $[source].pdb // Not to be confused with windows .pdb debugger info files. +#define inst_source $[source:%.cxx=%.inst.cxx] +$[il_source] : $[source] $[yxx_sources:%.yxx=%.h] +$[TAB] $[TAU_MAKE_IL] + +$[pdb_source] : $[il_source] +$[TAB] $[TAU_MAKE_PDB] + +$[inst_source] : $[pdb_source] +$[TAB] $[TAU_MAKE_INST] -c++ + +$[target] : $[inst_source] $[get_depends $[source]] +#define source $[inst_source] $[TAB] $[COMPILE_C++] +#endif // direct_tau + #end file #end metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target diff --git a/dtool/pptempl/Template.unix.pp b/dtool/pptempl/Template.unix.pp index 8ab7e2240b..f9eaa1914a 100644 --- a/dtool/pptempl/Template.unix.pp +++ b/dtool/pptempl/Template.unix.pp @@ -178,7 +178,7 @@ #### Generated automatically by $[PPREMAKE] $[PPREMAKE_VERSION] from $[SOURCEFILE]. ################################# DO NOT EDIT ########################### -#if $[USE_TAU] +#if $[and $[USE_TAU],$[TAU_MAKEFILE]] include $[TAU_MAKEFILE] #endif diff --git a/dtool/pptempl/compilerSettings.pp b/dtool/pptempl/compilerSettings.pp index f6194d4454..dfc9fd391b 100644 --- a/dtool/pptempl/compilerSettings.pp +++ b/dtool/pptempl/compilerSettings.pp @@ -47,23 +47,12 @@ // ensure pdbs are copied to install dir #define build_pdbs yes - #define STL_ALLOCATOR VC6 - #elif $[or $[eq $[USE_COMPILER], MSVC7], $[eq $[USE_COMPILER], MSVC7_1]] #define COMPILER cl #define LINKER link #define LIBBER lib - #if $[eq $[USE_COMPILER], MSVC7] - // What is the syntax of the STL allocator declaration? See - // LocalSetup.pp for allowable values. - #define STL_ALLOCATOR MODERN - #else - // until I figure out how to get rid of 'rebind' vc7.1 C4346 build errors - #define STL_ALLOCATOR UNKNOWN - #endif - #if $[eq $[NO_CROSSOBJ_OPT],] #define DO_CROSSOBJ_OPT 1 #endif @@ -234,3 +223,7 @@ #define END_CFLAGS $[END_CFLAGS] /E #endif +#defer tau_opts $[decygwin %,-I"%",$[EXTRA_INCPATH] $[ipath] $[WIN32_PLATFORMSDK_INCPATH] $[tau_ipath]] $[building_var:%=-D%] +#defer TAU_MAKE_IL $[ROOT_PDT]/Windows/bin/edgcpfe -o $[il_source] $[tau_opts] $[cdefines:%=-D%] $[TAU_INSTRUMENTOR_FLAGS] $[source] +#defer TAU_MAKE_PDB $[ROOT_PDT]/Windows/bin/taucpdisp $[il_source] > $[pdb_source] +#defer TAU_MAKE_INST $[ROOT_TAU]/bin/tau_instrumentor $[pdb_source] $[source] -o $[inst_source] diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 5160398aae..2e8dd20d07 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -49,14 +49,6 @@ public: pvector(size_type n) : base_class(n) { } pvector(size_type n, const Type &value) : base_class(n, value) { } pvector(const Type *begin, const Type *end) : base_class(begin, end) { } - -#ifdef USE_TAU - void - push_back(const TYPENAME base_class::value_type &x) { - TAU_PROFILE("pvector::push_back(const value_type &)", " ", TAU_USER); - base_class::push_back(x); - } -#endif // USE_TAU }; #endif // USE_STL_ALLOCATOR