From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Bronnikov <sergeyb@tarantool.org>
Cc: Sergey Bronnikov <estetus@gmail.com>,
tarantool-patches@dev.tarantool.org, max.kokryashkin@gmail.com
Subject: Re: [Tarantool-patches] [PATCH luajit 1/2][v2] Fix embedded bytecode loader.
Date: Mon, 11 Sep 2023 11:45:46 +0300 [thread overview]
Message-ID: <ZP7Tuq_eo-Ek_yBl@root> (raw)
In-Reply-To: <272d18bd-5333-1224-31c3-8d59475f6afc@tarantool.org>
Hi, Sergey!
Thanks for the fixes!
On 07.09.23, Sergey Bronnikov wrote:
> Hi, Sergey
>
>
> On 9/5/23 17:10, Sergey Kaplun wrote:
> > Hi, Sergey!
> > Thanks for the patch!
> > Please, consider my comments below.
> >
> > On 31.08.23, Sergey Bronnikov wrote:
> >> From: Sergey Bronnikov <sergeyb@tarantool.org>
> >>
<snipped>
> >
> >> +end
> >> +
> >> +local function get_file_name(file)
> >> + return file:match("[^/]*$")
> > Minor: it may match the empty string for a directory occasionally:
> > | src/luajit -e 'print([["]]..("/tmp/"):match("[^/]*$")..[["]])'
>
>
> Fixed.
>
> > | ""
> >
> > Nit: use single quotes instead of double quotes if possible.
>
> Without context it is difficult to get what is line you talk about.
>
> As I see everything is fine with quotes in version on the branch.
>
I'm talking about the same line (got this version from the branch):
| +local function basename(path)
| + return path:match("[^/]*$")
| +end
>
> >
> > Nit: `[^/\\]` is better since it also covers Windows.
> > See <test/lua-Harness-tests/314-regex.t:167>
> > | local dirname = arg[0]:gsub('([^/\\]+)$', '')
> > Since we don't support Windows feel free to ignore.
> >
> >> +end
> >> +
> >> +local stdout_msg = 'Lango team'
> >> +local lua_code = ('print(%q)'):format(stdout_msg)
> >> +local fpath = os.tmpname()
> >> +local path_lua = ('%s.lua'):format(fpath)
> >> +local path_c = ('%s.c'):format(fpath)
> >> +local path_so = ('%s.so'):format(fpath)
> > Minor: I suppose it should be renamed to `path_shared`, since on macOS
> > they have the ".dyld" suffix for shared libs. Hence, we need to use the
> > suffix in format of the shared library name too. You may take some
> > inspiration from here [1].
> Fixed.
Hmm, I don't see these updates on the branch [1]. Maybe you forgot to push
your local changes to the repository (*)?
> >> +
<snipped>
> >> +local basedir = function(path)
> >> + local sep = '/'
> > Why do we need an additional variable here?
>
> For clarity.
OK.
>
>
> >
> > Nit: Indent is 4 spaces instead of 2.
> >
> >> + return path:match('(.*' .. sep .. ')') or './'
> > It's better to mention that the pattern matching is greedy, so we match
> > until the last separator.
>
>
> Updated.
This is missing too (*).
>
> >> +end
> >> +
> >> +-- Create a C file with LuaJIT bytecode.
> >> +-- We cannot use utils.makecmd, because command-line generated
> >> +-- by `makecmd` contains `-e` that is incompatible with option `-b`.
> > Nit: comment line width is more than 66 symbols
>
> Fixed.
>
>
> >> +local function create_c_file(pathlua, pathc)
> >> + local lua_path = os.getenv('LUA_PATH')
> >> + local lua_bin = require('utils').exec.luacmd(arg):match('%S+')
> >> + local cmd_fmt = 'LUA_PATH="%s" %s -b %s %s'
> >> + local cmd = (cmd_fmt):format(lua_path, lua_bin, pathlua, pathc)
> >> + local ret = os.execute(cmd)
> >> + assert(ret == 0, 'create a C file with bytecode')
> >> +end
> >> +
> >> +create_c_file(path_lua, path_c)
> >> +assert(file_exists(path_c))
> > Minor: The test flow is a little bit hard to read due to function
> > declarations. Maybe it is better to declare all utility functions first
> > and then use them one by one? This makes control flow easier to read.
> Rearranged, take a look please.
Yes, this is muchc clearer, thanks!
> >
> >> +
<snipped>
> >
> >> + -- It is required to cleanup LUA_PATH, otherwise
> >> + -- LuaJIT loads Lua module, see tarantool-tests/utils/init.lua.
> > Nit: comment line width is more than 66 symbols
> Fixed too.
> >
> > Actually I don't understand from the comment what Lua module exactly is
> > loaded. Maybe it's better to fix this behaviour?
> What behaviour you want to fix?
That some non-existing module was loaded with `makecmd()`, but since we
have a workaround, maybe it isn't critical.
Anyway, we should do it in a separate patch set.
Feel free to ignore, as I've said.
> > Feel free to ignore.
> >
> >> + LUA_PATH = '',
<snipped>
> >
[1]: https://github.com/tarantool/luajit/blob/f7e5e8abe396411065f8941d04879577e7fae175/test/tarantool-tests/lj-549-bytecode-loader.test.lua#L54
--
Best regards,
Sergey Kaplun
next prev parent reply other threads:[~2023-09-11 8:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 11:29 [Tarantool-patches] [PATCH luajit 0/2][v2] " Sergey Bronnikov via Tarantool-patches
2023-08-31 11:30 ` [Tarantool-patches] [PATCH luajit 1/2][v2] " Sergey Bronnikov via Tarantool-patches
2023-08-31 11:49 ` Sergey Bronnikov via Tarantool-patches
2023-09-01 9:42 ` Maxim Kokryashkin via Tarantool-patches
2023-09-04 9:31 ` Sergey Bronnikov via Tarantool-patches
2023-09-05 6:34 ` Maxim Kokryashkin via Tarantool-patches
2023-09-05 14:10 ` Sergey Kaplun via Tarantool-patches
2023-09-07 15:21 ` Sergey Bronnikov via Tarantool-patches
2023-09-11 8:45 ` Sergey Kaplun via Tarantool-patches [this message]
2023-09-12 10:20 ` Sergey Bronnikov via Tarantool-patches
2023-10-31 11:30 ` Sergey Kaplun via Tarantool-patches
2023-09-05 14:12 ` Sergey Kaplun via Tarantool-patches
2023-09-07 7:06 ` Sergey Bronnikov via Tarantool-patches
2023-08-31 11:32 ` [Tarantool-patches] [PATCH luajit 2/2][v2] Followup fix for " Sergey Bronnikov via Tarantool-patches
2023-09-01 10:05 ` Maxim Kokryashkin via Tarantool-patches
2023-09-04 16:34 ` Sergey Bronnikov via Tarantool-patches
2023-09-05 6:45 ` Maxim Kokryashkin via Tarantool-patches
2023-09-05 12:55 ` Sergey Kaplun via Tarantool-patches
2023-09-07 7:04 ` Sergey Bronnikov via Tarantool-patches
2023-09-11 9:26 ` Sergey Kaplun via Tarantool-patches
2023-09-12 10:30 ` Sergey Bronnikov via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZP7Tuq_eo-Ek_yBl@root \
--to=tarantool-patches@dev.tarantool.org \
--cc=estetus@gmail.com \
--cc=max.kokryashkin@gmail.com \
--cc=sergeyb@tarantool.org \
--cc=skaplun@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH luajit 1/2][v2] Fix embedded bytecode loader.' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox