Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poudriere reported host amd64 vs x86_64 #645

Closed
teamblubee opened this issue Oct 7, 2018 · 9 comments
Closed

poudriere reported host amd64 vs x86_64 #645

teamblubee opened this issue Oct 7, 2018 · 9 comments
Labels
Ports Issue An issue or behavior in the ports framework, not Poudriere question wontfix

Comments

@teamblubee
Copy link

This has bitten me a few times and I finally have a project that I can reliably reproduce it in.

I created an issue upstream but also creating one here to see if this is something that could get fixed here.

OpenMathLib/OpenBLAS#1796 (comment)

I can provide a port makefile that should reproduce the issue.

In this particular case if I start the poudriere jail, login and run gmake in the src directory, The env is properly detected and there's no problems.

If I do poudriere test port, it will fail. Using interactive mode after the failure and going to the source directory and running gmake the env is detected properly and the project gets built.

The problem only occurs when doing poudriere testport.

steps to test: git clone the openblas repo,
go to the src directory and run gmake; no problems.

# Created by: Eijiro Shibusawa <ej-sib@ice.uec.ac.jp>
# $FreeBSD: head/math/openblas/Makefile 479351 2018-09-10 02:06:12Z linimon $

PORTNAME=	openblas
PORTVERSION=	0.2.20
PORTREVISION=	4
DISTVERSIONPREFIX=	v
PORTEPOCH=	1
CATEGORIES=	math
MASTER_SITES=	NL/lapack/timing/:lapack_tmg
DISTFILES=	large.tgz:lapack_tmg timing.tgz:lapack_tmg
DIST_SUBDIR=	openblas

MAINTAINER=	phd_kimberlite@yahoo.co.jp
COMMENT=	Optimized BLAS library based on GotoBLAS2

LICENSE=	BSD3CLAUSE
LICENSE_FILE=	${WRKSRC}/LICENSE

LIB_DEPENDS+=	libomp.so:devel/openmp

CFLAGS+=	-I${LOCALBASE}/include
LDFLAGS+=	-L${LOCALBASE}/lib -lomp

USES=		fortran gmake perl5

USE_GITHUB=	yes
GH_ACCOUNT=	xianyi
GH_PROJECT=	OpenBLAS
GH_TAGNAME=	6e2c4945567ad8fb5f11be7ac7c0b10c6b4f42cb
LARGE_FILE=	large.tgz
TIMING_FILE=	timing.tgz

USE_LDCONFIG=	yes

MAKE_ARGS+=	NO_STATIC=1 #\
		USE_OPENMP=1

do-build:
	@(cd ${WRKSRC} && ${MAKE_CMD} ${MAKE_ARGS})
.include <bsd.port.mk>

host system: FreeBSD blubee 12.0-ALPHA5 FreeBSD 12.0-ALPHA5 #0 r338520: Fri Sep 7 23:31:46 CST 2018 root@:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64

@teamblubee
Copy link
Author

can I ping this issue:
OpenMathLib/OpenBLAS#1796 (comment)

@bdrewery
Copy link
Member

bdrewery commented Oct 8, 2018

ARCH is set by the ports framework, not Poudriere.
In this case I think normally a ports patch would be used to rename ARCH before trying to build.

@bdrewery bdrewery added the Ports Issue An issue or behavior in the ports framework, not Poudriere label Oct 8, 2018
@teamblubee
Copy link
Author

ARCH is set by the ports framework, not Poudriere.
In this case I think normally a ports patch would be used to rename ARCH before trying to build.

I tried this but that did not work.

The $(ARCH) variable is referenced many different times throughout the build. Even setting ARCH from within the ports Makefile this was not enough.

If I set ARCH from the makefile the first check would pass but then it would fail when trying to match
kernel/$(ARCH)
if I managed to pass that check then I would get an error later x86_64 is not a valid command, where $(ARCH) was referencing the archive command.

@teamblubee
Copy link
Author

This issue keeps cropping up and I am hoping that you guys can offer a fix.

Here's another example: math/scalapack has a SLmake.in.example file; contents

############################################################################
#
#  Program:         ScaLAPACK
#
#  Module:          SLmake.inc
#
#  Purpose:         Top-level Definitions
#
#  Creation date:   February 15, 2000
#
#  Modified:        October 13, 2011
#
#  Send bug reports, comments or suggestions to scalapack@cs.utk.edu
#
############################################################################
#
#  C preprocessor definitions:  set CDEFS to one of the following:
#
#     -DNoChange (fortran subprogram names are lower case without any suffix)
#     -DUpCase   (fortran subprogram names are upper case without any suffix)
#     -DAdd_     (fortran subprogram names are lower case with "_" appended)

CDEFS         = -DAdd_

#
#  The fortran and C compilers, loaders, and their flags
#

FC            = mpif90
CC            = mpicc 
NOOPT         = -O0
FCFLAGS       = -O3
CCFLAGS       = -O3
FCLOADER      = $(FC)
CCLOADER      = $(CC)
FCLOADFLAGS   = $(FCFLAGS)
CCLOADFLAGS   = $(CCFLAGS)

#
#  The archiver and the flag(s) to use when building archive (library)
#  Also the ranlib routine.  If your system has no ranlib, set RANLIB = echo
#

ARCH          = ar
ARCHFLAGS     = cr
RANLIB        = ranlib

#
#  The name of the ScaLAPACK library to be created
#

SCALAPACKLIB  = libscalapack.a

#
#  BLAS, LAPACK (and possibly other) libraries needed for linking test programs
#

BLASLIB       = -lblas
LAPACKLIB     = -llapack
LIBS          = $(LAPACKLIB) $(BLASLIB)

You can see ARCH defined there

running poudriere testport the jail starts up, build is going just fine and then failure

mpif90 -c -O3 pzunmr2.f
mpif90 -c -O3 pzunmrq.f
mpif90 -c -O3 pzunmtr.f
mpif90 -c -O3 pzlaevswp.f
mpif90 -c -O3 pzlarzb.f
mpif90 -c -O3 pzlarzt.f
mpif90 -c -O3 pzlarz.f
mpif90 -c -O3 pzlarzc.f
mpif90 -c -O3 pzlatrz.f
mpif90 -c -O3 pztzrzf.f
mpif90 -c -O3 pzunmr3.f
mpif90 -c -O3 pzunmrz.f
mpif90 -c -O3 pzmax1.f
mpif90 -c -O3 pdzsum1.f
mpif90 -c -O3 pzlamr1d.f
mpif90 -c -O3 zdbtf2.f
mpif90 -c -O3 zdbtrf.f
mpif90 -c -O3 zdttrf.f
mpif90 -c -O3 zdttrsv.f
mpif90 -c -O3 zpttrsv.f
mpif90 -c -O3 zsteqr2.f
mpif90 -c -O3 ztrmvt.f
mpif90 -c -O3 zlamsh.f
mpif90 -c -O3 zlaref.f
mpif90 -c -O3 zlanv2.f
mpif90 -c -O3 zlahqr2.f
mpif90 -c -O3 pzheevr.f
amd64 cr ../libscalapack.a psdbsv.o  psdbtrf.o psdbtrs.o psdbtrsv.o psdtsv.o  psdttrf.o psdttrs.o psdttrsv.o psgbsv.o  psgbtrf.o psgbtrs.o psgebd2.o psgebrd.o psgecon.o           psgeequ.o psgehd2.o psgehrd.o psgelq2.o psgelqf.o psgels.o  psgeql2.o psgeqlf.o psgeqpf.o psgeqr2.o psgeqrf.o psgerfs.o psgerq2.o psgerqf.o psgesv.o  psgesvd.o psgesvx.o psgetf2.o psgetrf.o psgetri.o psgetrs.o psggqrf.o psggrqf.o pslabrd.o pslacon.o pslacp2.o pslacpy.o pslahrd.o pslange.o pslanhs.o pslansy.o pslantr.o pslapiv.o pslapv2.o pslaqge.o pslaqsy.o pslarf.o  pslarfb.o pslarfg.o pslarft.o pslase2.o pslaset.o pslascl.o pslassq.o pslaswp.o pslatra.o pslatrd.o pslatrs.o pslauu2.o pslauum.o psorg2l.o psorg2r.o psorgl2.o psorglq.o psorgql.o psorgqr.o psorgr2.o psorgrq.o           psorm2l.o psorm2r.o psormbr.o psormhr.o psorml2.o psormlq.o psormql.o psormqr.o psormr2.o psormrq.o psormtr.o pspocon.o pspbsv.o  pspbtrf.o pspbtrs.o pspbtrsv.o psptsv.o  pspttrf.o pspttrs.o pspttrsv.o pspoequ.o psporfs.o psposv.o  psposvx.o pspotf2.o pspotrf.o pspotri.o pspotrs.o psrscl.o  psstein.o pssyev.o  pssyevd.o pssyevx.o pssygs2.o pssygst.o pssygvx.o pssyngst.o pssyntrd.o  pssyttrd.o pssytd2.o pssytrd.o pstrti2.o pstrtri.o pstrtrs.o pslaevswp.o pslarzb.o pslarzt.o pslarz.o pslatrz.o pstzrzf.o psormr3.o psormrz.o pslahqr.o pslaconsb.o pslacp3.o pslawil.o pslasmsub.o pslared2d.o pslamr1d.o slaref.o slamsh.o slasorte.o ssteqr2.o sdbtf2.o  sdbtrf.o  sdttrf.o sdttrsv.o spttrsv.o strmvt.o pssyevr.o bslaapp.o bslaexc.o bstrexc.o pstrord.o pstrsen.o psgebal.o pshseqr.o pslamve.o pslaqr0.o pslaqr1.o pslaqr2.o pslaqr3.o pslaqr4.o pslaqr5.o psrot.o slaqr6.o pslabad.o pslaed0.o pslaed1.o pslaed2.o pslaed3.o pslaedz.o pslaiect.o pslamch.o pslared1d.o pslasrt.o psstebz.o psstedc.o slapst.o slasrt2.o sstein2.o slar1va.o slarrb2.o slarrd2.o slarre2.o slarre2a.o slarrf2.o slarrv2.o sstegr2.o sstegr2a.o sstegr2b.o slamov.o clamov.o \
pjlaenv.o pbchkvect.o getpbbuf.o pilaenvx.o piparmq.o pilaver.o pmpim2.o pmpcol.o
gmake[2]: amd64: Command not found
gmake[2]: *** [Makefile:196: single] Error 127
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: Leaving directory '/wrkdirs/usr/ports/math/scalapack/work/scalapack-2.0.2/SRC'
gmake[1]: *** [Makefile:68: scalapacklib] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/math/scalapack/work/scalapack-2.0.2'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

You can clearly see that the ${AR} command is replaced by ARCH defined in /usr/ports/Mk/bsd.port.mk

I could apply NO_ARCH everywhere but that just feels like pointing a rifle at my toes.

Do you have any suggested fix for this?

@teamblubee
Copy link
Author

This seems like a bug in /usr/ports/Mk/bsd.port.mk
line 1137

# Get the architecture
.if !defined(ARCH)
ARCH!=	${UNAME} -p
.endif
HOSTARCH:=	${ARCH}
.if defined(CROSS_TOOLCHAIN)
ARCH=	${CROSS_TOOLCHAIN:C,-.*$,,}
.endif
_EXPORTED_VARS+=	ARCH

They use ARCH as a temp variable to get the hostarch, cross tools and added it to exported vars.

Maybe a fix is to unset ARCH after all this is completed?

@mat813
Copy link
Member

mat813 commented Oct 15, 2018

Like @bdrewery said, simply patch the software's Makefile to use another variable instead of ARCH, say, AR, this is not a poudriere bug, nor a framework one.

@teamblubee
Copy link
Author

Like @bdrewery said, simply patch the software's Makefile to use another variable instead of ARCH, say, AR, this is not a poudriere bug.

This problem only happens in poudriere on the first attempt at poudriere testport; If you go interactive after the failure and run the exact same commands; the bug does not appear unless you go and set the env variable again.

Also the $(ARCH) variable is used in almost every makefile that i've been working with recently, there's nothing that you guys are willing to do about this?

@mat813
Copy link
Member

mat813 commented Oct 16, 2018

Well, we are not willing to rename a variable that is used by base, ports and docs, so, you can patch the files, that's about it.

@teamblubee
Copy link
Author

teamblubee commented Oct 16, 2018

Well, we are not willing to rename a variable that is used by base, ports and docs, so, you can patch the files, that's about it.

It's not about patching out ARCH. It seems like when poudriere starts testport it doesn't go into an active shell because even after ${SETENV} ${MAKE_ENV} in any of the port stages I cannot get them to stick; Makefiles seems to get the wrong values but CMake does not seem to exhibit similar behavior.

I'll put together a sample dummy port that exhibits the behavior and upload it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ports Issue An issue or behavior in the ports framework, not Poudriere question wontfix
Projects
None yet
Development

No branches or pull requests

3 participants