Which compiler compiled system?
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. Regards, kaltheat ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Which compiler compiled system?
If Java is broken, then you know FreeBSD was compiled with clang... On Mon, Mar 12, 2012 at 3:45 PM, kalth...@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. Regards, kaltheat ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Which compiler compiled system?
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,kalth...@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. Regards, kaltheat ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Which compiler compiled system?
On Mon, Mar 12, 2012 at 6:55 PM, Da Rock freebsd-questi...@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,kalth...@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-**questionshttp://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscribe@**freebsd.orgfreebsd-questions-unsubscr...@freebsd.org __**_ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/**mailman/listinfo/freebsd-**questionshttp://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-** unsubscr...@freebsd.org freebsd-questions-unsubscr...@freebsd.org __**_ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/**mailman/listinfo/freebsd-**questionshttp://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-** unsubscr...@freebsd.org freebsd-questions-unsubscr...@freebsd.org -- regards, matt ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Which compiler compiled system?
On Mon, Mar 12, 2012 at 04:49:38PM -0400, Pierre-Luc Drouin wrote: If Java is broken, then you know FreeBSD was compiled with clang... It's probably more accurate to say If Java is not broken, it's almost certainly built with GCC. If it's broken, it could go either way. (No offense to the Java maintainers at the FreeBSD project, of course. They do a great job of making it possible to get working at all.) -- Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Which compiler compiled system?
On Mar 12, 2012, at 12:45 PM, kalth...@googlemail.com wrote: 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. It's fairly easy to determine whether assembly code was compiled with gcc or clang from idioms they use-- GCC emits .ascii for strings and then adds a trailing null; clang uses .asciz, for example. From that you can also figure out whether a particular executable or shared library was compiled with one or the other-- gcc is doing a leaf frame caller optimization, where it leave / jmp to puts() (using the stack frame allocated for main()), whereas clang is doing normal stack frame handling of %rpb and explicit return. Regards, -- -Chuck % cat h.c #include stdio.h int main() { puts(Hello, world!\n); } % gcc -S -O2 -o h-gcc.s h.c % clang -S -O2 -o h-clang.s h.c % cat h-gcc.s .cstring LC0: .ascii Hello, world!\12\0 .text .align 4,0x90 .globl _main _main: LFB3: pushq %rbp LCFI0: movq%rsp, %rbp LCFI1: leaqLC0(%rip), %rdi leave jmp _puts LFE3: .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support EH_frame1: .set L$set$0,LECIE1-LSCIE1 .long L$set$0 LSCIE1: .long 0x0 .byte 0x1 .ascii zR\0 .byte 0x1 .byte 0x78 .byte 0x10 .byte 0x1 .byte 0x10 .byte 0xc .byte 0x7 .byte 0x8 .byte 0x90 .byte 0x1 .align 3 LECIE1: .globl _main.eh _main.eh: LSFDE1: .set L$set$1,LEFDE1-LASFDE1 .long L$set$1 LASFDE1: .long LASFDE1-EH_frame1 .quad LFB3-. .set L$set$2,LFE3-LFB3 .quad L$set$2 .byte 0x0 .byte 0x4 .set L$set$3,LCFI0-LFB3 .long L$set$3 .byte 0xe .byte 0x10 .byte 0x86 .byte 0x2 .byte 0x4 .set L$set$4,LCFI1-LCFI0 .long L$set$4 .byte 0xd .byte 0x6 .align 3 LEFDE1: .subsections_via_symbols % cat h-clang.s .section__TEXT,__text,regular,pure_instructions .globl _main .align 4, 0x90 _main: ## @main Leh_func_begin0: ## BB#0: pushq %rbp Ltmp0: movq%rsp, %rbp Ltmp1: leaqL_.str(%rip), %rdi callq _puts xorl%eax, %eax popq%rbp ret Leh_func_end0: .section__TEXT,__cstring,cstring_literals L_.str: ## @.str .asciz Hello, world!\n .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support EH_frame0: Lsection_eh_frame0: Leh_frame_common0: Lset0 = Leh_frame_common_end0-Leh_frame_common_begin0 ## Length of Common Information Entry .long Lset0 Leh_frame_common_begin0: .long 0 ## CIE Identifier Tag .byte 1 ## DW_CIE_VERSION .asciz zR ## CIE Augmentation .byte 1 ## CIE Code Alignment Factor .byte 120 ## CIE Data Alignment Factor .byte 16 ## CIE Return Address Column .byte 1 ## Augmentation Size .byte 16 ## FDE Encoding = pcrel .byte 12 ## DW_CFA_def_cfa .byte 7 ## Register .byte 8 ## Offset .byte 144 ## DW_CFA_offset + Reg (16) .byte 1 ## Offset .align 3 Leh_frame_common_end0: .globl _main.eh _main.eh: Lset1 = Leh_frame_end0-Leh_frame_begin0 ## Length of Frame Information Entry .long Lset1 Leh_frame_begin0: Lset2 = Leh_frame_begin0-Leh_frame_common0 ## FDE CIE offset .long Lset2 Ltmp2: ## FDE initial location .quad Leh_func_begin0-Ltmp2 Lset3 = Leh_func_end0-Leh_func_begin0 ## FDE address range .quad Lset3 .byte 0 ## Augmentation size .byte 4 ## DW_CFA_advance_loc4 Lset4 = Ltmp0-Leh_func_begin0 .long Lset4 .byte 14 ## DW_CFA_def_cfa_offset .byte 16 ## Offset .byte 134 ## DW_CFA_offset + Reg (6) .byte 2 ## Offset .byte 4 ## DW_CFA_advance_loc4 Lset5 = Ltmp1-Ltmp0 .long Lset5 .byte 13 ## DW_CFA_def_cfa_register .byte 6 ## Register .align 3 Leh_frame_end0: .subsections_via_symbols ...and here's a disassembly of main() from gcc: _main: