From nobody@FreeBSD.org  Mon May  2 16:38:45 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E22F01065673
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  2 May 2011 16:38:45 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id D11FE8FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  2 May 2011 16:38:45 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p42GcjeE071074
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 2 May 2011 16:38:45 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p42Gcj7f071073;
	Mon, 2 May 2011 16:38:45 GMT
	(envelope-from nobody)
Message-Id: <201105021638.p42Gcj7f071073@red.freebsd.org>
Date: Mon, 2 May 2011 16:38:45 GMT
From: Damjan Marion <damjan.marion@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: FreeBSD/arm fails to build trampoline code with clang due to missing -ffreestanding
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         156771
>Category:       arm
>Synopsis:       FreeBSD/arm fails to build trampoline code with clang due to missing -ffreestanding
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-arm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 02 16:40:10 UTC 2011
>Closed-Date:    Wed Jun 15 19:22:43 UTC 2011
>Last-Modified:  Wed Jun 15 19:22:43 UTC 2011
>Originator:     Damjan Marion
>Release:        -CURRENT
>Organization:
n/a
>Environment:
>Description:

clang compiler produces optimized code which calls memset which is missing when kernel.trampoline is linked.

inflate-tramp.o: In function `inflate_dynamic':
/Volumes/data/src/freebsd/sys/kern/inflate.c:(.text+0x538): undefined reference to `memset'
inflate-tramp.o: In function `huft_build':
/Volumes/data/src/freebsd/sys/kern/inflate.c:(.text+0xb1c): undefined reference to `memset'


This can be avoided by passing -ffreestanding (diff attached). 

>How-To-Repeat:

>Fix:
diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm
index 756945d..d067fb3 100644
--- a/sys/conf/Makefile.arm
+++ b/sys/conf/Makefile.arm
@@ -108,7 +108,7 @@ ${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c
        gzip -9 ${KERNEL_KO}.tmp
        eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
        echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
-       ${CC} -O2 -DKZIP -I. -I$S -c $S/kern/inflate.c -o inflate-tramp.o
+       ${CC} -O2 -ffreestanding -DKZIP -I. -I$S -c $S/kern/inflate.c -o inflate-tramp.o
        ${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
        -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
        $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp


>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: arm/156771: commit references a PR
Date: Wed, 15 Jun 2011 19:16:05 +0000 (UTC)

 Author: cognet
 Date: Wed Jun 15 19:15:50 2011
 New Revision: 223116
 URL: http://svn.freebsd.org/changeset/base/223116
 
 Log:
   Add -ffreestanding to the command line, so taht inflate.c compiles and link
   properly with llvm.
   
   PR:		arm/156771
   Submitted by:	Damjan Marion <damjan dot marion at gmail DOT com>
 
 Modified:
   head/sys/conf/Makefile.arm
 
 Modified: head/sys/conf/Makefile.arm
 ==============================================================================
 --- head/sys/conf/Makefile.arm	Wed Jun 15 19:09:58 2011	(r223115)
 +++ head/sys/conf/Makefile.arm	Wed Jun 15 19:15:50 2011	(r223116)
 @@ -108,7 +108,8 @@ ${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$
  	gzip -9 ${KERNEL_KO}.tmp
  	eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
  	echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
 -	${CC} -O2 -DKZIP -I. -I$S -c $S/kern/inflate.c -o inflate-tramp.o
 +	${CC} -O2 -ffreestanding -DKZIP -I. -I$S -c $S/kern/inflate.c -o \
 +	    inflate-tramp.o
  	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
  	-DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
  	$S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: cognet 
State-Changed-When: Wed Jun 15 19:20:48 UTC 2011 
State-Changed-Why:  
Committed, thanks ! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156771 
>Unformatted:
