diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/libprofile/CMakeLists.txt | 3 | ||||
-rw-r--r-- | runtime/libprofile/CommonProfiling.c | 22 | ||||
-rw-r--r-- | runtime/libprofile/Makefile | 9 | ||||
-rw-r--r-- | runtime/libprofile/Profiling.h | 2 |
4 files changed, 33 insertions, 3 deletions
diff --git a/runtime/libprofile/CMakeLists.txt b/runtime/libprofile/CMakeLists.txt index 414ad00..8609715 100644 --- a/runtime/libprofile/CMakeLists.txt +++ b/runtime/libprofile/CMakeLists.txt @@ -13,7 +13,8 @@ set_target_properties( profile_rt-static PROPERTIES OUTPUT_NAME "profile_rt" ) -add_llvm_loadable_module( profile_rt-shared ${SOURCES} ) +set(BUILD_SHARED_LIBS ON) +add_llvm_library( profile_rt-shared ${SOURCES} ) set_target_properties( profile_rt-shared PROPERTIES OUTPUT_NAME "profile_rt" ) diff --git a/runtime/libprofile/CommonProfiling.c b/runtime/libprofile/CommonProfiling.c index acc17ce..8f4119c 100644 --- a/runtime/libprofile/CommonProfiling.c +++ b/runtime/libprofile/CommonProfiling.c @@ -28,14 +28,35 @@ static char *SavedArgs = 0; static unsigned SavedArgsLength = 0; +static const char *SavedEnvVar = 0; static const char *OutputFilename = "llvmprof.out"; +/* check_environment_variable - Check to see if the LLVMPROF_OUTPUT environment + * variable is set. If it is then save it and set OutputFilename. + */ +static void check_environment_variable(void) { + const char *EnvVar; + if (SavedEnvVar) return; /* Guarantee that we can't leak memory. */ + + if ((EnvVar = getenv("LLVMPROF_OUTPUT")) != NULL) { + /* The string that getenv returns is allowed to be statically allocated, + * which means it may be changed by future calls to getenv, so copy it. + */ + SavedEnvVar = strdup(EnvVar); + OutputFilename = SavedEnvVar; + } +} + /* save_arguments - Save argc and argv as passed into the program for the file * we output. + * If either the LLVMPROF_OUTPUT environment variable or the -llvmprof-output + * command line argument are set then change OutputFilename to the provided + * value. The command line argument value overrides the environment variable. */ int save_arguments(int argc, const char **argv) { unsigned Length, i; + if (!SavedEnvVar && !SavedArgs) check_environment_variable(); if (SavedArgs || !argv) return argc; /* This can be called multiple times */ /* Check to see if there are any arguments passed into the program for the @@ -54,6 +75,7 @@ int save_arguments(int argc, const char **argv) { puts("-llvmprof-output requires a filename argument!"); else { OutputFilename = strdup(argv[1]); + if (SavedEnvVar) { free((void *)SavedEnvVar); SavedEnvVar = 0; } memmove((char**)&argv[1], &argv[2], (argc-1)*sizeof(char*)); --argc; } diff --git a/runtime/libprofile/Makefile b/runtime/libprofile/Makefile index d851149..6e92253 100644 --- a/runtime/libprofile/Makefile +++ b/runtime/libprofile/Makefile @@ -44,8 +44,15 @@ ifeq ($(HOST_OS),Darwin) # command line. DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/') ifneq ($(DARWIN_VERS),8) - LLVMLibsOptions := $(LLVMLibsOptions) \ + LLVMLibsOptions := $(LLVMLibsOptions) \ -Wl,-install_name \ -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)" endif + + # If we're doing an Apple-style build, add the LTO object path. + ifeq ($(RC_BUILDIT),YES) + TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/profile_rt-lto.XXXXXX) + LLVMLibsOptions := $(LLVMLibsOptions) \ + -Wl,-object_path_lto -Wl,$(TempFile) + endif endif diff --git a/runtime/libprofile/Profiling.h b/runtime/libprofile/Profiling.h index c6b9a4d..acc6399 100644 --- a/runtime/libprofile/Profiling.h +++ b/runtime/libprofile/Profiling.h @@ -15,7 +15,7 @@ #ifndef PROFILING_H #define PROFILING_H -#include "llvm/Analysis/ProfileInfoTypes.h" /* for enum ProfilingType */ +#include "llvm/Analysis/ProfileDataTypes.h" /* for enum ProfilingType */ /* save_arguments - Save argc and argv as passed into the program for the file * we output. |