Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luaPackages.bit32: Tiny patch to fix a LuaJIT-incompatible declaration #63569

Merged
merged 1 commit into from Jun 28, 2019

Conversation

Shados
Copy link
Member

@Shados Shados commented Jun 20, 2019

Motivation for this change

Makes it build cleanly against LuaJIT.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@vcunat
Copy link
Member

vcunat commented Jun 23, 2019

The patch is certainly fine, though that just avoids a warning without any real effect. Have you tested in some way that the resulting package works well?

@teto
Copy link
Member

teto commented Jun 24, 2019

is that sthg that is supported upstream ? else it could bring trouble putting it into nixpkgs. I remember sthg about bit32 being embedded for 5.1 but a separate package for 5.2 etc.

@Shados
Copy link
Member Author

Shados commented Jun 24, 2019

@vcunat it should do, although I haven't checked. I'll do that shortly.

@teto you have it the wrong way around -- bit32 was added as a builtin module in Lua 5.2, and backported as a stand-alone module for 5.1.

I was mostly just being conservative in adding the isLuaJIT check to disabled originally, as I didn't want to diagnose the compile warning at that point (wanted to focus on moving the larger PR along). LuaJIT is ultimately API and ABI compatible with Lua 5.1, and as this stand-alone bit32 module is meant to target 5.1, it should work fine.

@Shados
Copy link
Member Author

Shados commented Jun 24, 2019

@vcunat I just did some very non-exhaustive testing (required the module, called some functions), seems to work fine with LuaJIT, as expected.

# Small patch in order to no longer redefine a Lua 5.2 function that Luajit
# 2.1 also provides, see https://github.com/LuaJIT/LuaJIT/issues/325 for
# more
patches = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we patch just for isLua51 then, like patches = optionals isLua51 ./bit32.patch;.
It would limit potential issues to lua51 (some damage control).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Re)defining these macros is quite safe, as their exact implementation is even documented (and doesn't change AFAIK).

@teto
Copy link
Member

teto commented Jun 24, 2019

ok then. I don't think it should be patched unconditionnally though see my comment.

@vcunat
Copy link
Member

vcunat commented Jun 24, 2019

Hmm, disabled is completely removed, so the module makes sense on all versions, right? It's a bit messy, as 5.1 (and LuaJIT) didn't have builtin bit32 yet, 5.2 officially added it and 5.3 deprecated it. Moreover LuaJIT has bit which also exists as a library for other versions.

@teto
Copy link
Member

teto commented Jun 24, 2019

The generated package contains disabled = (luaOlder "5.1"); so it should be fine

@vcunat
Copy link
Member

vcunat commented Jun 24, 2019

We don't even have any lua older than 5.1 anymore.

@Shados
Copy link
Member Author

Shados commented Jun 24, 2019

@vcunat @teto Luarocks has some provision for tracking "builtin" modules, and it has bit32listed as a builtin for Lua 5.2 and 5.3, meaning it doesn't actually download/install the module for those Lua versions even if it is listed as a dependency.

We could maybe come up with some similar mechanism in nixpkgs, perhaps by universally removing bit32 from the inputs of Lua packages if they're being built for Lua >= 5.2?

@Shados
Copy link
Member Author

Shados commented Jun 24, 2019

@vcunat also please note, the semantics of LuaJIT's bit/BitOP module are not quite the same as PUC Lua's bit32, unfortunately, so they're not always interchangeable (FWIR some of the overflow behaviour is different).

@vcunat
Copy link
Member

vcunat commented Jun 24, 2019

Yes, I didn't mean to imply they're interchangeable.

# Small patch in order to no longer redefine a Lua 5.2 function that Luajit
# 2.1 also provides, see https://github.com/LuaJIT/LuaJIT/issues/325 for
# more
patches = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Re)defining these macros is quite safe, as their exact implementation is even documented (and doesn't change AFAIK).

@vcunat vcunat merged commit 4cdbc77 into NixOS:master Jun 28, 2019
vcunat added a commit that referenced this pull request Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants