lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Roberto Ierusalimschy once stated:
> > It was thus said that the Great Roberto Ierusalimschy once stated:
> > > > On Solaris flockfile and friends aren't visible by default. [...]
> > > 
> > > Do you know a reliable environment variable that can be used to detect
> > > Solaris and friends?
> > 
> >   When compiling C code, I check for __SunOS.  As for environment variable,
> > I just logged into our Solaris systems and found
> > 
> > 	$HOSTTYPE
> > 	$MACHTYPE
> > 
> > set ("sparc" and "sparc-sun-solaris2.10" respectively).  I don't know if
> > those will always be set.  
> 
> Can you check whether Lua compiles if you define
> -D_POSIX_C_SOURCE=199506L (or just -D_POSIX_C_SOURCE),
> instead of -D_REENTRANT? Would you have any reason to prefer
> one to another?

  I downloaded Lua 5.1.5, Lua 5.2.3 and Lua 5.3.0-work2 to our Solaris box. 
The system has GCC installed (gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath))
but it did not like 

	__attribute__((visibility("hidden")))

as GCC returns:

	warning: visibility attribute not supported in this configuration; ignored

(it could very well be a custom version of GCC---I don't know, I'm even
surprised we have it installed as we normally don't use GCC for our
compiles).  

  With that fixed, Lua 5.1.5 compiled cleanly.  No issues.

  Lua 5.2.3 compiled with one warning:

gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN    -c -o
ldo.o ldo.c
ldo.c: In function `luaD_throw':
ldo.c:122: warning: `noreturn' function does return

  Lua 5.3.0-work2 generates the following errors:

gcc -O2 -Wall -Wextra -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -c -o ldo.o ldo.c
ldo.c: In function `luaD_throw':
ldo.c:125: warning: `noreturn' function does return

gcc -O2 -Wall -Wextra -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -c -o liolib.o liolib.c
liolib.c: In function `read_line':
liolib.c:404: warning: implicit declaration of function `flockfile'
liolib.c:405: warning: implicit declaration of function `getc_unlocked'
liolib.c:407: warning: implicit declaration of function `funlockfile'

  Now, I don't see _REENTRANT defined anywhere in the Lua codebase.  Adding
-D_POSIX_C_SOURCE did not fix the warnings in liolib.c, plus, it made things
a bit worse:

gcc -O2 -Wall -Wextra -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_POSIX_C_SOURCE    -c -o loslib.o loslib.c
loslib.c: In function _tmpname':
loslib.c:132: warning: implicit declaration of function `mkstemp'
loslib.c: In function _date':
loslib.c:223: warning: implicit declaration of function `gmtime_r'
loslib.c:223: warning: assignment makes pointer from integer without a cast
loslib.c:227: warning: implicit declaration of function `localtime_r'
loslib.c:227: warning: assignment makes pointer from integer without a cast

  -D_POSIX_C_SOURCE=199506L faired better:

gcc -O2 -Wall -Wextra -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_POSIX_C_SOURCE=199506L    -c -o loslib.o loslib.c
loslib.c: In function _tmpname':
loslib.c:132: warning: implicit declaration of function `mkstemp'

  Using -D_GNU_SOURCE fixed the mkstemp() declaration, but we got warnings
for the implicit declaration of flockfile(), getc_unlocked() and
funlockfile().  Defining both _GNU_SOURCE and _POSIX_C_SOURCE=199506L still
left mkstemp() implicitely declared:

gcc -O2 -Wall -Wextra -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_GNU_SOURCE -D_POSIX_C_SOURCE=199506L    -c -o loslib.o loslib.c
loslib.c: In function _tmpname':
loslib.c:132: warning: implicit declaration of function `mkstemp'

  I'm at a loss.

  -spc