Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jan 2020 14:19:08 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357145 - head/sys/conf
Message-ID:  <202001261419.00QEJ8pS089916@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Sun Jan 26 14:19:08 2020
New Revision: 357145
URL: https://svnweb.freebsd.org/changeset/base/357145

Log:
  Compile hack.c with normal CFLAGS + -shared -nostdlib.
  
  Originally, hack.c was compiled into a shard object with just -shared
  -nostdlib.  This assumed that ${CC} did not require any additional
  flags for ABIs, cross-building, etc.
  
  When kern.post.mk was created in r89509 by reducing duplication in
  kernel Makefile.<arch> files, the -shared flag was moved into a
  HACK_EXTRA_FLAGS variable so that sparc64 could override it with
  -Wl,-shared.  The sparc64 hack was removed in r111650, but
  HACK_EXTRA_FLAGS was left in place.  Over time, we have started
  support toolchains that require flags to support alternate ABIs on
  MIPS and PowerPC and started (ab)using HACK_EXTRA_FLAGS to set only
  those flags.
  
  I need to fix risc-v to pass -mno-relax to the hack.c build for lld in
  llvm 10, and the patches to support cross-build from non-FreeBSD hosts
  need to include -target for clang in CFLAGS for hack.c.  Rather than
  adding more hacks into HACK_EXTRA_FLAGS, just use the full set of
  CFLAGS with hack.c.
  
  Reviewed by:	kib, arichardson
  MFC after:	1 month
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D23362

Modified:
  head/sys/conf/Makefile.mips
  head/sys/conf/Makefile.powerpc
  head/sys/conf/kern.post.mk

Modified: head/sys/conf/Makefile.mips
==============================================================================
--- head/sys/conf/Makefile.mips	Sun Jan 26 11:54:21 2020	(r357144)
+++ head/sys/conf/Makefile.mips	Sun Jan 26 14:19:08 2020	(r357145)
@@ -50,12 +50,9 @@ ARCH_FLAGS+=-mabi=${MIPS_ABI}
 EXTRA_FLAGS=-fno-pic -mno-abicalls -G0 -DKERNLOADADDR=${KERNLOADADDR}
 EXTRA_FLAGS+=-${MIPS_ENDIAN}
 
-HACK_EXTRA_FLAGS=-shared
-
 # We add the -fno-pic flag to kernels because otherwise performance
 # is extremely poor, as well as -mno-abicalls to force no ABI usage.
 CFLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)
-HACK_EXTRA_FLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)
 TRAMP_ARCH_FLAGS?=$(ARCH_FLAGS)
 TRAMP_EXTRA_FLAGS=${EXTRA_FLAGS} ${TRAMP_ARCH_FLAGS}
 # Kernel code is always compiled with soft-float on MIPS

Modified: head/sys/conf/Makefile.powerpc
==============================================================================
--- head/sys/conf/Makefile.powerpc	Sun Jan 26 11:54:21 2020	(r357144)
+++ head/sys/conf/Makefile.powerpc	Sun Jan 26 14:19:08 2020	(r357145)
@@ -39,7 +39,6 @@ INCLUDES+= -I$S/contrib/libfdt
 # Force __SPE__, since the builtin will be removed later with -mno-spe
 CFLAGS.gcc+= -mabi=spe -D__SPE__
 CFLAGS.clang+= -mspe -D__SPE__ -m32
-HACK_EXTRA_FLAGS= -shared -m32 -mspe -D__SPE__
 .endif
 CFLAGS+= -msoft-float
 CFLAGS.gcc+= -Wa,-many

Modified: head/sys/conf/kern.post.mk
==============================================================================
--- head/sys/conf/kern.post.mk	Sun Jan 26 11:54:21 2020	(r357144)
+++ head/sys/conf/kern.post.mk	Sun Jan 26 14:19:08 2020	(r357145)
@@ -226,10 +226,9 @@ kernel-clean:
 # This is a hack.  BFD "optimizes" away dynamic mode if there are no
 # dynamic references.  We could probably do a '-Bforcedynamic' mode like
 # in the a.out ld.  For now, this works.
-HACK_EXTRA_FLAGS?= -shared
 hack.pico: Makefile
 	:> hack.c
-	${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.pico
+	${CC} -shared ${CFLAGS} -nostdlib hack.c -o hack.pico
 	rm -f hack.c
 
 offset.inc: $S/kern/genoffset.sh genoffset.o



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001261419.00QEJ8pS089916>