public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Cross Compiling for riscv64
@ 2023-02-14 11:37 Sagar Acharya
  2023-02-14 11:48 ` Xi Ruoyao
  2023-02-14 13:36 ` Kai Ruottu
  0 siblings, 2 replies; 9+ messages in thread
From: Sagar Acharya @ 2023-02-14 11:37 UTC (permalink / raw)
  To: Gcc Help

I built binutils and added variables
AR , etc. for configuring

Configured with
./configure --target=riscv64-unknown-elf
make

Gives

g++: fatal error: Killed signal terminated program cc1plus
compilation terminated
make[2]: *** [Makefile:1143: gimple-match.o] Error 1
make[2]: Leaving directory '/path/to/gcc-12.2.0/host-aarch64-unknown-linux-musl/gcc'
make[1]: *** [Makefile:4610: all-gcc] Error 2
make[1]: Leaving directory 'gcc-12.2.0’
make: *** [Makefile:1028: all] Error 2

I already have a preinstalled package aarch64-linux-musl-gcc . Kindly help. 
Thanking you
Sagar Acharya
https://designman.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 11:37 Cross Compiling for riscv64 Sagar Acharya
@ 2023-02-14 11:48 ` Xi Ruoyao
  2023-02-14 12:28   ` Sagar Acharya
  2023-02-14 13:36 ` Kai Ruottu
  1 sibling, 1 reply; 9+ messages in thread
From: Xi Ruoyao @ 2023-02-14 11:48 UTC (permalink / raw)
  To: Sagar Acharya; +Cc: gcc-help

On Tue, 2023-02-14 at 12:37 +0100, Sagar Acharya via Gcc-help wrote:
> g++: fatal error: Killed signal terminated program cc1plus
> compilation terminated
> make[2]: *** [Makefile:1143: gimple-match.o] Error 1

It looks like your system is out of memory then the kernel selects a
process heavily using the memory and kill it.  gimple-match.o is
automatically generated, so it can be very large and compiling it will
consume a large amount of memory.

Try to add more RAM into your system, or build with a smaller -j value.
The last resort is to add more swap space, but swapping can slow down
the building process significantly.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 11:48 ` Xi Ruoyao
@ 2023-02-14 12:28   ` Sagar Acharya
  2023-02-14 12:43     ` Xi Ruoyao
  0 siblings, 1 reply; 9+ messages in thread
From: Sagar Acharya @ 2023-02-14 12:28 UTC (permalink / raw)
  To: Xi Ruoyao; +Cc: gcc-help

I'm compiling on RPI3.

The real question is, whether building a compiler should require 900MB memory?

And my answer to it is a clear undisputed no. 900MB is more than enough memory for building a compiler.

I thank you very much for your help, Xi!
Thanking you
Sagar Acharya
https://designman.org



14 Feb 2023, 17:18 by xry111@xry111.site:

> On Tue, 2023-02-14 at 12:37 +0100, Sagar Acharya via Gcc-help wrote:
>
>> g++: fatal error: Killed signal terminated program cc1plus
>> compilation terminated
>> make[2]: *** [Makefile:1143: gimple-match.o] Error 1
>>
>
> It looks like your system is out of memory then the kernel selects a
> process heavily using the memory and kill it.  gimple-match.o is
> automatically generated, so it can be very large and compiling it will
> consume a large amount of memory.
>
> Try to add more RAM into your system, or build with a smaller -j value.
> The last resort is to add more swap space, but swapping can slow down
> the building process significantly.
>
> -- 
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 12:28   ` Sagar Acharya
@ 2023-02-14 12:43     ` Xi Ruoyao
  2023-02-14 12:57       ` Sagar Acharya
  0 siblings, 1 reply; 9+ messages in thread
From: Xi Ruoyao @ 2023-02-14 12:43 UTC (permalink / raw)
  To: Sagar Acharya; +Cc: gcc-help

On Tue, 2023-02-14 at 13:28 +0100, Sagar Acharya wrote:
> The real question is, whether building a compiler should require 900MB
> memory?
> 
> And my answer to it is a clear undisputed no. 900MB is more than
> enough memory for building a compiler.

GCC is a real compiler, not an example in the compiler textbook.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 12:43     ` Xi Ruoyao
@ 2023-02-14 12:57       ` Sagar Acharya
  2023-02-14 13:02         ` Xi Ruoyao
  2023-02-14 13:27         ` Jonathan Wakely
  0 siblings, 2 replies; 9+ messages in thread
From: Sagar Acharya @ 2023-02-14 12:57 UTC (permalink / raw)
  To: Xi Ruoyao; +Cc: gcc-help

Point of a compiler is to convert C code to machine code of hex/binary/object file in least amount of time and conserving as much memory as can be done. To create good error-free sequence of instructions is also one objective.

The values of memory required are definitely not of order 1GB. There are OSes which can be booted in less than 100MB.
Thanking you
Sagar Acharya
https://designman.org



14 Feb 2023, 18:13 by xry111@xry111.site:

> On Tue, 2023-02-14 at 13:28 +0100, Sagar Acharya wrote:
>
>> The real question is, whether building a compiler should require 900MB
>> memory?
>>
>> And my answer to it is a clear undisputed no. 900MB is more than
>> enough memory for building a compiler.
>>
>
> GCC is a real compiler, not an example in the compiler textbook.
>
> -- 
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 12:57       ` Sagar Acharya
@ 2023-02-14 13:02         ` Xi Ruoyao
  2023-02-14 13:27         ` Jonathan Wakely
  1 sibling, 0 replies; 9+ messages in thread
From: Xi Ruoyao @ 2023-02-14 13:02 UTC (permalink / raw)
  To: Sagar Acharya; +Cc: gcc-help

On Tue, 2023-02-14 at 13:57 +0100, Sagar Acharya wrote:
> Point of a compiler is to convert C code to machine code of
> hex/binary/object file in least amount of time and conserving as much
> memory as can be done.

A compiler needs to take a balance between compiling speed & memory
consumption and the speed & memory consumption of the generated code. 
GCC prefers to make better generated code, as long as no quadratic
behavior exists during compile time.

> The values of memory required are definitely not of order 1GB. There
> are OSes which can be booted in less than 100MB.

You can find another compiler if you really need one for a small device.
Or you can submit some patches to improve the speed & memory footprint
of GCC (or hire somebody to do) as long as you don't hurt the generated
code.

"You think what it should be" is not "what it should be".

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 12:57       ` Sagar Acharya
  2023-02-14 13:02         ` Xi Ruoyao
@ 2023-02-14 13:27         ` Jonathan Wakely
  1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Wakely @ 2023-02-14 13:27 UTC (permalink / raw)
  To: Sagar Acharya; +Cc: Xi Ruoyao, gcc-help

On Tue, 14 Feb 2023 at 12:58, Sagar Acharya via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> Point of a compiler is to convert C code to machine code of hex/binary/object file

Correct so far.

> in least amount of time and conserving as much memory as can be done.

No, that is a nice-to-have feature, not "the point of a compiler".


> To create good error-free sequence of instructions is also one objective.

Yes.

> The values of memory required are definitely not of order 1GB. There are OSes which can be booted in less than 100MB.

Have you actually looked at what is being compiled for gimple-match.o?
It's meaningless to compare it to booting an OS, those are two
completely different things.

You could try compiling that file without optimization, or you could
try building the compiler on a machine with more memory then copying
it to your rpi.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 11:37 Cross Compiling for riscv64 Sagar Acharya
  2023-02-14 11:48 ` Xi Ruoyao
@ 2023-02-14 13:36 ` Kai Ruottu
  2023-02-14 13:46   ` Kai Ruottu
  1 sibling, 1 reply; 9+ messages in thread
From: Kai Ruottu @ 2023-02-14 13:36 UTC (permalink / raw)
  To: Sagar Acharya, Gcc Help

[-- Attachment #1: Type: text/plain, Size: 4707 bytes --]

Sagar Acharya via Gcc-help kirjoitti 14.2.2023 klo 13.37:
> I built binutils and added variables
> AR , etc. for configuring
>
> Configured with
> ./configure --target=riscv64-unknown-elf
> make
As told on the GCC page configuring in the main GCC source directory is 
not recommended (https://gcc.gnu.org/install/configure.html) :

------------------ clip ----------------------------------
We use srcdir to refer to the toplevel source directory for GCC; we use 
objdir to refer to the toplevel build/object directory.

.......

First, we *highly* recommend that GCC be built into a separate directory 
from the sources which does *not* reside within the
source tree. This is how we generally build GCC; building where srcdir 
== objdir should still work, but doesn’t get extensive
testing; building where objdir is a subdirectory of srcdir is unsupported.
------------------ clip ----------------------------------

> I already have a preinstalled package aarch64-linux-musl-gcc . Kindly help.
Where this package could be downloaded?  The "Void Linux" pages don't 
include any GCC package for native/cross aarch64.
Only the runtime libraries in their ROOTFS/PLATFORMFS packages :

[root@AthlonXP2 aarch64-void-linux-musl]# ls
bin   dev  home  lib32  media  opt   root  sbin  tmp  var
boot  etc  lib   lib64  mnt    proc  run   sys   usr
[root@AthlonXP2 aarch64-void-linux-musl]# cd usr
[root@AthlonXP2 usr]# ls include
f2fs_fs.h  gawkapi.h  iproute2  quota.h

[root@AthlonXP2 usr]# ls lib
depmod.d                         libnftnl.so.11.6.0
dhcpcd                           libnl-3.so.200
dracut                           libnl-3.so.200.26.0
e2initrd_helper                  libnl-cli-3.so.200
engines-1.1                      libnl-cli-3.so.200.26.0
gawk                             libnl-genl-3.so.200
ld-musl-aarch64.so.1             libnl-genl-3.so.200.26.0
libacl.so.1                      libnl-idiag-3.so.200
libacl.so.1.1.2301               libnl-idiag-3.so.200.26.0
libarchive.so.13                 libnl-nf-3.so.200
libarchive.so.13.6.1             libnl-nf-3.so.200.26.0
libattr.so.1                     libnl-route-3.so.200
libattr.so.1.1.2501              libnl-route-3.so.200.26.0
libblkid.so.1                    libnl-xfrm-3.so.200
libblkid.so.1.1.0                libnl-xfrm-3.so.200.26.0
libbz2.so.1                      libpamc.so.0
libbz2.so.1.0                    libpamc.so.0.82.1
libbz2.so.1.0.8                  libpam_misc.so.0
libcap-ng.so.0                   libpam_misc.so.0.82.1
libcap-ng.so.0.0.0               libpam.so.0
libcap.so.2                      libpam.so.0.85.1
libcap.so.2.54                   libpanelw.so.6
libcom_err.so.2                  libpanelw.so.6.3
libcom_err.so.2.1                libpcap.so.1
libcrypto.so.1.1                 libpcap.so.1.10.1
libc.so
...............

There should be some but clicking their download links results to nothing :(

I found some other package for a 'i686-linux-gnu' hosted "statically 
built" cross GCC for 'aarch64-linux-musl' target
which had both development headers and libraries and that enabled me to 
build own cross-GCC to 'aarch64-linux-musl'
target. And then to build 'aarch64-linux-musl'-hosted stuff like this 
GCC, configured with :

../configure --build=i686-linux-gnu --host=aarch64-linux-musl 
--target=riscv64-elf --prefix=/opt/cross --libdir=/opt/cross/lib 
--libexecdir=/opt/cross/lib --enable-languages=c,c++ --disable-shared 
--disable-threads --disable-nls --disable-multilib --disable-libgcj 
--disable-libffi --enable-languages=c,c++ --with-newlib 
--with-gxx-include-dir=/opt/cross/include/c++/11.3 
--enable-version-specific-runtime-libs --program-prefix=riscv64-elf- 
--program-suffix=-11

BUT this ISN'T for the same host as the "Void Linux for aarch64 with 
musl"!  How good the binary compatability is
between different distros I have no clue.  Producing the same 
'riscv64-elf' targeted GCC with the gcc-12.2.0 sources
(and with 'newlib') just now succeeded when writing this...

One advice from me would be to consider using a "factory" instead of 
"garage" for producing this kind of stuff.
My old 2,8 MHz AthlonXP PC may sound "old and slow" but in my 70 years 
age its speed is enough for me.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Cross Compiling for riscv64
  2023-02-14 13:36 ` Kai Ruottu
@ 2023-02-14 13:46   ` Kai Ruottu
  0 siblings, 0 replies; 9+ messages in thread
From: Kai Ruottu @ 2023-02-14 13:46 UTC (permalink / raw)
  To: Sagar Acharya, Gcc Help

Kai Ruottu kirjoitti 14.2.2023 klo 15.36:
>
> One advice from me would be to consider using a "factory" instead of 
> "garage" for producing this kind of stuff.
> My old 2,8 MHz AthlonXP PC may sound "old and slow" but in my 70 years 
> age its speed is enough for me.
Actually I meaned to write "2800 MHz" but then changed the number to 
"2,8" but forgot to change the "MHz"
to "GHz". When one becomes old, things like this will happen more often :(

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-02-14 13:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 11:37 Cross Compiling for riscv64 Sagar Acharya
2023-02-14 11:48 ` Xi Ruoyao
2023-02-14 12:28   ` Sagar Acharya
2023-02-14 12:43     ` Xi Ruoyao
2023-02-14 12:57       ` Sagar Acharya
2023-02-14 13:02         ` Xi Ruoyao
2023-02-14 13:27         ` Jonathan Wakely
2023-02-14 13:36 ` Kai Ruottu
2023-02-14 13:46   ` Kai Ruottu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).