Giter Site home page Giter Site logo

Comments (14)

gvvaughan avatar gvvaughan commented on June 2, 2024 1

The lukefile patch is cleaner and simpler so no need to test the ugly patch. Thank you for the fast turnaround, I'll roll this up into a new release shortly :-)

from luaposix.

gvvaughan avatar gvvaughan commented on June 2, 2024

Thanks for the report, I was not aware of the double-underscore fields on CentOS.

I would have expected build-aux/luke to fail the struct field tests and not compile in any references to tm_gmtoff or tm_zone fields, so I think there must be a bug in the luke which I'll look into.

In the mean time, you can force luaposix to build either by adjusting the references in ext/posix/time.c by adding the double underscores, or by forcing luke to use the new fields with the following patch:

--- a/lukefile
+++ b/lukefile
@@ -18,6 +18,7 @@ defines  = {
       unix      = {
          _POSIX_C_SOURCE   = '200809L',
          _XOPEN_SOURCE     = 700,
+         __USE_BSD         = 1,
       },
       -- Otherwise, enable POSIX 2008.   Please send the output of `uname -s` if
       -- your host is not compliant.

Or to turn off use of those fields with:

--- a/lukefile
+++ b/lukefile
@@ -103,8 +104,8 @@ modules  = {
    ['posix.termio']        = 'ext/posix/termio.c',
    ['posix.time']          = {
       defines   = {
-         HAVE_TM_GMTOFF    = {checkmember='struct tm.tm_gmtoff', include='time.h'},
-         HAVE_TM_ZONE      = {checkmember='struct tm.tm_zone', include='time.h'},
+         HAVE_TM_GMTOFF    = 0,
+         HAVE_TM_ZONE      = 0,
       },
       libraries = {
          {

And then reinstalling with:

luarocks make --force

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

I can just continue using version 35.1 for now until you have time to look into it. I just wanted to get it reported since CI builds I ran last night showed this failure.

Thanks for the patch suggestions as well in case I do need to upgrade before then.

from luaposix.

gvvaughan avatar gvvaughan commented on June 2, 2024

On a hunch, I think your issue was caused by the conftests running without -D arguments, and then the actual luaposix modules being compiled with the platform -D arguments. I pushed a new revision to master with a version of luke that sets those arguments consistently. Please try it as follows and let me know, then I'll make a new release that works properly:

luarocks install http://raw.github.com/luaposix/luaposix/master/luaposix-git-1.rockspec

If it builds and installs for you, I'd be interested to learn whether the -D arguments turn off access to the tm_gmtoff and tm_zone fields for your build and if so, whether we can get them enabled with the following change:

diff --git a/lukefile b/lukefile
index 0de5625..2e266eb 100644
--- a/lukefile
+++ b/lukefile
@@ -10,7 +10,10 @@ defines  = {
       aix       = {_ALL_SOURCE       = 1},
       bsd       = {_BSD_SOURCE       = 1},
       freebsd   = {__BSD_VISIBLE     = 1},
-      linux     = {_DEFAULT_SOURCE   = 1},
+      linux     = {
+         _BSD_SOURCE       = 1,
+         _DEFAULT_SOURCE   = 1,
+      },
       macosx    = {_DARWIN_C_SOURCE  = 1},
       -- QNX is only POSIX 2001, but _XOPEN_SOURCE turns off other functions
       -- luaposix can bind.

If that still doesn't work, it would be super helpful for debugging if you could reply with the output from:

git clone https://github.com/luaposix/luaposix.git centos-fix
cd centos-fix
build-aux/luke LUA_DIR="/usr/local/opt/lua" --verbose --debug posix.time

(where LUA_DIR is a directory with lib/liblua.so and include/lua/lua.h inside of it)

If calling luke directly doesn't work properly for any reason, you can edit as follows:

diff --git a/luaposix-git-1.rockspec b/luaposix-git-1.rockspec
index 4647dea..b068f31 100644
--- a/luaposix-git-1.rockspec
+++ b/luaposix-git-1.rockspec
@@ -32,7 +32,7 @@ source = {
 
 build = {
    type = 'command',
-   build_command = '$(LUA) build-aux/luke'
+   build_command = '$(LUA) build-aux/luke --verbose --debug'
       .. ' package="' .. package .. '"'
       .. ' version="' .. _MODREV .. '"'
       .. ' PREFIX="$(PREFIX)"'

And then, from the freshly cloned luaposix working directory, run luarocks make --no-install to get the debug output.

from luaposix.

gvvaughan avatar gvvaughan commented on June 2, 2024

If you are able to get something working from my previous comment, but don't have access to tm_gmtoff and tm_zone fields from Lua, then in the worst case I think the following patch should work:

diff --git a/ext/posix/time.c b/ext/posix/time.c
index 1cf0485..42b7d1e 100644
--- a/ext/posix/time.c
+++ b/ext/posix/time.c
@@ -80,9 +80,13 @@ totm(lua_State *L, int index, struct tm *t)
 	t->tm_isdst = optintfield(L, index, "tm_isdst", 0);
 #if HAVE_TM_GMTOFF
 	t->tm_gmtoff = optintfield(L, index, "tm_gmtoff", 0);
+#elif HAVE___TM_GMTOFF
+	t->__tm_gmtoff = optintfield(L, index, "tm_gmtoff", 0);
 #endif
 #if HAVE_TM_ZONE
 	t->tm_zone = optstringfield(L, index, "tm_zone", NULL);
+#elif HAVE___TM_ZONE
+	t->__tm_zone = optstringfield(L, index, "tm_zone", NULL);
 #endif
 
 	checkfieldnames(L, index, Stm_fields);
@@ -120,9 +124,13 @@ pushtm(lua_State *L, struct tm *t)
 	setintegerfield(t, tm_isdst);
 #if HAVE_TM_GMTOFF
 	setintegerfield(t, tm_gmtoff);
+#elif HAVE___TM_GMTOFF
+	pushintegerfield("tm_gmtoff", t->__tm_gmtoff);
 #endif
 #if HAVE_TM_ZONE
 	setstringfield(t, tm_zone);
+#elif HAVE___TM_ZONE
+	pushstringfield("tm_zone", t->__tm_zone);
 #endif
 
 	settypemetatable("PosixTm");
diff --git a/lukefile b/lukefile
index 0de5625..b3a7458 100644
--- a/lukefile
+++ b/lukefile
@@ -103,6 +103,8 @@ modules  = {
    ['posix.termio']        = 'ext/posix/termio.c',
    ['posix.time']          = {
       defines   = {
+         HAVE___TM_GMTOFF  = {checkmember='struct tm.__tm_gmtoff', include='time.h'},
+         HAVE___TM_ZONE    = {checkmember='struct tm.__tm_zone', include='time.h'},
          HAVE_TM_GMTOFF    = {checkmember='struct tm.tm_gmtoff', include='time.h'},
          HAVE_TM_ZONE      = {checkmember='struct tm.tm_zone', include='time.h'},
       },

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

Ok, initial install command works:

luarocks install http://raw.github.com/luaposix/luaposix/master/luaposix-git-1.rockspec

But I've been away from actual coding in Lua, so I'm having trouble determining if I can access tm_gmtoff and tm_zone fields. I'm doing something wrong and can't remember / figure out why. Do you have a small snippet I can run to check that the way you want to see it?

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

Ok, I think I finally got it, here's what I tried and what I see:

> inspect = require("inspect")
> time = require("posix.time")
> print(inspect(time.gmtime(time.time())))
{
  tm_hour = 21,
  tm_isdst = 0,
  tm_mday = 31,
  tm_min = 59,
  tm_mon = 0,
  tm_sec = 18,
  tm_wday = 2,
  tm_yday = 30,
  tm_year = 123,
  <metatable> = {
    _type = "PosixTm"
  }
}

I don't see any tm_gmtoff or tm_zone being returned. So I'm going to attempt your patches and see what I get.

from luaposix.

gvvaughan avatar gvvaughan commented on June 2, 2024

Yep, no new fields in yours :-( Here's mine:

$ lua 
Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
> time, localtime = require'posix.time'.time, require'posix.time'.localtime
> tm = localtime(time())
> tm.tm_zone
MST
> tm.tm_gmtoff
-25200

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

Here's the output of the luke compile with the patch applied:

❯ build-aux/luke LUA_DIR="/usr" --verbose --debug posix.time
   DEBUG: ldoc not found
checking for ldoc... no
   DEBUG: found /usr/bin/true
checking for true... yes
   DEBUG: found /usr/bin/cc
checking for cc... yes
checking whether cc works... yes
   DEBUG: cc -O2 -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -DPACKAGE='"luaposix"' -DVERSION='"rshaw"' -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -DNDEBUG  -o /tmp/lua_FyDPvE /tmp/lua_hDB8f9.c
checking for library containing clock_gettime...    DEBUG: cc -O2 -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -DPACKAGE='"luaposix"' -DVERSION='"rshaw"' -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -DNDEBUG  -o /tmp/lua_jpPrQF /tmp/lua_lYJWqa.c
none required
   DEBUG: cc -c -O2 -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -DPACKAGE='"luaposix"' -DVERSION='"rshaw"' -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -DNDEBUG  /tmp/lua_IN7lcc.c
checking for struct tm.tm_gmtoff... yes
   DEBUG: cc -c -O2 -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -DPACKAGE='"luaposix"' -DVERSION='"rshaw"' -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -DNDEBUG  /tmp/lua_Is4DSI.c
checking for struct tm.tm_zone... yes
creating build-aux/config.ld
cc -O2 -shared -fPIC   -DHAVE_TM_ZONE -DHAVE_TM_GMTOFF -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DPACKAGE='"luaposix"' -DVERSION='"rshaw"' -D_FORTIFY_SOURCE=2 -D_BSD_SOURCE -D_DEFAULT_SOURCE -DNDEBUG -Iext/include -I/usr/include/lua5.1 ext/posix/time.c -o linux/posix/time.so
true -c build-aux/config.ld .

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

How do I install using that patch to the lukefile so I can test it?

from luaposix.

gvvaughan avatar gvvaughan commented on June 2, 2024

From the patched clone working copy, you can luarocks make --force to have luarocks rebuild with the patched lukefile and install, then your lua interpreter will be able to load it without any CPATH twiddling πŸ‘

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

Ok, I did it a bit roundabout since I didn't see your above comment in time, but I was able to get it installed, and now I see tm_gmtoff and tm_zone in the output:

> time = require("posix.time")
> inspect = require("inspect")
> print(inspect(time.gmtime(time.time())))
{
  tm_gmtoff = 0,
  tm_hour = 22,
  tm_isdst = 0,
  tm_mday = 31,
  tm_min = 15,
  tm_mon = 0,
  tm_sec = 13,
  tm_wday = 2,
  tm_yday = 30,
  tm_year = 123,
  tm_zone = "GMT",
  <metatable> = {
    _type = "PosixTm"
  }
}
> print(inspect(time.localtime(time.time())))
{
  tm_gmtoff = -18000,
  tm_hour = 17,
  tm_isdst = 0,
  tm_mday = 31,
  tm_min = 16,
  tm_mon = 0,
  tm_sec = 27,
  tm_wday = 2,
  tm_yday = 30,
  tm_year = 123,
  tm_zone = "EST",
  <metatable> = {
    _type = "PosixTm"
  }
}

So the very first patch (to lukefile) you listed works. I have not tried the second (longer) patch (to time.c) since this is working.

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

Let me know if you need me to try anything else. I am leaving for a few hours, so won't be able to reply till later tonight.

from luaposix.

robert914 avatar robert914 commented on June 2, 2024

Thanks!

from luaposix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.