When gem's binary commands are built, all gem's linker options are specified as below. What is the intent of this?
|
gem.bins.each do |bin| |
|
exec = exefile("#{build_dir}/bin/#{bin}") |
|
objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx,cc}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) } |
|
|
|
file exec => objs + target.libraries do |t| |
|
gem_flags = gems.map { |g| g.linker.flags } |
|
gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries } |
|
gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries } |
|
gem_libraries = gems.map { |g| g.linker.libraries } |
|
gem_library_paths = gems.map { |g| g.linker.library_paths } |
|
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries, gem_flags_after_libraries |
|
end |
I think they may not build as intended if other gem's linker options are specified. For example, the following example cannot be built on Mac because an unintended library is linked.
# mruby-foo/mrbgem.rb
MRuby::Gem::Specification.new('mruby-foo') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'example'
spec.bins << "foo"
spec.linker.library_paths << "/usr/lib"
end
// mruby-foo/tools/foo/main.c
int main(){return 0;}
# config.rb
MRuby::Lockfile.disable
MRuby::Build.new() do |conf|
conf.toolchain :clang
conf.gem path: "mruby-foo"
conf.gem core: "mruby-bin-mirb"
conf.enable_debug
end
$ rake CONFIG=config.rb -mv
(snip)
LD build/host/bin/mirb
clang -L/usr/lib -L/usr/local/lib -o "/mruby/build/host/bin/mirb" "/mruby/build/host/mrbgems/mruby-bin-mirb/tools/mirb/mirb.o" "/mruby/build/host/lib/libmruby.a" -lm -lreadline -lncurses
Undefined symbols for architecture x86_64:
"_rl_free", referenced from:
_main in mirb.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!
When gem's binary commands are built, all gem's linker options are specified as below. What is the intent of this?
mruby/Rakefile
Lines 71 to 82 in f6ad163
I think they may not build as intended if other gem's linker options are specified. For example, the following example cannot be built on Mac because an unintended library is linked.