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

cross build error for NetBSD/arm #5860

Open
yamori813 opened this issue Nov 29, 2022 · 7 comments
Open

cross build error for NetBSD/arm #5860

yamori813 opened this issue Nov 29, 2022 · 7 comments

Comments

@yamori813
Copy link
Contributor

I use conf.gembox 'default' on cross build on FreeBSD/amd64 for NetBSD/arm.

I have error no libreadline and no libncurses.

I seem cause of mrbgems/mruby-bin-mirb/mrbgem.rake.

I want use libedit.

Also NetBSD 9.99 libedit need libtermcap.

If you have advice, please let me know.

Thanks

@matz
Copy link
Member

matz commented Nov 30, 2022

Show us the error messages.

@yamori813
Copy link
Contributor Author

% rake MRUBY_CONFIG=netbsd
LD    build/cross-netbsd-arm/bin/mirb 
/usr/home/hiroki/netbsd-tools/earmv4/lib/gcc/armv4--netbsdelf-eabi/10.4.0/../../../../armv4--netbsdelf-eabi/bin/ld: cannot find -lreadline
/usr/home/hiroki/netbsd-tools/earmv4/lib/gcc/armv4--netbsdelf-eabi/10.4.0/../../../../armv4--netbsdelf-eabi/bin/ld: cannot find -lncurses
collect2: error: ld returned 1 exit status
rake aborted!
Command failed with status (1): [/usr/home/hiroki/netbsd-tools/earmv4/bin/a...]
/usr/home/hiroki/mruby-3.1.0/lib/mruby/build/command.rb:37:in `_run'
/usr/home/hiroki/mruby-3.1.0/lib/mruby/build/command.rb:217:in `run'
/usr/home/hiroki/mruby-3.1.0/tasks/bin.rake:17:in `block (4 levels) in <top (required)>'
/usr/home/hiroki/mruby-3.1.0/Rakefile:42:in `block in <top (required)>'
Tasks: TOP => build => /usr/home/hiroki/mruby-3.1.0/build/cross-netbsd-arm/bin/mirb
(See full trace by running task with --trace)

@dearblue
Copy link
Contributor

I don't know if this is correct, but how about replacing the library by calling mruby-bin-mirb with a block before gembox "default", as in the following example?

MRuby::CrossBuild.new("netbsd") do |conf|
  conf.toolchain "gcc"
  conf.gem core: "mruby-bin-mirb" do |spec|
    spec.linker.libraries = %w(edit termcap)
  end
  conf.gembox "default"
end

mruby-bin-mirb cannot automatically cross build to/from NetBSD for reasons determined by RUBY_PLATFORM.

if RUBY_PLATFORM.include?('netbsd')
spec.linker.libraries << 'edit'
else
spec.linker.libraries << 'readline'

Some improvement is needed, but I have no ideas.

@yamori813
Copy link
Contributor Author

This replacing workaround is fine on my environment.

@yamori813
Copy link
Contributor Author

yamori813 commented Dec 13, 2022

Same problem on this case.

https://qiita.com/yamori813/items/5153efb2ec0a23bfa7fb

I think good that is RUBY_PLATFORM set "NetBSD" at build_config. And use is value in mrbgem.rake. But RUBY_PLATFORM is confuse host and target now.

@matz
Copy link
Member

matz commented Dec 14, 2022

Probably, we need to distinguish host and target during the build (and use target info instead of RUBY_PLATFORM).

@dearblue
Copy link
Contributor

dearblue commented Jan 1, 2023

The RUBY_PLATFORM constant is defined by Ruby, so I don't think it is desirable to make any changes to it.
I also think that introducing another constant to check the build target is undesirable, as it leads to writing code that assumes the environment to be a prerequisite by name.

How about introducing methods for "feature check" (such as have_library or have_macro) defined in Ruby's mkmf.rb library?
However, I would like to have a mechanism to avoid this, since there is a possibility that these methods will be called every time just by rake clean, for example.

Example?:

# mygem/mrbgem.rake
MRuby::Gem::Specification.new("mygem") do |spec|
  ....
  spec.before_compile do
    case
    when spec.have_library "edit"
      ....
    when spec.have_library "readline"
      ....
    else
      ....
    end
  end
end

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

No branches or pull requests

3 participants