<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57560>57560</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Bazel Build: undefined symbol: environ
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Amzo
</td>
</tr>
</table>
<pre>
When building llvm with Bazel on FreeBSD the follow symbol is considered undefined:
`ld: error: undefined symbol: environ`
However, in FreeBSD the environ symbol is not defined in libc.so.7, but it exists in crt1.o.
`readelf -s work-bazel-out/k8-opt/bin/external/llvm-project/llvm/libSupport.pic.a | grep environ`
outputs the following
`99: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND environ`
environ is used in the file:
`grep environ llvm/lib/Support/Unix/Program.inc`
Shows this:
`extern char **environ;`
Which is the correct declaration.
Compiling a simple test program and compiling without Bazel shows:
`
extern char **environ;
int main() {
return 0;
}
`
Results in the environ symbol shown as:
`readelf -s a.out | grep environ
5: 0000000000203aa0 8 OBJECT GLOBAL DEFAULT 24 environ
`
So either BAzel is building something it shouldn't on FreeBSD as building with cmake is fine, or the symbols are being hidden somewhere.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVE1v2zAM_TX2hYjh2HUcH3xImnbDULTF2qLYUbaYWKssGZLctPv1o5yk-Wo3w5CZiCIfH59Yaf5ePjeooOqF5EKtQMrXFtbCNTBnf1CCVnBtEOcPC3ANwlJLqddg39tKSxAWaq2s4GiQQ684LoVCHqSzIF4E8W6dxNL_B2iMNt748NwGGjbVqzBakfPh2e96ja9oguQSxDGSrf8BFKUd7OKSsxRVHVkd5f5w1TsQDvBNWGf9bm3cONLRCU6DjKNcwsjCWpuXUeU5GOneBcn1y3SkO29UQtGKbw6NYpJMz9moM_o31m77039E9dB3nTYu6kQdMYAgv4SVwe6LWilN1xO6Pc_UkBOAReG5ik8e8E8Mt3ePv-6vAL7d3M1nN7C4up493TwCPN0uvki5I5HY6-2GtiG7kHjexEPoAPsqad0WStaTEm_0uTd6ZVgbCVWfpHxo9NrXKOw-wyTesAl1wwwEyYzeHeB0fhLguRF14xF7pLU2hlinvteSGeaEVkc9vdRtJ6QXNgMr2k4iOLQOug0-YIpTjJ2P1z11YSt965Ge07Bl7l-ADw4I5aBlXjHTIClIAttd3zGDrqcY8f5IvjhJs1l_ou3lRrefSN_jVMA-gXogZxb5ws4U-IEFsmNhJXHK2EZYU7ib_7i6fDwXFiQXx5FOe60BiVI0MJ95RqlpH4PG6hZJBWTRvaQSesmJpNwdThx24D_MpLplL-jD-Fvu77U2AyMbJqhKg1Chd28E5zTXfJY1AcAoxHI8mSRpPsmKNORlyou0YKETTmK5afjc5_rPfAp7I8vGuW6gO7mmd0XI-ioiGR1c_uORIKzt0ZKR5dkkDpuSFRdZgSzN6jpf8ryYsiweM87TosomS8RQsgqlLYNsHiSJwjUMIcgOskUoyiROkriIs_F4PEnTaMyyuiiqJJku4xx5HlzESKqTkccRabMKTTlAqvqVpU3px-B-k1krVgpxSEfxWU_3wJSz9o8Oh7zlgPsvYmbsVw">