Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Sep 2013 16:31:11 -0600
From:      Ian Lepore <ian@FreeBSD.org>
To:        Dimitry Andric <dim@FreeBSD.org>
Cc:        freebsd-current@FreeBSD.org
Subject:   Re: aicasm build error
Message-ID:  <1379197871.1197.41.camel@revolution.hippie.lan>
In-Reply-To: <55AEA8C2-9C47-4AB4-8626-EB7AC28839FC@FreeBSD.org>
References:  <1379181005.1197.24.camel@revolution.hippie.lan> <55AEA8C2-9C47-4AB4-8626-EB7AC28839FC@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-0mWKFIVkiIbV5MMWWlBf
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

On Sat, 2013-09-14 at 20:42 +0200, Dimitry Andric wrote:
> On Sep 14, 2013, at 19:50, Ian Lepore <ian@freebsd.org> wrote:
> > For a while I've been getting a build error on aicasm during the early
> > steps of the build.  Today I finally dug into it and discovered it's
> > because the build is using a mix of header files, some from /usr/include
> > on the build host, and some from obj/... for the target being built.  It
> > happens because dev/aic7xxx/aicasm/Makefile contains CFLAGS+= -I. and
> > the current directory when aicasm builds is obj/.../<kernconf>.  In my
> > case it was picking up machine/_types.h from objdir.
> > 
> > Apparently this is usually harmless, but if the build host system and
> > the target versions are far enough apart, or with a cross-build where
> > the host and target are different architectures, you can get problems.  
> > 
> > After a little digging, I just now discovered Marcel fixed this long ago
> > in r70000, but then it got undone in r236578 a couple months ago.  Is
> > there any reason not to restore Marcel's fix, such as with the attached
> > patch?
> 
> It got undone for a specific reason, which is mentioned in the commit
> message for r236578.
> 
> This hack might make it work, but it might also cause other issues.  The
> problem really is how to make sure aicasm is compiled with the *host*
> compiler, not the compiler from /usr/obj.
> 
> -Dimitry
> 

What do you think about this patch, which should achieve that goal?
This builds aicasm along with the compiler and binutils and all the
other compile-related tools.  Using this, I'm able to add "device ahc"
to the kernel config of an arm cross-build and it works.  (That's not
useful of course, except to demonstrate that it now uses the right
compiler and then runs the tool successfully during a kernel build.)

I see no straighforward way to do this as part of the kernel build,
which means aicasm gets built whether your kernel config includes an
ahc/ahd device or not.  I suspect that's going to make some people
unhappy, but it takes less than a second to build aicasm on my machine,
it's really not a big burden.

-- Ian


--=-0mWKFIVkiIbV5MMWWlBf
Content-Disposition: inline; filename="aicasm_build2.diff"
Content-Type: text/x-patch; name="aicasm_build2.diff"; charset="us-ascii"
Content-Transfer-Encoding: 7bit

diff -r f84e67c65c01 Makefile.inc1
--- a/Makefile.inc1	Sat Sep 14 15:37:16 2013 -0600
+++ b/Makefile.inc1	Sat Sep 14 16:08:03 2013 -0600
@@ -1005,20 +1005,7 @@ buildkernel:
 	@echo "--------------------------------------------------------------"
 	@echo ">>> stage 2.3: build tools"
 	@echo "--------------------------------------------------------------"
-	cd ${KRNLOBJDIR}/${_kernel}; \
-	    PATH=${BPATH}:${PATH} \
-	    MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
-	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \
-	    -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
-# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
-.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
-.for target in obj depend all
-	cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \
-	    PATH=${BPATH}:${PATH} \
-	    MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \
-	    ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target}
-.endfor
-.endif
+	@# Currently no special kernel tools to build.
 .if !defined(NO_KERNELDEPEND)
 	@echo
 	@echo "--------------------------------------------------------------"
@@ -1303,10 +1290,6 @@ bootstrap-tools: .MAKE
 #
 # build-tools: Build special purpose build tools
 #
-.if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules)
-_aicasm= sys/modules/aic7xxx/aicasm
-.endif
-
 .if !defined(NO_SHARE)
 _share=	share/syscons/scrnmaps
 .endif
@@ -1328,7 +1311,6 @@ build-tools: .MAKE
     lib/ncurses/ncurses \
     lib/ncurses/ncursesw \
     ${_share} \
-    ${_aicasm} \
     usr.bin/awk \
     lib/libmagic \
     usr.bin/mkesdb_static \
@@ -1391,7 +1373,8 @@ cross-tools: .MAKE
     usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \
     ${_btxld} \
     ${_crunchide} \
-    ${_kgzip}
+    ${_kgzip} \
+    sys/dev/aic7xxx/aicasm
 	${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
 		cd ${.CURDIR}/${_tool} && \
 		${MAKE} DIRPRFX=${_tool}/ obj && \
diff -r f84e67c65c01 sys/conf/files
--- a/sys/conf/files	Sat Sep 14 15:37:16 2013 -0600
+++ b/sys/conf/files	Sat Sep 14 16:08:03 2013 -0600
@@ -9,44 +9,39 @@ acpi_quirks.h			optional acpi				   \
 	compile-with	"${AWK} -f $S/tools/acpi_quirks2h.awk $S/dev/acpica/acpi_quirks" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"acpi_quirks.h"
-aicasm				optional ahc | ahd			   \
-	dependency	"$S/dev/aic7xxx/aicasm/*.[chyl]"		   \
-	compile-with	"CC='${CC}' ${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \
-	no-obj no-implicit-rule						   \
-	clean		"aicasm* y.tab.h"
 aic7xxx_seq.h			optional ahc				   \
-	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
+	compile-with	"aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic7xxx_seq.h"					   \
-	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
+	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h"
 aic7xxx_reg.h			optional ahc				   \
-	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
+	compile-with	"aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic7xxx_reg.h"					   \
-	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
+	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h"
 aic7xxx_reg_print.c		optional ahc				   \
-	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
+	compile-with	"aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
 	no-obj no-implicit-rule local					   \
 	clean		"aic7xxx_reg_print.c"				   \
-	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
+	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h"
 aic7xxx_reg_print.o		optional ahc ahc_reg_pretty_print	   \
 	compile-with	"${NORMAL_C}"					   \
 	no-implicit-rule local
 aic79xx_seq.h		optional ahd pci				   \
-	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
+	compile-with	"aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic79xx_seq.h"					   \
-	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
+	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h"
 aic79xx_reg.h		optional ahd pci				   \
-	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
+	compile-with	"aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic79xx_reg.h"					   \
-	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
+	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h"
 aic79xx_reg_print.c	optional ahd pci				   \
-	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
+	compile-with	"aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
 	no-obj no-implicit-rule local					   \
 	clean		"aic79xx_reg_print.c"				   \
-	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
+	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h"
 aic79xx_reg_print.o		optional ahd pci ahd_reg_pretty_print	   \
 	compile-with	"${NORMAL_C}"					   \
 	no-implicit-rule local
diff -r f84e67c65c01 sys/dev/aic7xxx/aicasm/Makefile
--- a/sys/dev/aic7xxx/aicasm/Makefile	Sat Sep 14 15:37:16 2013 -0600
+++ b/sys/dev/aic7xxx/aicasm/Makefile	Sat Sep 14 16:08:03 2013 -0600
@@ -24,7 +24,7 @@ WARNS?=	5
 DEPENDFILE=	.depend_aicasm
 .endif
 
-CFLAGS+= -I.
+CFLAGS+= -I${.CURDIR}
 .ifdef MAKESRCPATH
 CFLAGS+= -I${MAKESRCPATH}
 .endif
@@ -38,4 +38,8 @@ YFLAGS+= -t -v
 LFLAGS+= -d
 .endif
 
+BINDIR=/usr/bin
+
+build-tools: ${PROG}
+
 .include <bsd.prog.mk>

--=-0mWKFIVkiIbV5MMWWlBf--




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