Index: lib/profile/InstrProfilingFile.c =================================================================== --- lib/profile/InstrProfilingFile.c +++ lib/profile/InstrProfilingFile.c @@ -301,7 +301,7 @@ if (!NumPids++) { if (snprintf(PidChars, MAX_PID_SIZE, "%d", getpid()) <= 0) { PROF_WARN( - "Unable to parse filename pattern %s. Using the default name.", + "Unable to get pid for filename pattern %s. Using the default name.", FilenamePat); return -1; } @@ -310,7 +310,7 @@ if (!NumHosts++) if (COMPILER_RT_GETHOSTNAME(Hostname, COMPILER_RT_MAX_HOSTLEN)) { PROF_WARN( - "Unable to parse filename pattern %s. Using the default name.", + "Unable to get hostname for filename pattern %s. Using the default name.", FilenamePat); return -1; } Index: lib/profile/InstrProfilingPort.h =================================================================== --- lib/profile/InstrProfilingPort.h +++ lib/profile/InstrProfilingPort.h @@ -41,7 +41,23 @@ #define COMPILER_RT_MAX_HOSTLEN 128 #ifdef _MSC_VER -#define COMPILER_RT_GETHOSTNAME(Name, Len) gethostname(Name, Len) +#include +inline int compiler_rt_gethostname(LPSTR Name, int Len) { + TCHAR Buffer[256]; + DWORD BufferSize = sizeof(Buffer); + BOOL Result = GetComputerNameEx(ComputerNameDnsFullyQualified, Buffer, &BufferSize); + if (!Result) return -1; + if (WideCharToMultiByte(CP_UTF8, + 0, + Buffer, + BufferSize, + Name, + Len, + NULL, + NULL) == 0) return -1; + return 0; +} +#define COMPILER_RT_GETHOSTNAME(Name, Len) compiler_rt_gethostname(Name, Len) #elif defined(__ORBIS__) #define COMPILER_RT_GETHOSTNAME(Name, Len) ((void)(Name), (void)(Len), (-1)) #else