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

Static build #GSoC #712

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Static build #GSoC #712

wants to merge 14 commits into from

Conversation

robooo
Copy link
Contributor

@robooo robooo commented Jun 28, 2017

LuaRocks currently builds Lua modules as dynamic libraries. The aim of this PR is to add support for building static libraries and create new command static_flags to list all dependencies (static libs with specific flags) for module. Idea of this project is by @daurnimator and was implemented as a part of Google Summer of Code internship. #GSoC

https://summerofcode.withgoogle.com/projects/#5735758504656896

@@ -389,17 +390,18 @@ end
-- @return boolean or (nil, string, exitcode): True if build was successful; nil and an
-- error message otherwise. exitcode is optionally returned.
function build.command(flags, name, version)
local deps_mode = deps.get_deps_mode(flags)
Copy link
Member

Choose a reason for hiding this comment

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

With this line you can also pass deps_mode directly to manif.check_dependencies below.

--- Driver function for the builtin build back-end.
-- @param rockspec table: the loaded rockspec.
-- @param flags table: the flags table passed to run() drivers.
Copy link
Member

Choose a reason for hiding this comment

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

This annotation seems to be in the wrong commit.

@@ -49,7 +49,8 @@ To install rocks, you'll normally want to use the "install" and
]]

--- Driver function for "make" command.
-- @param name string: A local rockspec.
-- @param flags table: the flags table passed to run() drivers.
Copy link
Member

Choose a reason for hiding this comment

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

Annotation change in wrong commit?

local extras = {}
add_flags(extras, "-D%s", defines, variables)
add_flags(extras, "-I%s", incdirs, variables)
return execute(variables.CC.." "..variables.CFLAGS, "-I"..variables.LUA_INCDIR, "-c", source, "-o", object, unpack(extras))
end
if flags["static"] then
Copy link
Member

Choose a reason for hiding this comment

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

You can create this function unconditionally. Only the calling of it needs to be conditional on flags.

@hishamhm
Copy link
Member

hishamhm commented Jul 3, 2017

Also, any idea on why the Travis build failed?

@mpeterv
Copy link
Contributor

mpeterv commented Jul 3, 2017

Could be a bug in the relatively recently released LuaJIT 2.1.0-beta3.

@daurnimator
Copy link
Member

Also, any idea on why the Travis build failed?

Yes. there is a bug in lua-cjson that makes it incompatible with the latest luajit 2.1. It's a known issues that can be ignored. LuaJIT/LuaJIT#325

end
local ok = compile_object(object, source, info.defines, info.incdirs)
if not ok then
return nil, "Failed compiling object "..object
Copy link
Contributor

Choose a reason for hiding this comment

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

So, build_objects can return nil and error message, but callers do not check it, causing an error later when nil is used instead of objects array, like in the travis failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I add control of nil objects before calling build_objects?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it should be after build_objects. Just like build_objects catches that compile_object can return nil and propagates the error, builtin.run should check if build_objects returned nil and handle it.

@mpeterv
Copy link
Contributor

mpeterv commented Jul 4, 2017

@daurnimator right. Tweaking .travis.yml and appveyor.yml to install LuaJIT 2.1.0-beta2 specifically should work for now.

@robooo robooo force-pushed the static_build branch 5 times, most recently from 4279a20 to dd7a061 Compare July 16, 2017 19:49

if #rockspec.dependencies > 0 then
for _, dep in ipairs(rockspec.dependencies) do
if not dep.name:match("lua$") then
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be recursive. i.e. we also need flags of dependencies of dependencies ....... of dependencies

@robooo robooo force-pushed the static_build branch 17 times, most recently from 17de702 to 2f7341a Compare July 24, 2017 15:20
@robooo robooo force-pushed the static_build branch 2 times, most recently from 7ec7652 to f5843c2 Compare August 27, 2017 12:59
if not fs.exists(lib_name) then
return nil, "Library ".. lib_name .." is missing. Verify location of library or create it with 'luarocks make --static <module>'."
end
table.insert(libs_table, "luarocks-"..module_name..".a")
Copy link
Member

Choose a reason for hiding this comment

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

Use lib_name here?

@robooo robooo force-pushed the static_build branch 4 times, most recently from 647422c to 051b392 Compare September 1, 2017 12:41
@robooo robooo changed the title Static build Static build #GSoC Sep 4, 2017
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.

None yet

5 participants