[compiler-rt] a49795d - [profile] Third speculative fix for Windows after D68351
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 16:36:48 PDT 2019
Author: Vedant Kumar
Date: 2019-10-31T16:35:58-07:00
New Revision: a49795d8abcf8bf5d38b6ba4e665559c30eb3e62
URL: https://github.com/llvm/llvm-project/commit/a49795d8abcf8bf5d38b6ba4e665559c30eb3e62
DIFF: https://github.com/llvm/llvm-project/commit/a49795d8abcf8bf5d38b6ba4e665559c30eb3e62.diff
LOG: [profile] Third speculative fix for Windows after D68351
_putenv on Windows takes 1 argument, whereas setenv elsewhere takes 3.
Just treat the two platforms differently.
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/53547
Added:
Modified:
compiler-rt/lib/profile/InstrProfilingFile.c
compiler-rt/lib/profile/InstrProfilingPort.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c
index e2253de8eda2..d722b86f7c42 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -337,6 +337,8 @@ static int writeOrderFile(const char *OutputName) {
return RetVal;
}
+#define LPROF_INIT_ONCE_ENV "__LLVM_PROFILE_RT_INIT_ONCE"
+
static void truncateCurrentFile(void) {
const char *Filename;
char *FilenameBuf;
@@ -357,11 +359,14 @@ static void truncateCurrentFile(void) {
/* Only create the profile directory and truncate an existing profile once.
* In continuous mode, this is necessary, as the profile is written-to by the
* runtime initializer. */
- const char *lprofInitOnceEnv = "__LLVM_PROFILE_RT_INIT_ONCE";
- int initialized = getenv(lprofInitOnceEnv) != NULL;
+ int initialized = getenv(LPROF_INIT_ONCE_ENV) != NULL;
if (initialized)
return;
- setenv(lprofInitOnceEnv, lprofInitOnceEnv, 1);
+#if defined(_WIN32)
+ _putenv(LPROF_INIT_ONCE_ENV "=" LPROF_INIT_ONCE_ENV);
+#else
+ setenv(LPROF_INIT_ONCE_ENV, LPROF_INIT_ONCE_ENV, 1);
+#endif
createProfileDir(Filename);
diff --git a/compiler-rt/lib/profile/InstrProfilingPort.h b/compiler-rt/lib/profile/InstrProfilingPort.h
index ceafdb9783f2..9462cf1a240f 100644
--- a/compiler-rt/lib/profile/InstrProfilingPort.h
+++ b/compiler-rt/lib/profile/InstrProfilingPort.h
@@ -105,7 +105,6 @@ static inline size_t getpagesize() {
GetNativeSystemInfo(&S);
return S.dwPageSize;
}
-#define setenv _putenv
#else /* defined(_WIN32) */
#include <unistd.h>
#endif /* defined(_WIN32) */
More information about the llvm-commits
mailing list