Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jan 2012 16:22:30 -0700
From:      Lee Thomas <lthomas_lists@lthomas.net>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   lang/lua fails to build on 9.0-STABLE amd64 - bug or config issue?
Message-ID:  <522f40f6b20c88cc7b17b4967e09cea6@lthomas.net>

next in thread | raw e-mail | index | archive | help
Hello fellow FreeBSD users,
I ran across an odd issue compiling lua from ports on amd64 with 
FreeBSD 9.0-STABLE, and I'm not sure whether it's a bug or incorrect 
configuration on my part. The lang/lua port throws a linker error, 
claiming to need -fPIC, which is odd because the port Makefile seems to 
have logic to add that in, but somehow the logic seems not to have any 
effect, at least in my case. Making the port Makefile put ${CFLAGS} 
directly into lua's Makefile (patch at the end of this mail) fixes 
matters for me, but I don't understand the port infrastructure well 
enough to understand whether this patch represents a bugfix or a 
workaround of some local configuration issue. Has anyone run into this 
issue before? If this is a config issue, any hints on what might be 
going on or how to dope it out?

Thanks for your help,
Lee Thomas

The details:

#date
Mon Jan 23 18:01:30 EST 2012

#uname -a
FreeBSD Anon 9.0-STABLE FreeBSD 9.0-STABLE #0: Sat Jan 21 10:39:05 EST 
2012 anon@Anon:/usr/obj/usr/src/sys/GENERIC  amd64

#cat /etc/make.conf
CPUTYPE?=nocona
CFLAGS= -O2 -fno-strict-aliasing -pipe
COPTFLAGS= -O -pipe

#csup ports-supfile
Connected to 216.165.129.134
Updating collection ports-all/cvs
Finished successfully

#cd /usr/ports/lang/lua && make clean build
===>  Cleaning for lua-5.1.4_6
===>  Vulnerability check disabled, database not found
===>  License check disabled, port has not defined LICENSE
===>  Extracting for lua-5.1.4_6
=> SHA256 Checksum OK for lua-5.1.4.tar.gz.
=> SHA256 Checksum OK for patch-lua-5.1.4-3.
===>  Patching for lua-5.1.4_6
===>  Applying distribution patches for lua-5.1.4_6
===>  Applying FreeBSD patches for lua-5.1.4_6
===>   lua-5.1.4_6 depends on executable: pkg-config - found
===>  Configuring for lua-5.1.4_6
===>  Building for lua-5.1.4_6
cd src && make freebsd
make all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lapi.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lcode.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c ldebug.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c ldo.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c ldump.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lfunc.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c llex.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lgc.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lmem.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lobject.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lopcodes.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lparser.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lstate.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lstring.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c ltable.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c ltm.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lundump.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lvm.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lzio.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lauxlib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lbaselib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c ldblib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c liolib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c loslib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lmathlib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c ltablib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lstrlib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c loadlib.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c linit.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c lua.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c luac.c
cc -O2 -fno-strict-aliasing -pipe -march=nocona -Wall -DLUA_USE_LINUX 
-c print.c
cc -o liblua.so -O2 -fno-strict-aliasing -pipe -march=nocona -Wall 
-DLUA_USE_LINUX   -shared -Wl,-soname=liblua-5.1.so.1 lapi.o lcode.o 
ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o 
lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o 
lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o 
lstrlib.o loadlib.o linit.o
ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o 
llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o 
ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o ldblib.o liolib.o 
lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o
ranlib liblua.a
/usr/bin/ld: lapi.o: relocation R_X86_64_32 against `luaO_nilobject_' 
can not be used when making a shared object; recompile with -fPIC
lapi.o: could not read symbols: Bad value
*** Error code 1
1 error
*** Error code 2
1 error
*** Error code 2
1 error
*** Error code 1


The following patch fixes matters for me, but I don't understand why it 
should be necessary, which makes me think something might be wrong on my 
end.


--- old/ports/lang/lua/Makefile	2012-01-23 17:15:54.000000000 -0500
+++ new/ports/lang/lua/Makefile	2012-01-23 17:46:35.000000000 -0500
@@ -53,7 +53,7 @@
  	@${REINPLACE_CMD} -Ee \
  		'/^INSTALL_.*=/s/INSTALL_TOP/prefix/ ; \
  		 s|^(CC\|AR\|RANLIB)=|\1?=| ; \
-		 /^CFLAGS=/ { s/=/+=/; s/-O2//; } ; \
+		 /^CFLAGS=/ { s/-O2/${CFLAGS}/; } ; \
  		 s|/usr/local|${PREFIX}|' \
  		 ${WRKSRC}/Makefile ${WRKSRC}/src/Makefile
  	@${REINPLACE_CMD} -i '' -Ee \





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