You can do it from Lua without luac using string.dump. Try for instance
f=assert(io.open("luac.out","wb"))
assert(f:write(string.dump(assert(loadfile("foo.lua")))))
assert(f:close())
If the code to be compiled is in a string, use load(s).
You can also save the file below as luac.luaand run it from the command line:
-- bare-bones luac in Lua
-- usage: lua luac.lua file.lua
assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua")
f=assert(io.open("luac.out","wb"))
assert(f:write(string.dump(assert(loadfile(arg[1])))))
assert(f:close())