Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-06

FPC only 32 bits?

32 messages · 10 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Francisco Reyes

Just tried to install the FPC port in a AMD64 FreeBSD and got an error that it was an i386 only port.

Is this a deficiency of the port in FreeBSD or is FPC only 32bits?

Marco van de Voort
to Francisco Reyes
Just tried to install the FPC port in a AMD64 FreeBSD and got an error that it was an i386 only port. Is this a deficiency of the port in FreeBSD or is FPC only 32bits?

Yes. I tried to get it running on AMD64 (and the results are in SVN), but the binary won't run and I don't fully understand why.

Aleksey Y. Ulasevich (STAKANOV
to Michael Van Canneyt

Michael Van Canneyt ?????:

It's a deficiency of the port. I run 64 bit FPC every day, even my Lazarus is 64-bit :-)

Hmm.. Where I can get FPC port for FreeBSD-amd64?

Francisco Reyes
to Marco van de Voort: Yes. I tried to get it running on AMD64 (and the results are in SVN), but the binary…
Marco van de Voort wrote
Yes. I tried to get it running on AMD64 (and the results are in SVN), but the binary won't run and I don't fully understand why.

Is your work on the 2.1.4 Beta or I have to do SVN?

In particular I see sources from May 20 at
http://sourceforge.net/project/showfiles.php?group_id=2174

What files do I need to download for the source distribution to try and compile/test on amd64?

I see fpc-2.1.4.source.tar.gz and fpcbuild-2.1.4.tar.gz

I may try them both tonight, but any pointers would be helpfull.

Marco van de Voort
to Francisco Reyes
Show quoted text 12 lines
Marco van de Voort writes: > Yes. I tried to get it running on AMD64 (and the results are in SVN), but > the binary won't run and I don't fully understand why. Is your work on the 2.1.4 Beta or I have to do SVN? In particular I see sources from May 20 at http://sourceforge.net/project/showfiles.php?group_id=2174 What files do I need to download for the source distribution to try and compile/test on amd64?

You can't compile on amd64, since you still have to create the compiler (and debug the actual problem).

So you need:

- a starting compiler (2.0.4 or 2.1.4)
- a 2.3.x (development) snapshot or svn checkout, which are afaik on FTP's server. Note that sourceforge only contains releases, not snapshots

Then you need to crosscompile (see http://www.stack.nl/~marcov/buildfaq.pdf ) to AMD64, and fix the problems in the end.

It is possible to create a binary for amd64, but that binary doesn't work, and I don't know why. FreeBSD keeps complaining it can't execute it.

Florian Klaempfl
to Marco van de Voort
Show quoted text 26 lines
> Marco van de Voort writes: > >> Yes. I tried to get it running on AMD64 (and the results are in SVN), but >> the binary won't run and I don't fully understand why. > Is your work on the 2.1.4 Beta or I have to do SVN? > > In particular I see sources from May 20 at > http://sourceforge.net/project/showfiles.php?group_id=2174 > > What files do I need to download for the source distribution to try and > compile/test on amd64? You can't compile on amd64, since you still have to create the compiler (and debug the actual problem). So you need: - a starting compiler (2.0.4 or 2.1.4) - a 2.3.x (development) snapshot or svn checkout, which are afaik on FTP's server. Note that sourceforge only contains releases, not snapshots Then you need to crosscompile (see http://www.stack.nl/~marcov/buildfaq.pdf ) to AMD64, and fix the problems in the end. It is possible to create a binary for amd64, but that binary doesn't work, and I don't know why. FreeBSD keeps complaining it can't execute it.

.note.abi set?

Marco van de Voort
to Florian Klaempfl
Show quoted text 14 lines
Marco van de Voort schrieb: > So you need: > > - a starting compiler (2.0.4 or 2.1.4) > - a 2.3.x (development) snapshot or svn checkout, which are afaik on FTP's > server. Note that sourceforge only contains releases, not snapshots > > Then you need to crosscompile (see http://www.stack.nl/~marcov/buildfaq.pdf > ) to AMD64, and fix the problems in the end. > > It is possible to create a binary for amd64, but that binary doesn't work, > and I don't know why. FreeBSD keeps complaining it can't execute it. .note.abi set?

Yes. We even did it together.

Francisco Reyes
to Marco van de Voort: You can't compile on amd64, since you still have to create the compiler (and debug the…
Marco van de Voort wrote
- a starting compiler (2.0.4 or 2.1.4)

Have it.

- a 2.3.x (development) snapshot or svn checkout, which are afaik on FTP's server. Note that sourceforge only contains releases, not snapshots

Which directory?
....
drwxr-xr-x 2 1001 1001 4096 Mar 17 20:55 i386-emx drwxr-xr-x 2 1001 1001 4096 May 31 01:22 i386-go32v2 drwxr-xr-x 2 1001 1001 4096 May 31 01:40 i386-win32 ....
drwxr-xr-x 2 1001 1001 4096 Mar 18 00:03 source ....

The source?

Then you need to crosscompile (see http://www.stack.nl/~marcov/buildfaq.pdf ) to AMD64, and fix the problems in the end.

Ok.
Will read up the doc.

Francisco Reyes
to Marco van de Voort: You can't compile on amd64, since you still have to create the compiler (and debug the…
Marco van de Voort wrote
- a starting compiler (2.0.4 or 2.1.4)

Got 2.0.4

- a 2.3.x (development) snapshot

Got from ftp.

Then you need to crosscompile (see http://www.stack.nl/~marcov/buildfaq.pdf ) to AMD64, and fix the problems in the end.

Got it.
Trying to figure out the right parameters.

cd ~/fpc
gmake distclean
# next all on one line
gmake all install CPU_TARGET=x86_64 OS_TARGET=freebsd CROSSBINDIR=~/cross/bin BINUTILSPREFIX=x86_64-freebsd-INSTALL_PREFIX=/usr/local

Does the install_prefix at the end installs anything on /usr/local? or is everything installed on ~/cross/bin
Don't want to install a chunk of am64 code on an i386 machine. :-)

Marco van de Voort
to Francisco Reyes
Show quoted text 5 lines
cd ~/fpc gmake distclean # next all on one line gmake all install CPU_TARGET=x86_64 OS_TARGET=freebsd CROSSBINDIR=~/cross/bin BINUTILSPREFIX=x86_64-freebsd-INSTALL_PREFIX=/usr/local

First, there should be a space before INSTALL_PREFIX

Does the install_prefix at the end installs anything on /usr/local?

Yes.

or is everything installed on ~/cross/bin

No. It only uses AS en LD from there. Specify a different prefix to INSTALL_PREFIX then.

Francisco Reyes
to Marco van de Voort: You can't compile on amd64, since you still have to create the compiler (and debug the…
Marco van de Voort wrote
Then you need to crosscompile (see http://www.stack.nl/~marcov/buildfaq.pdf ) to AMD64, and fix the problems in the end.

Done.

It is possible to create a binary for amd64, but that binary doesn't work, and I don't know why. FreeBSD keeps complaining it can't execute it.

Free Pascal Compiler version 2.3.1 [2007/06/05] for x86_64 Copyright (c) 1993-2007 by Florian Klaempfl

Is this it?

I cross compiled using:
cd ~/fpc
gmake distclean
# next all on one line
gmake all install CPU_TARGET=x86_64 OS_TARGET=freebsd CROSSBINDIR=/vol2/fp-amd/fpc/cross/bin BINUTILSPREFIX=x86_64-freebsd -INSTALL_PREFIX=/vol2/fp-amd/amd64

How do I tell it where to look for the rtl units?

Tried compiling a simple progrma like:
compiler/ppcrossx64 -Xr rtl/ programs/crtxy.pp

Thr crtxy.pp is a trivial program that uses the crt unit.

Gave me the error:
Fatal: Can't find unit System used by crtxy
Fatal: Compilation aborted

Also tried putting
{$UNITPATH /data/fpc/rtl}
At the top most line of my program.

When I installed in i386 I used the FreeBSD port so this is my first install from source.. specially cross-compiling..

Just trying to see if my cross compile worked.
Trying on my laptop, which is FreeBSD AMD64.
Compiled on my desktop with FreeBSD i386.

Henry Vermaak
to Francisco Reyes
Francisco Reyes wrote 5 lines
How do I tell it where to look for the rtl units? Tried compiling a simple progrma like: compiler/ppcrossx64 -Xr rtl/ programs/crtxy.pp

usually fpc.cfg is configured to find the units, but because you installed the compiled units in a different folder, you will need to either change fpc.cfg, or pass the options to ppcrossx64. the relevant lines in fpc.cfg are:

-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl

you will also want to tell ppcrossx64 what your binutils prefix is by using -XPx86_64-freebsd-. also make sure that the compiler can find your binutils (put it on the path).

Show quoted text 16 lines
Thr crtxy.pp is a trivial program that uses the crt unit. Gave me the error: Fatal: Can't find unit System used by crtxy Fatal: Compilation aborted Also tried putting {$UNITPATH /data/fpc/rtl} At the top most line of my program. When I installed in i386 I used the FreeBSD port so this is my first install from source.. specially cross-compiling.. Just trying to see if my cross compile worked. Trying on my laptop, which is FreeBSD AMD64. Compiled on my desktop with FreeBSD i386.

henry

Francisco Reyes
to Henry Vermaak
Henry Vermaak wrote
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/* -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl

To which directory do I point it to?
find . -name "crt*"
shows me that the only compiled rtl are in rtl/units/i386-freebsd

Was the cross compile supposed to do the rtl in a different directory?

you will also want to tell ppcrossx64 what your binutils prefix is by using -XPx86_64-freebsd-. also make sure that the compiler can find your binutils (put it on the path).

Ok.

Francisco Reyes
to Henry Vermaak: usually fpc.cfg is configured to find the units, but because you installed the compiled…
Henry Vermaak wrote
usually fpc.cfg is configured to find the units, but because you installed the compiled units in a different folder, you will need to either change fpc.cfg

How do I tell the compiler where to look for the fpc.cfg? I copied the fpc.cfg from my i386 machine, made the change and tried. Didn't help. Put it in the same place I have it in the i386 architecture. /usr/local/etc/

On the command line I added -Fu<path> and found the diretory.

Now I have a different problem.
PPU Loading /data/fpc/rtl/units/i386-freebsd/system.ppu PPU is compiled for another processor

How do I compile the units for AMD64?
Do I need to cross compile them or can I compile them with this compiler in the AMD64.

you will also want to tell ppcrossx64 what your binutils prefix is by using -XPx86_64-freebsd-.

Was there a dash at the end there or is that a typo?

also make sure that the compiler can find your binutils (put it on the path).

I don't see a directory by that name. Is the directory called something other than binutils?

Originally I embarked on this cross compile because I was told that the freebsd port did not support AMD64 because of some problems. Is what I have done so far further than previously achieved? Just wondering if this that I am trying is of any person that reported the issue with the amd64 port was Marco van de Voort, in this same thread.

In particular he wrote.

It is possible to create a binary for amd64, but that binary doesn't work, and I don't know why. FreeBSD keeps complaining it can't execute it.
Francisco Reyes
to Henry Vermaak: usually fpc.cfg is configured to find the units, but because you installed the compiled…
Henry Vermaak wrote
you will also want to tell ppcrossx64 what your binutils prefix is by using -XPx86_64-freebsd-. also make sure that the compiler can find your binutils (put it on the path).

Based on some searching it seems I need to build the rtl in the AMD64 machine. After some inspection of the Makefile it seemed like I needed to point to variables:
FPC
BINUTILSPREFIX

From what I can tell BINUTILSPREFIX needs to point to among other things

where the assember is so I set those to variables to: setenv FPC "/data/fpc/compiler/ppcrossx64"
setenv BINUTILSPREFIX "/usr/bin/"

Now when I try to run gmake on the rtl directory I get: gmake[1]: Entering directory `/data/fpc/rtl/freebsd' gmake[1]: *** No rule to make target `x86_64/cprt0.as', needed by `cprt0.o'. Stop.
gmake[1]: Leaving directory `/data/fpc/rtl/freebsd' gmake: *** [freebsd_all] Error 2

Don't think I can go any further without help. :-(

Also how do I tell gmake that I am doing freebsd only? gmake -C freebsd all ?

That is what I see after typing "gmake" in the rtl directory.

Pete Cervasio
to Francisco Reyes: How do I tell the compiler where to look for the fpc.cfg? I copied the fpc.cfg from my…
Francisco Reyes wrote 6 lines
Henry Vermaak writes: > also make sure that the compiler can find > your binutils (put it on the path). I don't see a directory by that name. Is the directory called something other than binutils?

I don't think I can help with the rest of your cross-compiling adventure, but maybe I can help with an brief explanation of binutils. The binutils package is the set of GNU "binary utilities". This includes the assembler (as), linker (ld) and other utilities for working with binary program files. In order to make files that will run on 64 bit freebsd, you'll want to find (or build) a binutils package that works with binaries for 64 bit freebsd.

I hope this is helpful.

Best regards,
Pete C.

Marco van de Voort
to Pete Cervasio
Show quoted text 14 lines
On Wednesday 06 June 2007 18:26:15 Francisco Reyes wrote: > Henry Vermaak writes: > > also make sure that the compiler can find > > your binutils (put it on the path). > > I don't see a directory by that name. Is the directory called something > other than binutils? I don't think I can help with the rest of your cross-compiling adventure, but maybe I can help with an brief explanation of binutils. The binutils package is the set of GNU "binary utilities". This includes the assembler (as), linker (ld) and other utilities for working with binary program files. In order to make files that will run on 64 bit freebsd, you'll want to find (or build) a binutils package that works with binaries for 64 bit freebsd.

(actualy more to Francisco:)

Note that all of this is described in the buildfaq already published earlier.

That also contains examples for crosscompiling (hint: look for OS_TARGET CPU_TARGET )

Francisco Reyes
to Marco van de Voort
Marco van de Voort wrote
Note that all of this is described in the buildfaq already published earlier.

I thought I already had cross compiled.
I posted earlier what I used:

cd fpc
gmake distclean
# next all on one line
gmake all install CPU_TARGET=x86_64 OS_TARGET=freebsd CROSSBINDIR=/vol2/fp-amd/fpc/cross/bin BINUTILSPREFIX=x86_64-freebsd -INSTAL L_PREFIX=/vol2/fp-amd/amd64

The /vol2/fp-amd/amd64 is empty. Should it have something?

I think one of my problems may be the CROSSBINDIR. Reading the buildfaq I am not sure what that is supposed to point it to.

The buildfaq reads:
1. Cross binutils have been compiled, and are installed with $PREFIX=~/cross. The correct prefix has been identified (probably something like i686-ming32- and x86-64-linux- in our example)

In my case what does the cross binutils constitute? Copying some files from the FreeBSD amd64 machine? When I do man "as" it says it can do 64bit code, but when I try to compile one of the ".as" files with --64 it complaints that it could not do it.

Also when I do "file ppcrossx64" it reports it is 32bits. Therefore I don't think my cross compile produced amd64 code. The fact i386 units were created also points to that.

Jonas Maebe
to Francisco Reyes
Francisco Reyes wrote
Also when I do "file ppcrossx64" it reports it is 32bits.

At least this is normal, since you are working on a 32 bit machine: this is a cross compiler from 32 bits to 64 bits (i.e., the compiler itself is a 32 bit program, but generates 64 bit code).

Jonas

Henry Vermaak
to Francisco Reyes: I thought I already had cross compiled. I posted earlier what I used: cd fpc gmake…
Francisco Reyes wrote 11 lines
I thought I already had cross compiled. I posted earlier what I used: cd fpc gmake distclean # next all on one line gmake all install CPU_TARGET=x86_64 OS_TARGET=freebsd CROSSBINDIR=/vol2/fp-amd/fpc/cross/bin BINUTILSPREFIX=x86_64-freebsd -INSTAL L_PREFIX=/vol2/fp-amd/amd64

this doesn't look right you've got BINUTILSPREFIX=x86_64-freebsd -INSTALL_PREFIX=... where you should have
BINUTILSPREFIX=x86_64-freebsd- INSTALL_PREFIX=... (note the space after freebsd)

did you copy in paste or is this a typo?

The /vol2/fp-amd/amd64 is empty. Should it have something?

it should contain a directory structure with the compiled units of the rtl, etc.

I think one of my problems may be the CROSSBINDIR. Reading the buildfaq I am not sure what that is supposed to point it to.

this is the folder with the files x86_64-freebsd-* in it (e.g. as, ld)

Show quoted text 14 lines
The buildfaq reads: 1. Cross binutils have been compiled, and are installed with $PREFIX=~/cross. The correct prefix has been identified (probably something like i686-ming32- and x86-64-linux- in our example) In my case what does the cross binutils constitute? Copying some files from the FreeBSD amd64 machine? When I do man "as" it says it can do 64bit code, but when I try to compile one of the ".as" files with --64 it complaints that it could not do it. Also when I do "file ppcrossx64" it reports it is 32bits. Therefore I don't think my cross compile produced amd64 code. The fact i386 units were created also points to that.

henry

Francisco Reyes
to Henry Vermaak
Henry Vermaak wrote 6 lines
this doesn't look right you've got BINUTILSPREFIX=x86_64-freebsd -INSTALL_PREFIX=... where you should have BINUTILSPREFIX=x86_64-freebsd- INSTALL_PREFIX=... (note the space after freebsd) did you copy in paste or is this a typo?

It was a typo.
Corrected. Thanks.

> I think one of my problems may be the CROSSBINDIR. Reading the buildfaq I > am not sure what that is supposed to point it to. this is the folder with the files x86_64-freebsd-* in it (e.g. as, ld)

So I copy /usr/bin/as to /vol2/fp-amd/fpc/crossbin and name it x86_64-freebsd-as?

Did that.

Tried again. Got a number of errors from the assembler. Errors like: /vol2/fp-amd/fpc/crossbin/x86_64-freebsd-as -o
/vol2/fp-amd/fpc/rtl/units/x86_64-freebsd/prt0.o x86_64/prt0.as x86_64/prt0.as: Assembler messages:
x86_64/prt0.as:31: Error: suffix or operands invalid for `push' x86_64/prt0.as:33: Error: suffix or operands invalid for `movq' x86_64/prt0.as:37: Error: `-8(%rbp)' is not a valid 32 bit base/index expression
x86_64/prt0.as:38: Error: `-16(%rbp)' is not a valid 32 bit base/index expression

Vincent Snijders
to Francisco Reyes
Francisco Reyes wrote 33 lines
Henry Vermaak writes: > this doesn't look right you've got BINUTILSPREFIX=x86_64-freebsd > -INSTALL_PREFIX=... where you should have > BINUTILSPREFIX=x86_64-freebsd- INSTALL_PREFIX=... (note the space > after freebsd) > > did you copy in paste or is this a typo? It was a typo. Corrected. Thanks. >> I think one of my problems may be the CROSSBINDIR. Reading the >> buildfaq I >> am not sure what that is supposed to point it to. > > this is the folder with the files x86_64-freebsd-* in it (e.g. as, ld) So I copy /usr/bin/as to /vol2/fp-amd/fpc/crossbin and name it x86_64-freebsd-as? Did that. Tried again. Got a number of errors from the assembler. Errors like: /vol2/fp-amd/fpc/crossbin/x86_64-freebsd-as -o /vol2/fp-amd/fpc/rtl/units/x86_64-freebsd/prt0.o x86_64/prt0.as x86_64/prt0.as: Assembler messages: x86_64/prt0.as:31: Error: suffix or operands invalid for `push' x86_64/prt0.as:33: Error: suffix or operands invalid for `movq' x86_64/prt0.as:37: Error: `-8(%rbp)' is not a valid 32 bit base/index expression x86_64/prt0.as:38: Error: `-16(%rbp)' is not a valid 32 bit base/index expression

Can you manually assemble prt0.as?

Maybe the assembler needs --64 to be in 64 bits mode. In that case you may need to write some wrapper scripts to add that parameter.

Vincent

Henry Vermaak
to Francisco Reyes: It was a typo. Corrected. Thanks. So I copy /usr/bin/as to /vol2/fp-amd/fpc/crossbin and…
Francisco Reyes wrote 5 lines
So I copy /usr/bin/as to /vol2/fp-amd/fpc/crossbin and name it x86_64-freebsd-as? Did that.

no, this is wrong. there is a reason that they have the prefix. you need to get the cross binutils that cross assembles and cross links from your platform to x86_64 freebsd. you might be able to download them from somewhere or build them with a suitable tool./script like dan kegel's crosstool. just search.

i urge you to read marco's excellent document on this. it will save you a lot of time.

good luck
henry

Francisco Reyes
to Henry Vermaak
Henry Vermaak wrote
no, this is wrong. there is a reason that they have the prefix. you need to get the cross binutils that cross assembles and cross links from your platform to x86_64 freebsd.

Ok.

you might be able to download them from somewhere or build them with a suitable tool./script like dan kegel's crosstool. just search.

OK. Will do.

i urge you to read marco's excellent document on this. it will save you a lot of time.

I have read it a few times, but it is likely that something that is obvious to more experienced users is not clear to someone new like myself.

Henry Vermaak
to Francisco Reyes
Francisco Reyes wrote
I have read it a few times, but it is likely that something that is obvious to more experienced users is not clear to someone new like myself.

o.k., no problems, we all gotta learn ;) on which platform are you compiling on at the moment? (sorry, i've lost the story line a bit)

henry

Francisco Reyes
to Vincent Snijders: Can you manually assemble prt0.as? Maybe the assembler needs --64 to be in 64 bits mode.…
Vincent Snijders wrote 7 lines
> x86_64/prt0.as:38: Error: `-16(%rbp)' is not a valid 32 bit base/index > expression Can you manually assemble prt0.as? Maybe the assembler needs --64 to be in 64 bits mode. In that case you may need to write some wrapper scripts to add that parameter.

Even though my very first attempt did not produce compiled rtl units for x86. It seems I did get a compiler.

I am trying to use that compiler to then do an install in the amd64 machine. It crashes trying to run:
as -o /data/fpc/rtl/units/i386-freebsd/prt0.o i386/prt0.as

However if I add --64 to the same line.. (manually.. and including the missing path) it works.

Will try two things now..
1- See if I can find the crosscompile tools needed 2- See if somehow I can pass the right parameter to the 'as' on the amd64 and see if I am able to finish the build on that environment.

Francisco Reyes
to Henry Vermaak: o.k., no problems, we all gotta learn ;) on which platform are you compiling on at the…
Henry Vermaak wrote
o.k., no problems, we all gotta learn ;) on which platform are you compiling on at the moment? (sorry, i've lost the story line a bit)

Compiling on FreeBSD 6.2 i386
I started this whole project because the FreeBSD port doesn't compile in amd64.

I have a laptop which is AMD64 and since I spend a good hour plus on the train every day.. I want to get free pascal there so I can code during my commute.

Right now my next step is to search for the cross binutils. Already posted on a freebsd list and also searching on google to see if there is a way I can build them myself.

Francisco Reyes
to Marco van de Voort: You can't compile on amd64, since you still have to create the compiler (and debug the…
Marco van de Voort wrote
It is possible to create a binary for amd64, but that binary doesn't work, and I don't know why. FreeBSD keeps complaining it can't execute it.

Marco, since you were able to do this cross compile once, doesn't that mean you have the cross-binutils for 6.2? Any chance you could put them somewhere for me?

Where did you get them or how did you compile them?

Thanks.

Marco van de Voort
to Francisco Reyes
Show quoted text 11 lines
Marco van de Voort writes: > It is possible to create a binary for amd64, but that binary doesn't work, > and I don't know why. FreeBSD keeps complaining it can't execute it. Marco, since you were able to do this cross compile once, doesn't that mean you have the cross-binutils for 6.2? Any chance you could put them somewhere for me? Where did you get them or how did you compile them?

Compiled them from Gnu.org sources ? Only trick is to add --disable-nls and set the target to configure.

IIRC there is a script to mass-build crossbinutils on *nix in the fpcbuild repository. (install/scripts or so)