Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Mar 2012 19:16:04 -0400
From:      Matthew Story <matthewstory@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Which compiler compiled system?
Message-ID:  <CAB%2B9ogf=RGqftc2Jcf8PJ5iFL6dh40RfQ7iAp1tR9OzANpJq5g@mail.gmail.com>
In-Reply-To: <4F5E7EDF.9070000@herveybayaustralia.com.au>
References:  <20120312194545.GA14584@-> <CANT0rcuycULo4pzvsTO_ArSv7YJ2GXfzVKS7Swo4P9f0JzArPA@mail.gmail.com> <4F5E7EDF.9070000@herveybayaustralia.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 12, 2012 at 6:55 PM, Da Rock <
freebsd-questions@herveybayaustralia.com.au> wrote:

> On 03/13/12 06:49, Pierre-Luc Drouin wrote:
>
>> If Java is broken, then you know FreeBSD was compiled with clang...
>>
> I wouldn't say that is categorical.
>
>
>> On Mon, Mar 12, 2012 at 3:45 PM,<kaltheat@googlemail.com>  wrote:
>>
>>  Hi,
>>>
>>> Is there a way to determine whether a FreeBSD-system was compiled with
>>> gcc
>>> or clang?
>>> I thought of some libs or so that might significantly differ.
>>>
>>
strings on a clang v. gcc compile shows no differences (at least in my
tests), but binaries compiled with clang and gcc seem to reliable show
differences at the 25th character of the compiled program, although the
differences at the 25th character are not consistent across programs ...

$ # one example
$ gcc -Wall -o hello_world.gcc hello_world.c
$ clang -Wall -o hello_world.clang hello_world.c
$ cmp hello_world.gcc hello_world.clang
hello_world.gcc hello_world.clang differ: char 25, line 1

this does suggest that if you know gcc and clang are the only 2 options for
compilation on a system, and you have a version compiled with the same
flags on the same system from a known compiler, you should be able to
reliably detect compilation by the other compiler using cmp ... although
this may be more or less meaningless to you depending on how much control
you have over the variables (e.g. binaries built on the same system,
ability to know which compilation flags were sent at compile time, etc ...):

$ # hello_world here is ``in the wild''
$ clang -Wall -o hello_world.clang hello_world.c
$ if cmp hello_world.clang hello_world > /dev/null 2> /dev/null; then echo
"built with clang"; else echo "built with gcc"; fi
built with clang


>
>>> Regards,
>>> kaltheat
>>>
>>> ______________________________**_________________
>>> freebsd-questions@freebsd.org mailing list
>>> http://lists.freebsd.org/**mailman/listinfo/freebsd-**questions<http://lists.freebsd.org/mailman/listinfo/freebsd-questions>;
>>> To unsubscribe, send any mail to "
>>> freebsd-questions-unsubscribe@**freebsd.org<freebsd-questions-unsubscribe@freebsd.org>
>>> "
>>>
>>>  ______________________________**_________________
>> freebsd-questions@freebsd.org mailing list
>> http://lists.freebsd.org/**mailman/listinfo/freebsd-**questions<http://lists.freebsd.org/mailman/listinfo/freebsd-questions>;
>> To unsubscribe, send any mail to "freebsd-questions-**
>> unsubscribe@freebsd.org <freebsd-questions-unsubscribe@freebsd.org>"
>>
>
> ______________________________**_________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/**mailman/listinfo/freebsd-**questions<http://lists.freebsd.org/mailman/listinfo/freebsd-questions>;
> To unsubscribe, send any mail to "freebsd-questions-**
> unsubscribe@freebsd.org <freebsd-questions-unsubscribe@freebsd.org>"
>



-- 
regards,
matt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAB%2B9ogf=RGqftc2Jcf8PJ5iFL6dh40RfQ7iAp1tR9OzANpJq5g>