On Tue, 14 Feb 2023 17:07:13 GMT, Erik Joelsson <er...@openjdk.org> wrote:

> I'm not sure I'm understanding the problem here. I think the uppercase `CC` 
> is a remnant of Solaris support. In Solaris Studio, the C++ compiler is 
> uppercase and the C compiler lowercase. What is this resolving to for you? 
> Could it be that on a mac case insensitive file system it resolves to `cc` 
> which in turn resolves to `clang`? I'm not familiar with `c++` as a launcher, 
> but I see on my local Linux host, this resolves to g++ and on my mac to 
> clang++. The drawback of going with a standard launcher like this is that we 
> have a harder time knowing which toolchain type it is.
> 
> Dropping Solaris support for `CC` should be fine, but if we add `c++` it 
> should probably be after `g++`. In the Solaris case, we wanted to be sure we 
> got Solaris Studio and not GCC, but now I think we prefer the known `g++` 
> over the potentially unknown `c++`.

`c++` is indeed the alias of the C++ Compiler that is used for compiling C++ 
for the build platform, much like `cc` is for C. On my end, the uppercase `CC` 
ends up resolving to `gcc`, likely because `CC` doesn't exist (at least on some 
platforms), so the next best fallback of `cc` is chosen, which quite 
understandably makes the linker give up on life when compiling something like 
`adlc` which was written in C++



> Erik is probably right that this was created for Solaris, but using "CC" (in 
> upper case) is afaik a long-standing Unix tradition. It is a bit hard too 
> google, but see e.g. 
> https://users.cs.cf.ac.uk/dave/C/node3.html#SECTION00312000000000000000. I 
> think we should not remove it, but we might add other aliases, and we might 
> discuss the order.
> 
> I agree with Erik that trying the g++ explicitly first is a good idea. I 
> think we should keep CC, but it can be lower priority, so in that case the 
> preferred order would be `g++ c++ CC`.
> 
> But I am also curious to what problem you experienced?

For one, when testing this on WSL and an Ubuntu VM, build tools written in C++ 
such as `adlc` started getting compiled as C, which turned out about as well as 
you might expect :P

I don't know about shifting the order that these are searched though, `cc` and 
`c++` are explicitly listed as the compilers meant for "this" platform (the one 
we are building on), which seems to be explicitly what we want here. Wouldn't 
searching for `g++` first (and correspondingly swapping `gcc` as the first 
search for C as well) risk returning the compiler for `--openjdk-target` as the 
build compiler? (I also had the worry that leaving `CC` as the last search 
would risk returning `gcc` if the build platform exhausts every other possible 
compiler and the uppercase `CC` is not present, but after some thought it 
sounds very unlikely to happen)

-------------

PR: https://git.openjdk.org/jdk/pull/12558

Reply via email to