Do not collect linker options from binary gems; close
Binary gems are mrbgems that set `spec.bins` in their `mrbgem.rake`,
and usually their names are prefixed with `mruby-bin-`.
MODIFY
lib/mruby/gem.rb
lib/mruby/gem.rb
@@ -119,6 +119,10 @@ module MRuby
@dir.start_with?("#{MRUBY_ROOT}/mrbgems/")
end
+ def bin?
+ @bins.size > 0
+ end
+
def add_dependency(name, *requirements)
default_gem = requirements.last.kind_of?(Hash) ? requirements.pop : nil
requirements = ['>= 0.0.0'] if requirements.empty?
@@ -496,8 +500,10 @@ module MRuby
end
end
- def linker_attrs
- map{|g| g.linker.run_attrs}.transpose
+ def linker_attrs(gem=nil)
+ gems = self.reject{|g| g.bin?} # library gems
+ gems << gem unless gem.nil?
+ gems.map{|g| g.linker.run_attrs}.transpose
end
end # List
end # Gem

MODIFY
tasks/bin.rake
tasks/bin.rake
@@ -6,8 +6,8 @@ MRuby.each_target do |build|
build.bins.each{|bin| build.products << define_installer_if_needed(bin)}
- linker_attrs = build.gems.linker_attrs
build.gems.each do |gem|
+ linker_attrs = build.gems.linker_attrs(gem)
gem.bins.each do |bin|
exe = build.exefile("#{build.build_dir}/bin/#{bin}")
objs = Dir["#{gem.dir}/tools/#{bin}/*.{c,cpp,cxx,cc}"].map do |f|

MODIFY
tasks/libmruby.rake
tasks/libmruby.rake
@@ -16,14 +16,15 @@ MRuby.each_target do
open(t.name, 'w') do |f|
f.puts "MRUBY_CFLAGS = #{cc.all_flags}"
- gem_flags = gems.map { |g| g.linker.flags }
- gem_library_paths = gems.map { |g| g.linker.library_paths }
+ libgems = gems.reject{|g| g.bin?}
+ gem_flags = libgems.map {|g| g.linker.flags }
+ gem_library_paths = libgems.map {|g| g.linker.library_paths }
f.puts "MRUBY_LDFLAGS = #{linker.all_flags(gem_library_paths, gem_flags)} #{linker.option_library_path % "#{build_dir}/lib"}"
- gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
+ gem_flags_before_libraries = libgems.map {|g| g.linker.flags_before_libraries }
f.puts "MRUBY_LDFLAGS_BEFORE_LIBS = #{[linker.flags_before_libraries, gem_flags_before_libraries].flatten.join(' ')}"
- gem_libraries = gems.map { |g| g.linker.libraries }
+ gem_libraries = libgems.map {|g| g.linker.libraries }
f.puts "MRUBY_LIBS = #{linker.option_library % 'mruby'} #{linker.library_flags(gem_libraries)}"
f.puts "MRUBY_LIBMRUBY_PATH = #{libmruby_static}"

Do not collect linker options from binary gems; close #5210

Binary gems are mrbgems that set `spec.bins` in their `mrbgem.rake`,
and usually their names are prefixed with `mruby-bin-`.