You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix --target cflag on FreeBSD when compiling against clang
Clang does not/did not support being invoked with a target triple that does not
contain at least the major os version tacked on to the end, and will fail to
find standard library headers if it's not present [0].
e.g. invoking `clang++` with `--target=x86_64-unknown-freebsd` may present
errors like
```
warning: In file included from src/cxx.cc:1:
warning: src/../include/cxx.h:2:10: fatal error: 'algorithm' file not found
warning: #include <algorithm>
warning: ^~~~~~~~~~~
warning: 1 error generated.
error: failed to run custom build command for `cxx v1.0.81`
```
This is rectified by detecting cases where clang is used and the target triple
is set to `xxx-xxx-freebsd` and then invoking `uname -r` to obtain the os
version and appending it to the triple before converting it into a
`--target=...` argument to the compiler.
This has been fixed upstream in the LLVM project for Clang 14 and above [1], but
systems not running the latest bleeding edge will not benefit from that. This
issue may be reproduced with clang 13.0.0 on FreeBSD 13.1.
Closes#463.
[0]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238556
[1]: https://reviews.llvm.org/D77776
0 commit comments