Clang --target argument breaks C++ compilation on FreeBSD
It turns out that the fact that we pass --target=...
to clang
breaks C++ compilation on FreeBSD:
$ cat hi.cpp
#include <iostream>
int main() {
std::cout << "hello\n";
return 0;
}
$ ghc -c hi.cpp
hi.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
$ clang++ -c hi.cpp
$
Passing -v3
to ghc
reveals the clang++
command-line which replicates the issue:
'clang++' -x 'c++' -c hi.cpp -o hi.o.tmp -fno-PIC -include /usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/rts-1.0.2/include/ghcversion.h -I/usr/local/include -I/usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/base-4.17.0.0/include -I/usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/ghc-bignum-1.3/include -I/usr/home/vagrant/ghc/_build/stage1/lib/../lib/x86_64-freebsd-ghc-9.5.20220808/rts-1.0.2/include '--target=x86_64-unknown-freebsd'
Dropping the '--target=x86_64-unknown-freebsd'
flag allows the command to run.
This causes T13366Cxx
to fail on FreeBSD, among othres.
Edited by Ben Gamari