From owner-svn-src-head@freebsd.org Thu Oct 8 17:42:10 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C116C9D02D1; Thu, 8 Oct 2015 17:42:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B8C53CF; Thu, 8 Oct 2015 17:42:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t98Hg9s2040264; Thu, 8 Oct 2015 17:42:09 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t98Hg9pr040259; Thu, 8 Oct 2015 17:42:09 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201510081742.t98Hg9pr040259@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 8 Oct 2015 17:42:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289039 - in head/sys: arm64/conf conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Oct 2015 17:42:10 -0000 Author: kib Date: Thu Oct 8 17:42:08 2015 New Revision: 289039 URL: https://svnweb.freebsd.org/changeset/base/289039 Log: Build changes that allow the modules on arm64. - Move the required kernel compiler flags from Makefile.arm64 to kern.mk. - Build arm64 modules as PIC; non-PIC relocations in .o for shared object output cannot be handled. - Do not try to install aarch64 symlink. - A hack for arm64 to avoid ld -r stage. See the comment for the explanation. Some functionality is lost, like ctf handling, but hopefully will be restored after newer linker is available. Reviewed by: andrew, emaste Tested by: andrew (on real hardware) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3796 Modified: head/sys/arm64/conf/GENERIC head/sys/conf/Makefile.arm64 head/sys/conf/kern.mk head/sys/conf/kern.post.mk head/sys/conf/kmod.mk Modified: head/sys/arm64/conf/GENERIC ============================================================================== --- head/sys/arm64/conf/GENERIC Thu Oct 8 17:41:17 2015 (r289038) +++ head/sys/arm64/conf/GENERIC Thu Oct 8 17:42:08 2015 (r289039) @@ -22,7 +22,6 @@ cpu ARM64 ident GENERIC makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions NO_MODULES=1 # We don't yet support modules on arm64 options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption Modified: head/sys/conf/Makefile.arm64 ============================================================================== --- head/sys/conf/Makefile.arm64 Thu Oct 8 17:41:17 2015 (r289038) +++ head/sys/conf/Makefile.arm64 Thu Oct 8 17:42:08 2015 (r289039) @@ -27,12 +27,6 @@ S= ../../.. INCLUDES+= -I$S/contrib/libfdt -# We generally don't want fpu instructions in the kernel. -CFLAGS += -mgeneral-regs-only - -# Reserve x18 for pcpu data -CFLAGS += -ffixed-x18 - .if !empty(DDB_ENABLED) CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer .endif Modified: head/sys/conf/kern.mk ============================================================================== --- head/sys/conf/kern.mk Thu Oct 8 17:41:17 2015 (r289038) +++ head/sys/conf/kern.mk Thu Oct 8 17:42:08 2015 (r289039) @@ -97,6 +97,13 @@ INLINE_LIMIT?= 8000 INLINE_LIMIT?= 8000 .endif +.if ${MACHINE_CPUARCH} == "aarch64" +# We generally don't want fpu instructions in the kernel. +CFLAGS += -mgeneral-regs-only +# Reserve x18 for pcpu data +CFLAGS += -ffixed-x18 +.endif + # # For sparc64 we want the medany code model so modules may be located # anywhere in the 64-bit address space. We also tell GCC to use floating Modified: head/sys/conf/kern.post.mk ============================================================================== --- head/sys/conf/kern.post.mk Thu Oct 8 17:41:17 2015 (r289038) +++ head/sys/conf/kern.post.mk Thu Oct 8 17:42:08 2015 (r289039) @@ -212,7 +212,7 @@ SRCS= assym.s vnode_if.h ${BEFORE_DEPEND mv .newdep .depend _ILINKS= machine -.if ${MACHINE} != ${MACHINE_CPUARCH} +.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+= ${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" Modified: head/sys/conf/kmod.mk ============================================================================== --- head/sys/conf/kmod.mk Thu Oct 8 17:41:17 2015 (r289038) +++ head/sys/conf/kmod.mk Thu Oct 8 17:42:08 2015 (r289039) @@ -113,6 +113,10 @@ CFLAGS+= ${DEBUG_FLAGS} CFLAGS+= -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer .endif +.if ${MACHINE_CPUARCH} == "aarch64" +CFLAGS+= -fPIC +.endif + # Temporary workaround for PR 196407, which contains the fascinating details. # Don't allow clang to use fpu instructions or registers in kernel modules. .if ${MACHINE_CPUARCH} == arm @@ -182,7 +186,17 @@ ${PROG}.debug: ${FULLPROG} .if ${__KLD_SHARED} == yes ${FULLPROG}: ${KMOD}.kld +.if ${MACHINE_CPUARCH} != "aarch64" ${LD} -Bshareable ${_LDFLAGS} -o ${.TARGET} ${KMOD}.kld +.else +#XXXKIB Relocatable linking in aarch64 ld from binutils 2.25.1 does +# not work. The linker corrupts the references to the external +# symbols which are defined by other object in the linking set +# and should therefore loose the GOT entry. The problem seems +# to be fixed in the binutils-gdb git HEAD as of 2015-10-04. Hack +# below allows to get partially functioning modules for now. + ${LD} -Bshareable ${_LDFLAGS} -o ${.TARGET} ${OBJS} +.endif .if !defined(DEBUG_FLAGS) ${OBJCOPY} --strip-debug ${.TARGET} .endif @@ -220,7 +234,7 @@ ${FULLPROG}: ${OBJS} .endif _ILINKS=machine -.if ${MACHINE} != ${MACHINE_CPUARCH} +.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+=${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"