From owner-freebsd-questions@FreeBSD.ORG Mon Mar 12 23:16:06 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02ED41065673 for ; Mon, 12 Mar 2012 23:16:06 +0000 (UTC) (envelope-from matthewstory@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id AC6908FC17 for ; Mon, 12 Mar 2012 23:16:05 +0000 (UTC) Received: by ggnk4 with SMTP id k4so3801593ggn.13 for ; Mon, 12 Mar 2012 16:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=TyO6Z4+oizfJ7BgOy5azz2ylHM9sbfN03Tz7Ee7vsm8=; b=uOp0otv/6fkAxl46ejUuwjpqr9RlM7tr3+tm+NozjK8Q5gPFjcW+uPsphlQJzCSTzB jaijFaSFYKYvYj5MAaD9FLoDni+ARofuTHhZRI8cN1h3AC4GxqPYZiKLdeWS3mkxLSEz y3NYJbV4+icmlgDhr5Dce2XzbsfTkC392t+n9ulWNLrLyI+BtHws5t4fM8suezxcPJ/c VGoL4JPMl1pU10RLz6jzvC/HG2szneA5+CZS43d3yel/7a7ZkDTttSsdDcPbpK0hrCTu fyHMqluLXV2ejj8jfPV2Vul9sLrlUoxAbFZkJ46hzJvQLNeV8YfCL+xnV2ZAA+6tslNV RE3A== MIME-Version: 1.0 Received: by 10.52.76.164 with SMTP id l4mr15872947vdw.6.1331594164897; Mon, 12 Mar 2012 16:16:04 -0700 (PDT) Received: by 10.52.93.42 with HTTP; Mon, 12 Mar 2012 16:16:04 -0700 (PDT) In-Reply-To: <4F5E7EDF.9070000@herveybayaustralia.com.au> References: <20120312194545.GA14584@-> <4F5E7EDF.9070000@herveybayaustralia.com.au> Date: Mon, 12 Mar 2012 19:16:04 -0400 Message-ID: From: Matthew Story To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: Which compiler compiled system? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Mar 2012 23:16:06 -0000 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, 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 >>> To unsubscribe, send any mail to " >>> freebsd-questions-unsubscribe@**freebsd.org >>> " >>> >>> ______________________________**_________________ >> freebsd-questions@freebsd.org mailing list >> http://lists.freebsd.org/**mailman/listinfo/freebsd-**questions >> To unsubscribe, send any mail to "freebsd-questions-** >> unsubscribe@freebsd.org " >> > > ______________________________**_________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/**mailman/listinfo/freebsd-**questions > To unsubscribe, send any mail to "freebsd-questions-** > unsubscribe@freebsd.org " > -- regards, matt