<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/78125>78125</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
compiler-rt: call to undeclared function 'fdopen'; ISO C99 and later do not support implicit function declarations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AA1999
</td>
</tr>
</table>
<pre>
Hi, while compiling llvm with the following configuration:
```cmake
cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;cross-project-tests;flang;libc;libclc;lld;lldb;openmp;polly' -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_USE_LINKER=lld -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;compiler-rt;libunwind' -DLLVM_BUILD_DOCS=OFF -DLLVM_ENABLE_BINDINGS=OFF -DLIBCXX_CXX_ABI=libcxxabi
```
I get these errors:
```cpp
[3851/3865] Performing build step for 'runtimes'
[774/983] Building C object compiler-rt/lib/profile/CMakeFiles/clang_rt.profile-i386.dir/GCDAProfiling.c.o
FAILED: compiler-rt/lib/profile/CMakeFiles/clang_rt.profile-i386.dir/GCDAProfiling.c.o
/home/arshia/.clone/llvm-project/build/./bin/clang --target=x86_64-unknown-linux-gnu -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/.. -I/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/../../include -O3 -pipe -std=c17 -fPIC -fno-semantic-interposition -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O2 -g -DNDEBUG -m32 -fno-lto -fPIC -Wno-pedantic -DCOMPILER_RT_HAS_ATOMICS=1 -DCOMPILER_RT_HAS_FCNTL_LCK=1 -DCOMPILER_RT_HAS_UNAME=1 -nostdinc++ -MD -MT compiler-rt/lib/profile/CMakeFiles/clang_rt.profile-i386.dir/GCDAProfiling.c.o -MF compiler-rt/lib/profile/CMakeFiles/clang_rt.profile-i386.dir/GCDAProfiling.c.o.d -o compiler-rt/lib/profile/CMakeFiles/clang_rt.profile-i386.dir/GCDAProfiling.c.o -c /home/arshia/.clone/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c
/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:212:12: error: call to undeclared function 'strdup'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
212 | return strdup(orig_filename);
| ^
/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:212:12: note: did you mean 'strcmp'?
/usr/include/string.h:156:12: note: 'strcmp' declared here
156 | extern int strcmp (const char *__s1, const char *__s2)
| ^
/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:212:12: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'char *' [-Wint-conversion]
212 | return strdup(orig_filename);
| ^~~~~~~~~~~~~~~~~~~~~
/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:338:17: error: call to undeclared function 'fdopen'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
338 | output_file = fdopen(fd, mode);
| ^
/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:338:17: note: did you mean 'fopen'?
/usr/include/stdio.h:263:14: note: 'fopen' declared here
263 | extern FILE *fopen (const char *__restrict __filename,
| ^
/home/arshia/.clone/llvm-project/compiler-rt/lib/profile/GCDAProfiling.c:338:15: error: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct _IO_FILE *') from 'int' [-Wint-conversion]
338 | output_file = fdopen(fd, mode);
| ^ ~~~~~~~~~~~~~~~~
4 errors generated.
```
I have the full log here: https://paste.ofcode.org/r8Xsncf2Sg6KGacvAttiQL
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWFtzozgW_jXyi0ouWzK-PPgBjMmw7Us2dm9mnyiBBNa0kFhJ5LIP-9u3BHbiTme6qrsm01QCWNI5OufT9x0Q1FpRKc6XIIhAEA9o607aLMNwvFgsBrlmz8vfBMAr-HgSksNC142QQlVQyocaPgp3gu7EYaml1I--vdCqFFVrqBNaARKCUQxGIZiO-r-ipl9439bdQnToXaEI5q2QDKIbuBPqDwpRvNn8a5utd2G0WWe3d_t_rFfHAyAxwLNCUlUBEnVX5LSWFvEnZ6hvM9pa1Bj9By8cctw6C0hUni2kyIvzRXY3kvXnHJBIN1zVDSBRo6V8BngGUbzahp_WWfQ53cTZ8d-3a0DiOy7vhTvFPE9Vqd8EGh4O67tjut_5UPe7S-_nwzrbpLtP6ztAYunz_Mrq7vPumG7X5_R8dE9P5zCfnmgufF4d9twg4_qeVj0KxfooO199kPF-1U2dJG_miNJdnO5urjrTaPX775n_D6PUx_Uy3derdv7ZnVNYcecX3XLIjdHGvq7ym7VumnNLEJF5MAY4IfNpAIIY3nJTalN7wvSrbh1vYKkNBHhmWuVEzS3Asxf72WwCcLKYE28deRNvu4I696sMr7HBiRQ5wEljdCkkBzhZbekXngjpXSYdZTLjhud-JMh8OmTCAJzcrOLwtmsWqhoWQ93Pn4TpZh0DEn7YPPCcKE5OuvauqLEnQQFOhoXUyrd4lVxYDXDSweb7_b1QlwkhQo6aijtA4qf5NJtOUKu-KP2okBSqfUKVaiGKs3gdfb7xNzdnErzS1rdmh2O8ylb73eEY7o7ZNlzd7a86kv3dNvy2eZNu09fW9Aey-T6uw-Ff6-1yEqqQLeMQ7QlEjWg4RNYxQOJiPIOovE1XEJVKI8tr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