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

install native and cross lua executables & add LuaRocks plugin #1017

Merged
merged 12 commits into from
Dec 6, 2015

Conversation

starius
Copy link
Member

@starius starius commented Nov 29, 2015

No description provided.

@starius starius mentioned this pull request Nov 29, 2015
--with-lua-bin='$(PREFIX)/bin' \
--with-downloader='wget' \
--with-md5-checker='openssl'
$(MAKE) -C '$(1)' build install \
Copy link
Member

Choose a reason for hiding this comment

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

install doesn't depend on build so (on OSX) the symlink is created first and doesn't have execute permissions. These steps should be separated.

@tonytheodore
Copy link
Member

Looks good!

Plugins currently require some boilerplate:

$(PKG)_MAKEFILE := $(lastword $(MAKEFILE_LIST))

for updates to work, I might see if there's some sort of include hook so it isn't necessary.

Additional metadata like:

$(PKG)_WEBSITE  := http://www.gnu.org/software/automake
$(PKG)_OWNER    := https://github.com/starius

may also be useful, but the REAMDE is an excellent approach.

$(WGET) -q -O- 'http://www.inf.puc-rio.br/~roberto/lpeg/' | \
$(SED) -n 's,.*lpeg-\([0-9][^>]*\)\.tar.*,\1,p' | \
sort -h | tail -1
endef
Copy link
Member

Choose a reason for hiding this comment

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

$(SORT)

@tonytheodore
Copy link
Member

Plugins currently require some boilerplate:

See 2944ccd, $(PKG)_MAKEFILE is no longer needed.

How to build all packages from a particular plugin? from #935 (comment)

There's also now an automatic all-<plugin> target which is the last segment of the plugin path. all-rocks.mk can be removed and make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks ... will work.

starius added a commit to LuaAndC/mxe that referenced this pull request Dec 1, 2015
> install doesn't depend on build so (on OSX) the symlink is
> created first and doesn't have execute permissions. These
> steps should be separated.

See mxe#1017
starius added a commit to LuaAndC/mxe that referenced this pull request Dec 1, 2015
starius added a commit to LuaAndC/mxe that referenced this pull request Dec 1, 2015
... instead of $(PREFIX)/bin, not to clobber the user's normal
tools.

See mxe#1017
starius added a commit to LuaAndC/mxe that referenced this pull request Dec 1, 2015
> There's also now an automatic all-<plugin> target which is the
> last segment of the plugin path. all-rocks.mk can be removed
> and make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks ...
> will work.

See mxe#1017
starius added a commit to LuaAndC/mxe that referenced this pull request Dec 1, 2015
... instead of $(PREFIX)/bin, not to clobber the user's normal
tools.

See mxe#1017
starius added a commit to LuaAndC/mxe that referenced this pull request Dec 1, 2015
> There's also now an automatic all-<plugin> target which is the
> last segment of the plugin path. all-rocks.mk can be removed
> and make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks ...
> will work.

See mxe#1017
@starius
Copy link
Member Author

starius commented Dec 1, 2015

I have taken into account all the comments.

Build on Wheezy produces broken lua.exe / lua53.dll. It can't find libgcc_s_sjlj-1.dll.

$ make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks MXE_TARGETS='i686-w64-mingw32.shared x86_64-w64-mingw32.shared'

$ ./usr/bin/i686-w64-mingw32.shared-lua 
err:module:import_dll Library libgcc_s_sjlj-1.dll (which is needed by L"Z:\\home\\mxe\\mxe-luarocks-review\\usr\\i686-w64-mingw32.shared\\bin\\lua53.dll") not found
err:module:import_dll Library lua53.dll (which is needed by L"Z:\\home\\mxe\\mxe-luarocks-review\\usr\\i686-w64-mingw32.shared\\bin\\lua.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\mxe\\mxe-luarocks-review\\usr\\i686-w64-mingw32.shared\\bin\\lua.exe" failed, status c0000135

@tonytheodore
Copy link
Member

Build on Wheezy produces broken lua.exe / lua53.dll. It can't find libgcc_s_sjlj-1.dll

Is it only Wheezy and/or lua.exe? The gcc *.dlls are in a version-specific subdir in case we were going to do side-by-side gcc versions (which now seems unlikely).

Does moving the *.dlls the the parent dir work?

@starius
Copy link
Member Author

starius commented Dec 2, 2015

It doesn't depend on Wheezy/Jessie.

Clean installation:

$ make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks MXE_TARGETS='i686-w64-mingw32.shared x86_64-w64-mingw32.shared'
$ find usr/ -name libgcc_s_sjlj-1.dll
usr/i686-w64-mingw32.shared/bin/gcc-4.9.3/libgcc_s_sjlj-1.dll

Old installation (gcc rebuilt):

$ find usr/ -name libgcc_s_sjlj-1.dll
usr/i686-w64-mingw32.shared/bin/libgcc_s_sjlj-1.dll
usr/i686-w64-mingw32.shared/bin/gcc-4.9.3/libgcc_s_sjlj-1.dll

@tonytheodore
Copy link
Member

I'm not sure what just happened. I tried creating a pull request using the web interface and it created the branch but seems to have merged it without a pull request ae8f6de.

@tonytheodore
Copy link
Member

Reverted now 38a9ead, I'll do a proper fix tomorrow.

@starius
Copy link
Member Author

starius commented Dec 2, 2015

For the record, the problem seems to be introduced by 9020e9e, #965.

@tonytheodore
Copy link
Member

See #1032

@tonytheodore
Copy link
Member

llthreads2, lpeg, and lua-rapidjson depend on luasocket:

$ make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks -j4
[build]     lua                    i686-w64-mingw32.shared
[done]      lua                    i686-w64-mingw32.shared                                2380 KiB       0m6.850s
[build]     luarocks               i686-w64-mingw32.shared
[done]      luarocks               i686-w64-mingw32.shared                                732 KiB        0m6.548s
[build]     llthreads2             i686-w64-mingw32.shared
[build]     lpeg                   i686-w64-mingw32.shared
[build]     lua-rapidjson          i686-w64-mingw32.shared
[build]     luasocket              i686-w64-mingw32.shared

Failed to build package llthreads2 for target i686-w64-mingw32.shared!
------------------------------------------------------------
/Users/tonyt/dev/mxe/usr/bin/i686-w64-mingw32.shared-gcc -shared -o llthreads2.dll -L/Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/lib src/l52util.obj src/llthread.obj -lkernel32 -llua
No existing manifest. Attempting to rebuild...
Updating manifest for /Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/lib/luarocks/rocks
Error: rock_manifest file not found for luasocket scm-0 - not a LuaRocks 2 tree?
make[1]: *** [build-only-llthreads2_i686-w64-mingw32.shared] Error 1
real    0m6.847s
user    0m6.154s
sys 0m0.606s
------------------------------------------------------------
[log]      /Users/tonyt/dev/mxe/log/llthreads2_i686-w64-mingw32.shared

make: *** [/Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/installed/llthreads2] Error 1
make: *** Waiting for unfinished jobs....

Failed to build package lpeg for target i686-w64-mingw32.shared!
------------------------------------------------------------
/Users/tonyt/dev/mxe/usr/bin/i686-w64-mingw32.shared-gcc -shared -o lpeg.dll -L/Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/lib lpcap.obj lpcode.obj lpprint.obj lptree.obj lpvm.obj -llua
No existing manifest. Attempting to rebuild...
Updating manifest for /Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/lib/luarocks/rocks
Error: rock_manifest file not found for luasocket scm-0 - not a LuaRocks 2 tree?
make[1]: *** [build-only-lpeg_i686-w64-mingw32.shared] Error 1
real    0m7.079s
user    0m6.417s
sys 0m0.575s
------------------------------------------------------------
[log]      /Users/tonyt/dev/mxe/log/lpeg_i686-w64-mingw32.shared

make: *** [/Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/installed/lpeg] Error 1

Failed to build package lua-rapidjson for target i686-w64-mingw32.shared!
------------------------------------------------------------
-- Installing: /Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/lib/luarocks/rocks/rapidjson/0.2.2-1/lib/rapidjson.dll
No existing manifest. Attempting to rebuild...
Updating manifest for /Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/lib/luarocks/rocks
Error: rock_manifest file not found for luasocket scm-0 - not a LuaRocks 2 tree?
make[1]: *** [build-only-lua-rapidjson_i686-w64-mingw32.shared] Error 1
real    0m11.512s
user    0m10.398s
sys 0m0.916s
------------------------------------------------------------
[log]      /Users/tonyt/dev/mxe/log/lua-rapidjson_i686-w64-mingw32.shared

make: *** [/Users/tonyt/dev/mxe/usr/i686-w64-mingw32.shared/installed/lua-rapidjson] Error 1
[done]      luasocket              i686-w64-mingw32.shared                                2340 KiB       0m12.423s

Easy fix tonytheodore@297f697

@starius
Copy link
Member Author

starius commented Dec 3, 2015

llthreads2, lpeg, and lua-rapidjson do not depend on luasocket. None of them needs network. Can you show logs for llthreads2, lpeg, and lua-rapidjson, please? Probably the build was failed because of race condition (-j4). Luarocks updates information about rocks installed and it seems to do it without synchronization between multiple processes. If it is true, some kind of mutex should be introduced to prevent this.

Another possible reason of printing luasocket in error logs of other rocks is that the build from the local rockspec failed for some reason and luarocks tried to download rocks from luarocks.org. Luarocks uses wget or luasocket for downloading. This behaviour should be suppressed in MXE.

@tonytheodore
Copy link
Member

Can you show logs for llthreads2, lpeg, and lua-rapidjson, please?

Only llthreads2 and lpeg this time: https://gist.github.com/tonytheodore/7765744f895cdad87035

Luarocks uses wget or luasocket for downloading. This behaviour should be suppressed in MXE.

The PRELOAD trick is working on OSX now, disabling it always succeeds:

make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks -j4 PRELOAD=

@tonytheodore
Copy link
Member

Luarocks updates information about rocks installed and it seems to do it without synchronization between multiple processes. If it is true, some kind of mutex should be introduced to prevent this.

A workaround is to put a .NOTPARALLEL target in one of the files:

diff --git a/plugins/luarocks/luarocks.mk b/plugins/luarocks/luarocks.mk
index b7cbbae..51209bb 100644
--- a/plugins/luarocks/luarocks.mk
+++ b/plugins/luarocks/luarocks.mk
@@ -18,6 +18,10 @@ define $(PKG)_UPDATE
     $(SORT) -h | tail -1
 endef

+# Luarocks updates information about rocks installed and it seems
+# to do it without synchronization between multiple processes.
+.NOTPARALLEL:
+
 # shared-only because Lua loads modules in runtime

 define $(PKG)_BUILD_SHARED

@starius
Copy link
Member Author

starius commented Dec 5, 2015

I wrapped luarocks main tool with bash script which provides a mutex based on mkdir.
See http://wiki.bash-hackers.org/howto/mutex for the explanation
Please test if it works for you.

@tonytheodore
Copy link
Member

Thanks, the lock dir needs to exist:

diff --git a/plugins/luarocks/luarocks.mk b/plugins/luarocks/luarocks.mk
index 10131ee..a852c37 100644
--- a/plugins/luarocks/luarocks.mk
+++ b/plugins/luarocks/luarocks.mk
@@ -39,6 +39,7 @@ define $(PKG)_BUILD_SHARED

     # create bash wrapper adding inter-process mutex
     # see https://github.com/mxe/mxe/pull/1017#issuecomment-161557440
+    $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/luarocks'
     (echo '#!/usr/bin/env bash'; \
      echo 'echo "== Using MXE wrapper: $(PREFIX)/$(TARGET)/bin/luarocks"'; \
      echo '# Creating a directory is an atomic operation, that is why'; \

and it all works well!

starius pushed a commit to LuaAndC/mxe that referenced this pull request Dec 6, 2015
@starius
Copy link
Member Author

starius commented Dec 6, 2015

Fixed.

@tonytheodore
Copy link
Member

Do you want to do any rebasing? Otherwise I think this is ready to merge.

starius and others added 12 commits December 6, 2015 05:38
LuaRocks plugin adds

  * package "luarocks"
  * several packages with rocks (lpeg, luasocket, llthreads2, lua-rapidjson)
  * plugins/luarocks/README.md
  * virtual rock "all-rocks" depending on all rocks
  * short test for rocks
> install doesn't depend on build so (on OSX) the symlink is
> created first and doesn't have execute permissions. These
> steps should be separated.

See mxe#1017
... instead of $(PREFIX)/bin, not to clobber the user's normal
tools.

See mxe#1017
> There's also now an automatic all-<plugin> target which is the
> last segment of the plugin path. all-rocks.mk can be removed
> and make all-luarocks MXE_PLUGIN_DIRS=plugins/luarocks ...
> will work.

See mxe#1017
@starius
Copy link
Member Author

starius commented Dec 6, 2015

Rebased

starius added a commit that referenced this pull request Dec 6, 2015
install native and cross lua executables & add LuaRocks plugin
@starius starius merged commit 99af3f7 into mxe:master Dec 6, 2015
@starius starius deleted the luarocks2 branch December 6, 2015 02:44
@tonytheodore
Copy link
Member

Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants