Sign in Join

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

Mailing lists / fpc-pascal / 2012-10

Running FPC on a system that supports multiple architectures

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Mark Morgan Lloyd

This is an "out of interest" question rather than being particularly important. I've managed to get my hands on an Itanium-based system for my collection, and find that it runs the x86 Linux variant of FPC fairly happily. However, GNU as and so on clearly don't know about x86 assembler: they expect the monstrosity that is IA-64.

I could obviously build appropriate binutils with the conventional naming prexies, but what is the preferred way of telling FPC/PPC which binutils to use? Is that where the CPU_TARGET and OS_TARGET shell variables come itno it, or are they only for use in makefiles?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Marco van de Voort
to Mark Morgan Lloyd

In our previous episode, Mark Morgan Lloyd said:

Show quoted text 9 lines
This is an "out of interest" question rather than being particularly important. I've managed to get my hands on an Itanium-based system for my collection, and find that it runs the x86 Linux variant of FPC fairly happily. However, GNU as and so on clearly don't know about x86 assembler: they expect the monstrosity that is IA-64. I could obviously build appropriate binutils with the conventional naming prexies, but what is the preferred way of telling FPC/PPC which binutils to use?

http://www.stack.nl/~marcov/buildfaq/#toc-Subsection-1.6.3

Is that where the CPU_TARGET and OS_TARGET shell variables come itno it, or are they only for use in makefiles?

http://www.stack.nl/~marcov/buildfaq/#toc-Section-1.6 point 5 in the list.

IIRC there is also a CROSSBINUTILSPREFIX in case you only have to override it for the "cross" part.

Mark Morgan Lloyd
to Marco van de Voort
Marco van de Voort wrote 20 lines
In our previous episode, Mark Morgan Lloyd said: > This is an "out of interest" question rather than being particularly > important. I've managed to get my hands on an Itanium-based system for > my collection, and find that it runs the x86 Linux variant of FPC fairly > happily. However, GNU as and so on clearly don't know about x86 > assembler: they expect the monstrosity that is IA-64. > > I could obviously build appropriate binutils with the conventional > naming prexies, but what is the preferred way of telling FPC/PPC which > binutils to use? http://www.stack.nl/~marcov/buildfaq/#toc-Subsection-1.6.3 > Is that where the CPU_TARGET and OS_TARGET shell > variables come itno it, or are they only for use in makefiles? http://www.stack.nl/~marcov/buildfaq/#toc-Section-1.6 point 5 in the list. IIRC there is also a CROSSBINUTILSPREFIX in case you only have to override it for the "cross" part.

Thanks Marco, I'd missed -XP since I was mistakenly looking at the -A section.

For information, it works, but I'm getting an error when it calls the linker. If I link using a script it's fine:

~$ fpc -XPi486-linux- -sh test.pas
Free Pascal Compiler version 2.6.0 [2012/05/05] for i386 Copyright (c) 1993-2011 by Florian Klaempfl and others Target OS: Linux for i386
Compiling test.pas
Closing script ppas.sh
6 lines compiled, 0.8 sec
~$ ./ppas.sh
Linking test
/usr/local/bin/i486-linux-ld: warning: link.res contains output sections; did you forget -T?
~$ ./test
Hello, World!

Does x86-64 on Linux provide similar emulation, and does it also require a script for reliable operation?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Sven Barth
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote
For information, it works, but I'm getting an error when it calls the linker. If I link using a script it's fine:

It would help very much if you'd post the error that you get.

Regards,
Sven

Mark Morgan Lloyd
to Sven Barth
Sven Barth wrote 5 lines
Am 05.10.2012 11:34, schrieb Mark Morgan Lloyd: > For information, it works, but I'm getting an error when it calls the > linker. If I link using a script it's fine: It would help very much if you'd post the error that you get.

I posted the minimum to report (partial) success in case the problem was considered below the threshold of interest.

I'm compiling binutils 2.20 using

./configure --prefix=/usr/local/i486-linux i486-linux-gnu

etc., and then setting up symlinks

/usr/local/bin/i486-linux-as -> /usr/local/i486-linux/bin/as

etc. When I do a direct compilation I get

~$ fpc -XPi486-linux- test.pas
Free Pascal Compiler version 2.6.0 [2012/05/05] for i386 Copyright (c) 1993-2011 by Florian Klaempfl and others Target OS: Linux for i386
Compiling test.pas
Linking test
test.pas(5,1) Error: Can't call the linker, switching to external linking test.pas(5,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

If I use -vt I see

..
Searching file /usr/local/lib/fpc/2.6.0/I486-LINUX-LD... not found Searching file /usr/local/bin/i486-linux-ld... found Using util /usr/local/bin/i486-linux-ld
test.pas(5,1) Error: Can't call the linker, switching to external linking test.pas(5,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

Nothing obviously useful in -vv output.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Mark Morgan Lloyd
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 45 lines
Sven Barth wrote: > Am 05.10.2012 11:34, schrieb Mark Morgan Lloyd: >> For information, it works, but I'm getting an error when it calls the >> linker. If I link using a script it's fine: > > It would help very much if you'd post the error that you get. I posted the minimum to report (partial) success in case the problem was considered below the threshold of interest. I'm compiling binutils 2.20 using ./configure --prefix=/usr/local/i486-linux i486-linux-gnu etc., and then setting up symlinks /usr/local/bin/i486-linux-as -> /usr/local/i486-linux/bin/as etc. When I do a direct compilation I get ~$ fpc -XPi486-linux- test.pas Free Pascal Compiler version 2.6.0 [2012/05/05] for i386 Copyright (c) 1993-2011 by Florian Klaempfl and others Target OS: Linux for i386 Compiling test.pas Linking test test.pas(5,1) Error: Can't call the linker, switching to external linking test.pas(5,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled) If I use -vt I see .. Searching file /usr/local/lib/fpc/2.6.0/I486-LINUX-LD... not found Searching file /usr/local/bin/i486-linux-ld... found Using util /usr/local/bin/i486-linux-ld test.pas(5,1) Error: Can't call the linker, switching to external linking test.pas(5,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled) Nothing obviously useful in -vv output.

Also ppas.sh reads

#!/bin/sh
DoExitAsm ()
{ echo "An error occurred while assembling $1"; exit 1; } DoExitLink ()
{ echo "An error occurred while linking $1"; exit 1; } echo Linking test
OFS=$IFS
IFS="
"
/usr/local/bin/i486-linux-ld -b elf32-i386 -m elf_i386 -s -L. -o test link.res
if [ $? != 0 ]; then DoExitLink test; fi
IFS=$OFS

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Marco van de Voort
to Mark Morgan Lloyd: Thanks Marco, I'd missed -XP since I was mistakenly looking at the -A section. For…

In our previous episode, Mark Morgan Lloyd said:

Show quoted text 9 lines
> > IIRC there is also a CROSSBINUTILSPREFIX in case you only have to override > it for the "cross" part. Thanks Marco, I'd missed -XP since I was mistakenly looking at the -A section. For information, it works, but I'm getting an error when it calls the linker. If I link using a script it's fine:

1. IIRC FPC uses a builtin list of paths and -FD paths

2. The shell might use its own $PATH.

Solution, pass -FD or CROSSBINDIR (or something, search in makefile)

Mark Morgan Lloyd
to Marco van de Voort
Marco van de Voort wrote 14 lines
In our previous episode, Mark Morgan Lloyd said: >> IIRC there is also a CROSSBINUTILSPREFIX in case you only have to override >> it for the "cross" part. > Thanks Marco, I'd missed -XP since I was mistakenly looking at the -A > section. > > For information, it works, but I'm getting an error when it calls the > linker. If I link using a script it's fine: 1. IIRC FPC uses a builtin list of paths and -FD paths 2. The shell might use its own $PATH. Solution, pass -FD or CROSSBINDIR (or something, search in makefile)

I'd not expect this to be a path problem since I've symlinked the assemblers into /usr/local/bin which is where ppc386 is, -vt output says that it's finding the binary and using an explicit -FD doesn't have an obvious effect.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Mark Morgan Lloyd
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 21 lines
Marco van de Voort wrote: > In our previous episode, Mark Morgan Lloyd said: >>> IIRC there is also a CROSSBINUTILSPREFIX in case you only have to >>> override >>> it for the "cross" part. >> Thanks Marco, I'd missed -XP since I was mistakenly looking at the -A >> section. >> >> For information, it works, but I'm getting an error when it calls the >> linker. If I link using a script it's fine: > > 1. IIRC FPC uses a builtin list of paths and -FD paths > > 2. The shell might use its own $PATH. > > Solution, pass -FD or CROSSBINDIR (or something, search in makefile) I'd not expect this to be a path problem since I've symlinked the assemblers into /usr/local/bin which is where ppc386 is, -vt output says that it's finding the binary and using an explicit -FD doesn't have an obvious effect.

I don't believe that this is a path problem since the assembler pass works, but I can make it fail by specifying the -a parameter:

$ fpc -XPi486-linux- -a test.pas
Free Pascal Compiler version 2.6.0 [2012/05/05] for i386 Copyright (c) 1993-2011 by Florian Klaempfl and others Note: Switching assembler to default source writing assembler Target OS: Linux for i386
Compiling test.pas
Assembling test
test.pas(4,26) Error: Can't call the assembler, error -9 switching to external assembling
test.pas(4,26) Error: Error while linking
test.pas(4,26) Fatal: There were 3 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

So it appears to be something to do with how the compiler communicates with as or ld.

This was on an IA-64 system using its hardware emulation of x86. I think there's a potential that this could also occur on an x86-64 system, but I don't have one to test it on.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]