Re: lang/lua: /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

From: Daniel Kalchev <daniel_at_digsys.bg>
Date: Thu, 29 Dec 2011 14:34:58 +0200
On 29.12.11 14:19, O. Hartmann wrote:
> Am 12/29/11 12:59, schrieb Kostik Belousov:
>> On Thu, Dec 29, 2011 at 12:19:40PM +0100, O. Hartmann wrote:
>>> [...]
>>> /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
>>> clang: error: linker command failed with exit code 1 (use -v to see
>>> invocation)
>>> *** Error code 1
>>>
>>> Stop in /usr/ports/lang/lua/work/lua-5.1.4/src.
>>> *** Error code 1
>>>
>>> Stop in /usr/ports/lang/lua/work/lua-5.1.4/src.
>>> *** Error code 1
>>>
>>> Stop in /usr/ports/lang/lua/work/lua-5.1.4.
>>> *** Error code 1
>>>
>>> Stop in /usr/ports/lang/lua.
>>>
>>> ===>>>  make failed for lang/lua
>>> ===>>>  Aborting update
>>>
>>> Terminated
>>> Terminated
>>>
>>> This is very strange!
>> What is strange ? It is exactly the same problem as in the first message
>> started this thread. You must use -fPIC flag for compiler when compiling
>> objects that shall be later linked into dso. So, for lua case, -fPIC
>> must be present on the cc -c command line.
> This therefore strange, since this problem with lua occurs on machines,
> where I've set "CFLAGS=" and "COPTFLAGS=" as in
> /usr/share/examples/etc/make.conf and on one box, one box I accidentally
> set those flags to "CFLAGS+=" and "COPTFLAGS+=" and there it works and
> the -fPIC flag is set by the FreeBSD's port framework.
>
> So I guess there is a bug introduced with one of the last Mk-files updates.
>

As suggested by the "howto" for using newer GCC versions, 
http://www.freebsd.org/doc/en/articles/custom-gcc/article.html you are 
supposed to use CFLAGS+= to add additional compile flags.

By the way, "-O2 -fno-strict-aliasing -pipe" are the default flags, that 
are used when CFLAGS is not set by the user.

COPTFLAGS is used only to build the kernel and doing it with non-system 
GCC is not likely to be safe.

Daniel
Received on Thu Dec 29 2011 - 11:35:10 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:22 UTC