Makes -fprofile-instr-generate and -fprofile-instr-use work with clang-cl so that profile-guided optimization can be used.
Details
Diff Detail
- Build Status
Buildable 1653 Build 1653: arc lint + arc unit
Event Timeline
lib/Driver/ToolChain.cpp | ||
---|---|---|
538 ↗ | (On Diff #79186) | Which code uses gethostname? The only places I find it are in Unix-specific #ifdefs. I'm mildly concerned that we're requiring a working network connection to do profiling. The winsock implementation of gethostname will fail if there is no active network connection (or a variety of other reasons). If you just need the name of the computer, it might be better to use GetComputerNameEx on Windows. |
lib/Driver/ToolChain.cpp | ||
---|---|---|
538 ↗ | (On Diff #79186) | Yeah, I don't like it, either. My guess is some code in compiler-rt uses gethostname to allow files to be named after the host. We might want to go in and change that, as you say, but it would be unrelated to this patch. |
lib/Driver/ToolChain.cpp | ||
---|---|---|
538 ↗ | (On Diff #79186) | But where is that code? I'm doing a tree-wide search, and I don't see a case where gethostbyname would be called on Windows. |
lib/Driver/ToolChain.cpp | ||
---|---|---|
538 ↗ | (On Diff #79186) | How about using #pragma comment(lib, "ws2_32") in the profiling runtime sources? It's a Windows-ism, but it has the nice property that it keeps the system library knowledge close to the site of the usage. |
lib/Driver/ToolChain.cpp | ||
---|---|---|
538 ↗ | (On Diff #79186) | I think it's probably line 44 in projects/compiler-rt/lib/profile/InstrProfilingPort.h |
lgtm modulo comment about -- in the test file.
Also I'd suggest phrasing the commit message in the imperative (and maybe drop the "make .. work on windows" now that the patch is really just about exposing the flags in clang-cl).
test/Driver/cl-options.c | ||
---|---|---|
62 | Please put -- before %s here and below (see note at the top of the file). |
Please put -- before %s here and below (see note at the top of the file).