Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Apr 2017 20:02:01 +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: r316622 - head/share/mk
Message-ID:  <201704072002.v37K21Ux032932@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Apr  7 20:02:01 2017
New Revision: 316622
URL: https://svnweb.freebsd.org/changeset/base/316622

Log:
  Explicitly set the desired MIPS ABI in toolchain flags.
  
  Specifically, set '-mabi=XX' in AFLAGS, CFLAGS, and LDFLAGS.  This permits
  building MIPS worlds and binaries with a toolchain whose default output
  does not match the desired TARGET_ARCH.
  
  _LDFLAGS (which is used with LD instead of with CC) required an update as
  LD does not accept the -mabi flags (so they must be stripped from LDFLAGS
  when generating _LDFLAGS).  For bare uses of LD (rather than linking via
  CC), the desired ABI must be set by setting an explicit linker emulation
  as done in r316514 for kernels and kernel modules.
  
  Reviewed by:	imp
  Sponsored by:	DARPA / AFRL
  Differential Revision:	https://reviews.freebsd.org/D10085

Modified:
  head/share/mk/bsd.cpu.mk
  head/share/mk/sys.mk

Modified: head/share/mk/bsd.cpu.mk
==============================================================================
--- head/share/mk/bsd.cpu.mk	Fri Apr  7 19:56:12 2017	(r316621)
+++ head/share/mk/bsd.cpu.mk	Fri Apr  7 20:02:01 2017	(r316622)
@@ -314,6 +314,19 @@ AFLAGS += -EB
 CFLAGS += -EB
 LDFLAGS += -EB
 . endif
+. if ${MACHINE_ARCH:Mmips64*} != ""
+AFLAGS+= -mabi=64
+CFLAGS+= -mabi=64
+LDFLAGS+= -mabi=64
+. elif ${MACHINE_ARCH:Mmipsn32*} != ""
+AFLAGS+= -mabi=n32
+CFLAGS+= -mabi=n32
+LDFLAGS+= -mabi=n32
+. else
+AFLAGS+= -mabi=32
+CFLAGS+= -mabi=32
+LDFLAGS+= -mabi=32
+. endif
 . if ${MACHINE_ARCH:Mmips*hf}
 CFLAGS += -mhard-float
 . else

Modified: head/share/mk/sys.mk
==============================================================================
--- head/share/mk/sys.mk	Fri Apr  7 19:56:12 2017	(r316621)
+++ head/share/mk/sys.mk	Fri Apr  7 20:02:01 2017	(r316622)
@@ -217,9 +217,12 @@ INSTALL		?=	install
 LEX		?=	lex
 LFLAGS		?=
 
+# LDFLAGS is for CC, _LDFLAGS is for LD.  Generate _LDFLAGS from
+# LDFLAGS by stripping -Wl, from pass-through arguments and dropping
+# compiler driver flags (e.g. -mabi=*) that conflict with flags to LD.
 LD		?=	ld
-LDFLAGS		?=				# LDFLAGS is for CC, 
-_LDFLAGS	=	${LDFLAGS:S/-Wl,//g}	# strip -Wl, for LD
+LDFLAGS		?=
+_LDFLAGS	=	${LDFLAGS:S/-Wl,//g:N-mabi=*}
 
 LINT		?=	lint
 LINTFLAGS	?=	-cghapbx



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