Difference between clang and clang++

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Difference between clang and clang++

Nikola Smiljanic
Hi all,

If somebody would explain the difference between clang and clang++. I downloaded 2.9 release and clang.exe and clang++.exe are identical files?

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

John McCall
On May 30, 2011, at 2:07 AM, Nikola Smiljanic wrote:
> Hi all,
>
> If somebody would explain the difference between clang and clang++. I downloaded 2.9 release and clang.exe and clang++.exe are identical files?

Invoking the compiler as clang++ requests it to compile and link code as C++.  This typically only matters when linking object files, where it causes the C++ standard library to be linked in.

I don't know why (or whether) these files are independent on disk;  on Unix-y platforms, clang++ is just a symlink.

John.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Sean Hunt
On 11-05-30 02:15 AM, John McCall wrote:

> On May 30, 2011, at 2:07 AM, Nikola Smiljanic wrote:
>> Hi all,
>>
>> If somebody would explain the difference between clang and clang++. I downloaded 2.9 release and clang.exe and clang++.exe are identical files?
>
> Invoking the compiler as clang++ requests it to compile and link code as C++.  This typically only matters when linking object files, where it causes the C++ standard library to be linked in.
>
> I don't know why (or whether) these files are independent on disk;  on Unix-y platforms, clang++ is just a symlink.
>
> John.

They might be hard linked?

Sean
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

John McCall
On May 30, 2011, at 2:19 AM, Sean Hunt wrote:
On 11-05-30 02:15 AM, John McCall wrote:
On May 30, 2011, at 2:07 AM, Nikola Smiljanic wrote:
Hi all,

If somebody would explain the difference between clang and clang++. I downloaded 2.9 release and clang.exe and clang++.exe are identical files?

Invoking the compiler as clang++ requests it to compile and link code as C++.  This typically only matters when linking object files, where it causes the C++ standard library to be linked in.

I don't know why (or whether) these files are independent on disk;  on Unix-y platforms, clang++ is just a symlink.

They might be hard linked?

I had the impression that the Windows filesystem was sane enough to not allow hard-linking, but I am prepared to be corrected.

I rate it more likely that some packager just didn't want to deal with symlinks.

John.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Konstantin Tokarev
In reply to this post by Nikola Smiljanic


30.05.2011, 13:07, "Nikola Smiljanic" <[hidden email]>:
> Hi all,
> If somebody would explain the difference between clang and clang++. I downloaded 2.9 release and clang.exe and clang++.exe are identical files?
>

Driver activates C++ mode depending on executable name


--
Regards,
Konstantin
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Sebastian Redl
In reply to this post by John McCall
On 30.05.2011 11:27, John McCall wrote:
On May 30, 2011, at 2:19 AM, Sean Hunt wrote:
On 11-05-30 02:15 AM, John McCall wrote:

I don't know why (or whether) these files are independent on disk;  on Unix-y platforms, clang++ is just a symlink.

They might be hard linked?

I had the impression that the Windows filesystem was sane enough to not allow hard-linking, but I am prepared to be corrected.

I rate it more likely that some packager just didn't want to deal with symlinks.

Hard links are possible in NTFS, but the userland really doesn't play well with them. They're better avoided.

Soft links are also possible, but only since Vista have they become supported by the WinAPI properly. Many tools still won't create them.

Sebastian

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Matthieu Moy
In reply to this post by John McCall
John McCall <[hidden email]> writes:

> I had the impression that the Windows filesystem was sane enough to
> not allow hard-linking, but I am prepared to be corrected.

http://en.wikipedia.org/wiki/Hard_link
"The Windows API from Windows 2000 onwards includes a CreateHardLink()
call to create hard links [...] Hard links require an NTFS partition."

It's probably more a matter of culture than technical limitation if
people use hardlinks more on Unix than on windows.

--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Anton Korobeynikov
In reply to this post by John McCall
> I had the impression that the Windows filesystem was sane enough to not
> allow hard-linking, but I am prepared to be corrected.
> I rate it more likely that some packager just didn't want to deal with
> symlinks.
No "sane" links on windows. So, yes, one can consider "ln -s" as an
alias of "cp" there :)

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Nikola Smiljanic
On Mon, May 30, 2011 at 11:47 AM, Konstantin Tokarev <[hidden email]> wrote:

Driver activates C++ mode depending on executable name


How can it do this if the files are identical? And if clang++ is only a symlink that would mean that one executable contains all the functionality? If this is the case, what is the reason behind two names?

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Jonathan Sauer
Hello,

>> Driver activates C++ mode depending on executable name
>
> How can it do this if the files are identical?

If clang is called via the symlink clang++, argv[0] is "clang++" instead of "clang". Look into
driver.cpp, function ParseProgName, where this is checked. There are quite a few supported names
(suffixes, actually).

> And if clang++ is only a symlink that would mean that one executable contains all the functionality?

Yes :-)

> If this is the case, what is the reason behind two names?

To activate C++ mode, just as Konstantin wrote.

Of course you can simply use "clang" to compile C++ code, too. You just have to pass "-x c++" and
"-lc++" (for libc++) or "-lstdc++" (for libstdc++) to it ("-x c++" is optional if the source file
is recognized (using its extension) as C++ code.


HTH,
Jonathan


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Matthieu Moy
In reply to this post by Nikola Smiljanic
Nikola Smiljanic <[hidden email]> writes:

> On Mon, May 30, 2011 at 11:47 AM, Konstantin Tokarev <[hidden email]> wrote:
>
>     Driver activates C++ mode depending on executable name
>
> How can it do this if the files are identical?

int main(int argc, char **argv) {
        // argv[0] tells you.

clang is not the only one to do this kind of things. For example, on my
system, pdflatex is a symbolic link to latex, although they do different
things.

> And if clang++ is only a symlink that would mean that one executable
> contains all the functionality?

Sure.

> If this is the case, what is the reason behind two names?

C++ is not a superset of C, so compiling C and C++ are different tasks,
although much of the C-compiling code can be re-used for C++.

Clang could as well have shipped one binary, and ask users to say
"clang" or "clang -x c++", but "clang++" is shorter to type.

--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Sebastian Redl
In reply to this post by Nikola Smiljanic
On 30.05.2011 13:01, Nikola Smiljanic wrote:
On Mon, May 30, 2011 at 11:47 AM, Konstantin Tokarev <[hidden email]> wrote:

Driver activates C++ mode depending on executable name


How can it do this if the files are identical? And if clang++ is only a symlink that would mean that one executable contains all the functionality? If this is the case, what is the reason behind two names?

A program can inspect the name by which it was called.

Sebastian

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Konstantin Tokarev
In reply to this post by Nikola Smiljanic


30.05.2011, 15:01, "Nikola Smiljanic" <[hidden email]>:
> On Mon, May 30, 2011 at 11:47 AM, Konstantin Tokarev <[hidden email]> wrote:
>> Driver activates C++ mode depending on executable name
>
> How can it do this if the files are identical?

But argv[0] is not :)

>And if clang++ is only a symlink that would mean that one executable contains all the functionality?

Right.

>If this is the case, what is the reason behind two names?

For convenience and compatibility with compilers like gcc/g++.


--
Regards,
Konstantin
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Nikola Smiljanic
In reply to this post by Jonathan Sauer


On Mon, May 30, 2011 at 1:26 PM, Jonathan Sauer <[hidden email]> wrote:
Hello,

If clang is called via the symlink clang++, argv[0] is "clang++" instead of "clang". Look into
driver.cpp, function ParseProgName, where this is checked. There are quite a few supported names
(suffixes, actually).


Fantastic, I was wondering what was argv[0] good for, now I know. Thanks.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Jonathan Sauer
>> If clang is called via the symlink clang++, argv[0] is "clang++" instead of "clang". Look into
>> driver.cpp, function ParseProgName, where this is checked. There are quite a few supported names
>> (suffixes, actually).
>
> Fantastic, I was wondering what was argv[0] good for, now I know. Thanks.

Someone should write a patch for clang so that when it is called as "WOPR", it lets you play a game
of Global Thermonuclear War.


Jonathan


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Argyrios Kyrtzidis
On May 30, 2011, at 5:34 AM, Jonathan Sauer wrote:

>>> If clang is called via the symlink clang++, argv[0] is "clang++" instead of "clang". Look into
>>> driver.cpp, function ParseProgName, where this is checked. There are quite a few supported names
>>> (suffixes, actually).
>>
>> Fantastic, I was wondering what was argv[0] good for, now I know. Thanks.
>
> Someone should write a patch for clang so that when it is called as "WOPR", it lets you play a game
> of Global Thermonuclear War.

... and a patch for "tictactoe" to prevent the ensuing nuclear annihilation.

>
>
> Jonathan
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

NAKAMURA Takumi
In reply to this post by John McCall
2011/5/30 John McCall <[hidden email]>:
> I don't know why (or whether) these files are independent on disk;  on Unix-y platforms, clang++ is just a symlink.

If we had "the big clang.dll (like --shared llvm.dll, not only C
API)", we could obtain smaller clang.exe and clang++.exe. Of course
they may be identical.

I love monolithic clang!

ps. Note that, gcc has its big cc1.exe and cc1plus.exe (and other
backends) in most platforms.

...Takumi

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Difference between clang and clang++

Yonggang Luo
Someone tried, but seems not finished yet..

2011/6/1 NAKAMURA Takumi <[hidden email]>
2011/5/30 John McCall <[hidden email]>:
> I don't know why (or whether) these files are independent on disk;  on Unix-y platforms, clang++ is just a symlink.

If we had "the big clang.dll (like --shared llvm.dll, not only C
API)", we could obtain smaller clang.exe and clang++.exe. Of course
they may be identical.

I love monolithic clang!

ps. Note that, gcc has its big cc1.exe and cc1plus.exe (and other
backends) in most platforms.

...Takumi

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



--
         此致

罗勇刚
Yours
    sincerely,
Yonggang Luo


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev