Recent

Author Topic: [Tutorial] Cross Compile for arm-linux (Finally it works!)  (Read 178583 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #90 on: August 25, 2014, 01:34:22 pm »
Likewise, you're now on 32-bit platform. If your binutils is already 32-bit, it may not accept --32 parameter. Logically, you only need it to assemble/link FOR different architecture than the host.

Diego

  • New member
  • *
  • Posts: 8
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #91 on: August 25, 2014, 10:35:45 pm »
I looked at the documentation (https://sourceware.org/binutils/docs/binutils/index.html) and found nothing related, just found this bug that speaks of the case: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54996

The biggest doubt is where it is being inserted option --32 or --64?  I did not insert option. I'm doing cross compile Linux (i386 or x86_64) for ARM, how to pass the correct option for arm?

I lowered my Beanutils of gnu ftp: http://ftp.gnu.org/gnu/binutils/ and configured beanutils following the steps of section "Install & Configure Binutils" of the tutorial "http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM"

Thanks again for help leledumbo!

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #92 on: August 26, 2014, 09:02:22 am »
The biggest doubt is where it is being inserted option --32 or --64?  I did not insert option. I'm doing cross compile Linux (i386 or x86_64) for ARM, how to pass the correct option for arm?
The compiler passes that, the respective file is compiler/x86/agx86att.pas. So it's binutils problem. You might need to tailor certain options when building it. I got mine from official repository of my distro (which probably has the options enabled). Here is the respective documentation link for that option.

Diego

  • New member
  • *
  • Posts: 8
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #93 on: August 26, 2014, 11:57:51 am »
Okay Leledumbo, I'll try to install the binutils repository of my distro, to see if it works.

Still got one doubt. Created a test.pas file with the content:

program test;
begin
  writeln('DATE ',{$i %DATE%});
  writeln('FPCTARGET ',{$i %FPCTARGET%});
  writeln('FPCTARGETCPU ',{$i %FPCTARGETCPU%});
  writeln('FPCTARGETOS ',{$i %FPCTARGETOS%});
  writeln('FPCVERSION ',{$i %FPCVERSION%});
end.

and executed:

$ fpc -Tlinux -Parm -XParm-linux- test.pas

The console showed the text below and generated all files to ARM platform with successfully:

Free Pascal Compiler version 2.6.4 [2014/08/24] for arm
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for ARMEL
Compiling test.pas
Assembling test
Linking test
8 lines compiled, 0.4 sec

Is that really the problem is the beanutils or lazarus? Using the fpc command to compile the test.pas it works but when I try to "Configure Lazarus for cross Compile" generates errors.

I think the team lazarus should provide a version that is configured for this purpose.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #94 on: August 27, 2014, 11:02:56 am »
Is that really the problem is the beanutils or lazarus? Using the fpc command to compile the test.pas it works but when I try to "Configure Lazarus for cross Compile" generates errors.
Your binutils works then. It's too weird if it works for test program above but not for program above, since the command line option would be similar (you can check yourself by watching make output).
Quote
I think the team lazarus should provide a version that is configured for this purpose.
Go look for a maintainer. There's none for arm-linux ATM.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #95 on: August 27, 2014, 01:03:29 pm »
There are many ARM targets.  There is no universal arm-linux. It all depends on device, and target CPU

Diego

  • New member
  • *
  • Posts: 8
Re: [Tutorial] Cross Compile for arm-linux (Finally it works!)
« Reply #96 on: August 27, 2014, 09:47:36 pm »
I understand Marcov, really must be difficult to create a version of lazarus i386 or x86_64 with configuring cross compile for Arm preconfigured.

Leledumbo agree with you, it really is very strange. The worst that the entire configuration of fpc, fpc-src and beanutils is successful. The binary for ARM are created when executed by the terminal using only the fpc, but when starting configuration for Lazarus generate for binaries ARM, many mistakes happen.

According to my tests I believe that should be the file ~/.fpc.cfg that is not well configured for Lazarus. Mine is like this:

#INCLUDE /etc/fpc.cfg
#DEFINE DEMOTEST
#DEFINE DEMOTEST1
#DEFINE LAZARUS

-Fu/usr/lib/fpc/2.6.4/units/$fpctarget/*
-Fl/usr/lib/fpc/2.6.4/units/$fpctarget/rtl/

-a
-Sd
-Xd
-Xs

-O-

#IFDEF CPUARM
-XP/home/user/lazarus/fpc/binutils/
-Xr/usr/lib/fpc/2.6.4/units/arm-linux/rtl/
-Xr/home/user/lazarus/fpc/libcross
-XR/home/user/lazarus/fpc/
-darm
-Tlinux
#ENDIF

 

TinyPortal © 2005-2018