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

how to use arm-linux-gcc ? #1603

Open
sevk opened this issue Dec 4, 2013 · 11 comments
Open

how to use arm-linux-gcc ? #1603

sevk opened this issue Dec 4, 2013 · 11 comments

Comments

@sevk
Copy link

sevk commented Dec 4, 2013

something like this :

MRuby::CrossBuild.new('32bit') do |conf|
  toolchain :"arm-linux-gcc"
  conf.cc.flags << "-m32"
  conf.linker.flags << "-m32"
  conf.build_mrbtest_lib_only
  conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
  conf.test_runner.command = 'env'
end

my cross build tools is :

arm-linux-addr2line     arm-linux-cpp           arm-linux-gcov          arm-linux-populate
arm-linux-ar            arm-linux-ct-ng.config  arm-linux-gprof         arm-linux-ranlib
arm-linux-as            arm-linux-g++           arm-linux-ld            arm-linux-readelf
arm-linux-c++           arm-linux-gcc           arm-linux-nm            arm-linux-size
arm-linux-cc           arm-linux-objcopy         arm-linux-strings        arm-linux-c++filt       
arm-linux-gccbug        arm-linux-objdump       arm-linux-strip

all in there:

 └─> which arm-linux-gcc
/usr/crosstool/opt/toolschain/4.4/bin/arm-linux-***

@bovi
Copy link
Member

bovi commented Dec 4, 2013

The toolchain you try to use doesn't exist. Have a look here: https://github.com/mruby/mruby/tree/master/tasks/toolchains

You have to create a toolchain file which describes the compiler tool names.

On 04 Dec 2013, at 15:35, sevk notifications@github.com wrote:

something like this :

MRuby::CrossBuild.new('32bit') do |conf|
toolchain :"arm-linux-gcc"
conf.cc.flags << "-m32"
conf.linker.flags << "-m32"
conf.build_mrbtest_lib_only
conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
conf.test_runner.command = 'env'
end
my cross build tools is :

arm-linux-addr2line arm-linux-cpp arm-linux-gcov arm-linux-populate
arm-linux-ar arm-linux-ct-ng.config arm-linux-gprof arm-linux-ranlib
arm-linux-as arm-linux-g++ arm-linux-ld arm-linux-readelf
arm-linux-c++ arm-linux-gcc arm-linux-nm arm-linux-size
arm-linux-cc arm-linux-objcopy arm-linux-strings arm-linux-c++filt arm-linux-gccbug arm-linux-objdump arm-linux-strip

all in there:

©¸©¤> which arm-linux-gcc
/usr/crosstool/opt/toolschain/4.7/bin/arm-linux-***

¡ª
Reply to this email directly or view it on GitHub.

@sevk
Copy link
Author

sevk commented Dec 6, 2013

so , I have create a toolchains ,
and edit arm.rake for "arm-linux-gcc" .
but did't konw how to do next :


cd tasks/toolchains
cp gcc.rake arm.rake


MRuby::CrossBuild.new('32bit') do |conf|
  toolchain :arm
  ...
end


 └─> rake -A
(in /usr/local/mruby)
rake aborted!
Unknown arm toolchain

@bovi
Copy link
Member

bovi commented Dec 6, 2013

did you adapted the content of the toolchain? I.e. changing the identifier from :gnu to :arm and also changing the compiler tool names?

On 06 Dec 2013, at 10:42, sevk notifications@github.com wrote:

so , I have create a toolchains ,
but did't konw how to do next :

cd tasks/toolchains
cp gcc.rake arm.rake

MRuby::CrossBuild.new('32bit') do |conf|
toolchain :arm
...
end

©¸©¤> rake -A
(in /usr/local/mruby)
rake aborted!
Unknown arm toolchain

¡ª
Reply to this email directly or view it on GitHub.

@sevk
Copy link
Author

sevk commented Dec 10, 2013

yes , I forget edit arm.rake with MRuby::Toolchain.new(:arm) .
now , rake is running .

and file type is for arm :
└─> file build/host/src/proc.o
build/host/src/proc.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

  • but get " cannot find entry symbol _start " in ld :
...
CC    src/proc.c -> build/host/src/proc.o
CC    src/vm.c -> build/host/src/vm.o
CC    src/state.c -> build/host/src/state.o
CC    src/codegen.c -> build/host/src/codegen.o
CC    src/error.c -> build/host/src/error.o
YACC  src/parse.y -> build/host/src/y.tab.c
CC    build/host/src/y.tab.c -> build/host/src/y.tab.o
AR    build/host/lib/libmruby_core.a 
ar:    /usr/local/mruby/build/host/lib/libmruby_core.a
LD    build/host/bin/mrbc 
/usr/crosstool/opt/toolschain/4.4/bin/.arm-none-linux-gnueabi-ld: warning: cannot find entry symbol _start; defaulting to 0000906c
/usr/local/mruby/build/host/lib/libmruby_core.a(gc.o): In function `mrb_gc_arena_restore':
/usr/local/mruby/src/gc.c:1054: undefined reference to `__aeabi_i2d'
/usr/local/mruby/src/gc.c:1054: undefined reference to `__aeabi_dmul'
/usr/local/mruby/src/gc.c:1054: undefined reference to `__aeabi_d2iz'
/usr/local/mruby/build/host/lib/libmruby_core.a(gc.o): In function `gc_protect':
... 
/usr/local/mruby/src/codegen.c:418: undefined reference to `__aeabi_dcmpeq'
/usr/local/mruby/src/codegen.c:418: undefined reference to `__aeabi_dcmpeq'
/usr/local/mruby/build/host/lib/libmruby_core.a(etc.o): In function `mrb_obj_id':
/usr/local/mruby/src/etc.c:167: undefined reference to `__aeabi_i2d'
rake aborted!
Command failed with status (1): ["arm-linux-ld"  -o "/usr/local/mruby/build...]
/usr/local/mruby/tasks/mruby_build_commands.rake:29:in `_run'
/usr/local/mruby/tasks/mruby_build_commands.rake:160:in `run'
/usr/local/mruby/tools/mrbc/mrbc.rake:11:in `block (2 levels) in <top (required)>'
/home/kk/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
/home/kk/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => default => all => /usr/local/mruby/bin/mrbc => /usr/local/mruby/build/host/bin/mrbc
(See full trace by running task with --trace)

** Execute /usr/local/mruby/build/host/bin/mrbc
"arm-linux-ld"  -o "/usr/local/mruby/build/host/bin/mrbc" "/usr/local/mruby/build/host/tools/mrbc/mrbc.o" "/usr/local/mruby/build/host/lib/libmruby_core.a"  -lm 
/usr/crosstool/opt/toolschain/4.4/bin/.arm-none-linux-gnueabi-ld: warning: cannot find entry symbol _start; defaulting to 0000906c

 └─> file /usr/local/mruby/build/host/lib/libmruby_core.a 
/usr/local/mruby/build/host/lib/libmruby_core.a: current ar archive


 └─> file /usr/local/mruby/build/host/tools/mrbc/mrbc.o
/usr/local/mruby/build/host/tools/mrbc/mrbc.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

 └─> nm /usr/local/mruby/build/host/lib/libmruby_core.a | grep _start
00001b7c t gc_start



@bovi
Copy link
Member

bovi commented Dec 10, 2013

Could u post your complete arm.rake?

On 10 Dec 2013, at 11:16, sevk notifications@github.com wrote:

yes , I forget edit arm.rake with MRuby::Toolchain.new(:arm) .
now , rake is running .

and file type is for arm :
©¸©¤> file build/host/src/proc.o
build/host/src/proc.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

but get cannot find entry symbol _start in ld :
...
CC src/proc.c -> build/host/src/proc.o
CC src/vm.c -> build/host/src/vm.o
CC src/state.c -> build/host/src/state.o
CC src/codegen.c -> build/host/src/codegen.o
CC src/error.c -> build/host/src/error.o
YACC src/parse.y -> build/host/src/y.tab.c
CC build/host/src/y.tab.c -> build/host/src/y.tab.o
AR build/host/lib/libmruby_core.a
ar: /usr/local/mruby/build/host/lib/libmruby_core.a
LD build/host/bin/mrbc
/usr/crosstool/opt/toolschain/4.4/bin/.arm-none-linux-gnueabi-ld: warning: cannot find entry symbol _start; defaulting to 0000906c
/usr/local/mruby/build/host/lib/libmruby_core.a(gc.o): In function mrb_gc_arena_restore': /usr/local/mruby/src/gc.c:1054: undefined reference to__aeabi_i2d'
/usr/local/mruby/src/gc.c:1054: undefined reference to __aeabi_dmul' /usr/local/mruby/src/gc.c:1054: undefined reference to__aeabi_d2iz'
/usr/local/mruby/build/host/lib/libmruby_core.a(gc.o): In function gc_protect': ... /usr/local/mruby/src/codegen.c:418: undefined reference to__aeabi_dcmpeq'
/usr/local/mruby/src/codegen.c:418: undefined reference to __aeabi_dcmpeq' /usr/local/mruby/build/host/lib/libmruby_core.a(etc.o): In functionmrb_obj_id':
/usr/local/mruby/src/etc.c:167: undefined reference to __aeabi_i2d' rake aborted! Command failed with status (1): ["arm-linux-ld" -o "/usr/local/mruby/build...] /usr/local/mruby/tasks/mruby_build_commands.rake:29:in_run'
/usr/local/mruby/tasks/mruby_build_commands.rake:160:in run' /usr/local/mruby/tools/mrbc/mrbc.rake:11:inblock (2 levels) in <top (required)>'
/home/kk/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in eval' /home/kk/.rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in

'
Tasks: TOP => default => all => /usr/local/mruby/bin/mrbc => /usr/local/mruby/build/host/bin/mrbc
(See full trace by running task with --trace)

rake --trace: https://gist.github.com/sevk/7885182
** Execute /usr/local/mruby/build/host/bin/mrbc
"arm-linux-ld" -o "/usr/local/mruby/build/host/bin/mrbc" "/usr/local/mruby/build/host/tools/mrbc/mrbc.o" "/usr/local/mruby/build/host/lib/libmruby_core.a" -lm
/usr/crosstool/opt/toolschain/4.4/bin/.arm-none-linux-gnueabi-ld: warning: cannot find entry symbol _start; defaulting to 0000906c

©¸©¤> file /usr/local/mruby/build/host/lib/libmruby_core.a
/usr/local/mruby/build/host/lib/libmruby_core.a: current ar archive

©¸©¤> file /usr/local/mruby/build/host/tools/mrbc/mrbc.o
/usr/local/mruby/build/host/tools/mrbc/mrbc.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

©¸©¤> nm /usr/local/mruby/build/host/lib/libmruby_core.a | grep _start
00001b7c t gc_start

¡ª
Reply to this email directly or view it on GitHub.

@sevk
Copy link
Author

sevk commented Dec 10, 2013

yes

MRuby::Toolchain.new(:arm) do |conf|
  [conf.cc, conf.objc, conf.asm].each do |cc|
    cc.command = ENV['CC'] || 'arm-linux-gcc'
    cc.flags = [ENV['CFLAGS'] || %w(-g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration)]
    cc.include_paths = ["#{MRUBY_ROOT}/include"]
    cc.defines = %w(DISABLE_GEMS)
    cc.option_include_path = '-I%s'
    cc.option_define = '-D%s'
    cc.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
  end

  [conf.cxx].each do |cxx|
    cxx.command = ENV['CXX'] || 'arm-linux-g++'
    cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(-g -O3 -Wall -Werror-implicit-function-declaration)]
    cxx.include_paths = ["#{MRUBY_ROOT}/include"]
    cxx.defines = %w(DISABLE_GEMS)
    cxx.option_include_path = '-I%s'
    cxx.option_define = '-D%s'
    cxx.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
  end

  conf.linker do |linker|
    linker.command = ENV['LD'] || 'arm-linux-ld'
    linker.flags = [ENV['LDFLAGS'] || %w()]
    linker.libraries = %w(m)
    linker.library_paths = []
    linker.option_library = '-l%s'
    linker.option_library_path = '-L%s'
    linker.link_options = '%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}'
  end
end

@bovi
Copy link
Member

bovi commented Dec 10, 2013

Your toolchain should also contain an archiver command for arm (ar). Can you configure the command:
conf.archiver.command
to use it? Otherwise it will use the local ar command which I don't know if it is compatible with the arm linker.

On 10 Dec 2013, at 11:20, sevk notifications@github.com wrote:

yes

MRuby::Toolchain.new(:arm) do |conf|
[conf.cc, conf.objc, conf.asm].each do |cc|
cc.command = ENV['CC'] || 'arm-linux-gcc'
cc.flags = [ENV['CFLAGS'] || %w(-g -std=gnu99 -O3 -Wall -Werror-implicit-function-declaration)]
cc.include_paths = ["#{MRUBY_ROOT}/include"]
cc.defines = %w(DISABLE_GEMS)
cc.option_include_path = '-I%s'
cc.option_define = '-D%s'
cc.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
end

[conf.cxx].each do |cxx|
cxx.command = ENV['CXX'] || 'arm-linux-g++'
cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(-g -O3 -Wall -Werror-implicit-function-declaration)]
cxx.include_paths = ["#{MRUBY_ROOT}/include"]
cxx.defines = %w(DISABLE_GEMS)
cxx.option_include_path = '-I%s'
cxx.option_define = '-D%s'
cxx.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}'
end

conf.linker do |linker|
linker.command = ENV['LD'] || 'arm-linux-ld'
linker.flags = [ENV['LDFLAGS'] || %w()]
linker.libraries = %w(m)
linker.library_paths = []
linker.option_library = '-l%s'
linker.option_library_path = '-L%s'
linker.link_options = '%{flags} -o %{outfile} %{objs} %{flags_before_libraries} %{libs} %{flags_after_libraries}'
end
end

Reply to this email directly or view it on GitHub.

@sevk
Copy link
Author

sevk commented Dec 11, 2013

when add " conf.archiver.command " into MRuby::Toolchain.new(:arm) :

conf.archiver do |ar|
  ar.command = 'arm-lnux-ar'
end

err msg :

 └─> rake --trace
rake aborted!
no _dump_data is defined for class Proc
/usr/local/mruby/tasks/mruby_build_commands.rake:20:in `dump'
/usr/local/mruby/tasks/mruby_build_commands.rake:20:in `block in clone'
/usr/local/mruby/tasks/mruby_build_commands.rake:18:in `each'
/usr/local/mruby/tasks/mruby_build_commands.rake:18:in `clone'
/usr/local/mruby/tasks/mrbgem_spec.rake:51:in `block in setup'
/usr/local/mruby/tasks/mrbgem_spec.rake:50:in `each'
/usr/local/mruby/tasks/mrbgem_spec.rake:50:in `setup'
/usr/local/mruby/tasks/ruby_ext.rake:41:in `block in to_proc'
/usr/local/mruby/tasks/mrbgem_spec.rake:256:in `each'
/usr/local/mruby/tasks/mrbgem_spec.rake:256:in `each'
/usr/local/mruby/tasks/mrbgems.rake:4:in `block in <top (required)>'
/usr/local/mruby/tasks/mruby_build.rake:12:in `instance_eval'
/usr/local/mruby/tasks/mruby_build.rake:12:in `block in each_target'
/usr/local/mruby/tasks/mruby_build.rake:11:in `each'
/usr/local/mruby/tasks/mruby_build.rake:11:in `each_target'
/usr/local/mruby/tasks/mrbgems.rake:1:in `<top (required)>'

whether need define each command :

arm-linux-addr2line     arm-linux-cpp           arm-linux-gcov          arm-linux-populate
arm-linux-ar            arm-linux-ct-ng.config  arm-linux-gprof         arm-linux-ranlib
arm-linux-as            arm-linux-g++           arm-linux-ld            arm-linux-readelf
arm-linux-c++           arm-linux-gcc           arm-linux-nm            arm-linux-size
arm-linux-cc           arm-linux-objcopy         arm-linux-strings        arm-linux-c++filt       
arm-linux-gccbug        arm-linux-objdump       arm-linux-strip

when I configure a cpp source , just need run this :
./configure --host=arm-linux && make -j4

so , what is the easiest way to define these commands ?

@slucx
Copy link

slucx commented May 20, 2015

@sevk replace the string 'arm-linux-ld' to 'arm-linux-gcc'

@tisyang
Copy link

tisyang commented Jul 24, 2017

@slucx it works for me, thanks.

@qichunren
Copy link

@sevk Did you succeed?

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

5 participants