<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60523>60523</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[compiler-rt] -fprofile-instr-generate produces malformed .profraw files in all cases
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AndyGrant
</td>
</tr>
</table>
<pre>
Using llvm/clang/lld/compiler-rt built from source with gcc 8.1.0
An idea of the process I undertook to build:
```
cmake -G "MinGW Makefiles" -DLLVM_ENABLE_PROJECTS="clang;lld" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 ../llvm
cmake -G "MinGW Makefiles" ../compiler-rt -DLLVM_CONFIG_PATH=../build/bin/llvm-config.exe
```
```
$ cat temp.c
#include <stdio.h>
int main() {
printf("Hello, World");
}
$ clang temp.c --target=x86_64-pc-windows-gnu -fprofile-instr-generate -fuse-ld=lld -flto
$ ./a.exe
Hello, World
$ hexdump default.profraw -v
0000000 7281 6f66 7072 ff6c 0008 0000 0000 0000
0000010 0000 0000 0000 0000 0002 0000 0000 0000
0000020 0000 0000 0000 0000 0002 0000 0000 0000
0000030 0000 0000 0000 0000 000b 0000 0000 0000
0000040 efd1 ffff 0000 0000 4001 65db 7ff6 0000
0000050 0001 0000 0000 0000 0000 0000 0000 0000
0000060 0000 0000 0000 0000 d5fa e78d 6436 db95
0000070 0000 0000 0000 0000 efc8 ffff 0000 0000
0000080 0000 0000 0000 0000 0000 0000 0000 0000
0000090 0001 0000 0000 0000 0000 0000 0000 0000
00000a0 0000 0000 0000 0000 0000 0000 0000 0000
00000b0 0000 0000 0000 0000 0000 0000 0000 0100
00000c0 0000 0000 0000 0000 0000 0400 6d00 6961
00000d0 006e 0000 0000 0000
00000d8
```
Based on: https://github.com/llvm/llvm-project/blob/b72b56016a6b586a22a49f145c924c03e4239b1d/llvm/include/llvm/ProfileData/InstrProfData.inc#L121-L141 We can see that we this profraw has size=0 for many fields, including size of binary IDs, size of the data section, size of the counters section, the size of the names section. Perhaps more is malformed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVl1v27gS_TX0y0CCROrLD35wIjvNvUkbtOnt3SeDIoc2txRpiFTT7K9fUHYS10ja3RoGBc2cw5k5lg_Fvddbi7gg5QUp2xkfw84Ni6WVj1cDt2HWOfm4-Oy13YIx33pC18JwuyV0bYyMd67fa4NDMgToRm0CqMH14N04CIQHHXawFQKaNE8zkrUkWx7WpQUtkYNTEHYI-8EJ9B6uYbQSh-DcVwhu2lESduSQKjt-p1vR868IyRUQSm-1vfoCt_wrKm3QE0ohaW9u_ne7Wb1fXtysNncfP_xndXn_ibCWUHqYgV1MM0To5e3yv6vNxefrm3Zz_8fdirD2IxrkHp_2uV9-vFrdf9rcfzjACGv_31SQppMU3_rT4X7R2cQ5Fe5Y4vLD-_X11eZuef-OsHZCHQSg607bY51EOKv0NsXv-KoqrwdpAYIHCNjvU_EUY9oKM0oEwi59kNqlO8JWp9toG6DnsXZD6BxIfXGIAwDsB22DmjL0HRrjCL2EL26YJCV0TtgRTOr2h9ZiL1H_YzeQJIEPWwyEtd-balMVyV4kD9pK9-CTrR0hUfvBRfUSbX0Yki1aHHhASNToMYlPSGuMhESZ4M5LRRX5i1pnnZ6Bd_hdjv0eJCo-mpDGugN_gOTbAZMdPlDTJodKVRXUWU1BqUpAlmUNTNnn5YSUZ2e554W-TaK_Q2Jvkrq3SUUGqGQOSil1giqyLIeqlB3USlXnpHJC5W-Ve71S9TpKlooD1o2EqmAVyG5enpDq10moRHPW8gmp-UVTr5LmvzMT_51K3T8j5T-QxM-gRZZBJeMyr_ITkoyACt9uRTY_sZIL7lGCs4QtYRfC3kc_pmtC11sddmOXCtc_eeDRovaD-xNFiL5lXBcvNe3KKssrXnVlU3FKeTFXeVGKOS1ExrCgbN7l8mWfozW9BO4OFtDywAldX0cjiKF4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