public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Cross compiler riscv64 building
@ 2023-02-08 11:11 Sagar Acharya
  2023-02-08 11:18 ` Jonathan Wakely
  2023-02-08 12:45 ` David Brown
  0 siblings, 2 replies; 8+ messages in thread
From: Sagar Acharya @ 2023-02-08 11:11 UTC (permalink / raw)
  To: Gcc Help

How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.

I have it's default gcc installed which I want to use for compiling.
Thanking you
Sagar Acharya
https://designman.org

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

* Re: Cross compiler riscv64 building
  2023-02-08 11:11 Cross compiler riscv64 building Sagar Acharya
@ 2023-02-08 11:18 ` Jonathan Wakely
  2023-02-09 11:20   ` Sagar Acharya
  2023-02-08 12:45 ` David Brown
  1 sibling, 1 reply; 8+ messages in thread
From: Jonathan Wakely @ 2023-02-08 11:18 UTC (permalink / raw)
  To: Sagar Acharya; +Cc: Gcc Help

On Wed, 8 Feb 2023 at 11:12, Sagar Acharya via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.
>
> I have it's default gcc installed which I want to use for compiling.

See https://wiki.osdev.org/GCC_Cross-Compiler

In summary:
Download the gcc and binutils source.
Configure binutils with --prefix=$DIR --target=riscv64-unknown-elf for
some $DIR.
Run make && make install.
Configure gcc with the same --prefix and --target options.
Run make && make install.

If you want a hosted target like riscv64-unknown-linux-gnu for
compiling user-space programs, then you'll need to have a copy of the
target headers and libraries available, and point GCC to them with the
--sysroot option.
See https://wiki.osdev.org/Hosted_GCC_Cross-Compiler

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

* Re: Cross compiler riscv64 building
  2023-02-08 11:11 Cross compiler riscv64 building Sagar Acharya
  2023-02-08 11:18 ` Jonathan Wakely
@ 2023-02-08 12:45 ` David Brown
  1 sibling, 0 replies; 8+ messages in thread
From: David Brown @ 2023-02-08 12:45 UTC (permalink / raw)
  To: Sagar Acharya, Gcc Help

On 08/02/2023 12:11, Sagar Acharya via Gcc-help wrote:
> How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.
> 
> I have it's default gcc installed which I want to use for compiling.
> Thanking you
> Sagar Acharya
> https://designman.org
> 

For many people, a better option is to use pre-built binaries.  Getting 
a complete toolchain for cross-development is a fair bit of work, and 
can involve a lot of trial and error and research.  The compiler, gcc, 
is just one part of the job (albeit a big part) - you have binutils, 
libraries, debuggers, and perhaps other bits and pieces.  It can be an 
educational and - if you like that sort of thing - enjoyable task.  But 
it can also be frustrating and time-consuming.  And if your ARM host 
here is a small system (say, a Raspberry Pi rather than an Ampere Altra 
monster), toolchain builds can take a /long/ time.

I have no experience with RISC-V as yet (one day, I hope to use them), 
but it looks like you might get what you need from here : 
<https://xpack.github.io/dev-tools/riscv-none-elf-gcc/>.

(I work mostly with ARM microcontrollers and use ARM's "GNU ARM 
Embedded" toolchains, rather than xPack's.)

I've done more than my fair share of cross-gcc toolchain builds over the 
decades, but for most purposes, ready-built packages make life a lot easier.


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

* Re: Cross compiler riscv64 building
  2023-02-08 11:18 ` Jonathan Wakely
@ 2023-02-09 11:20   ` Sagar Acharya
  2023-02-09 13:28     ` David Brown
  2023-02-09 14:31     ` Jonathan Wakely
  0 siblings, 2 replies; 8+ messages in thread
From: Sagar Acharya @ 2023-02-09 11:20 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Gcc Help

I built binutils. Installed it at /usr/local/riscv64-unknown-elf directory

Now, I tried building gcc with
./configure --host=riscv64-unknown-elf
make

However, the gcc directory within gcc-12.2.0 has no Makefile made during configure command. So it enters gcc-12.2.0/gcc dir, sees no Makefile prepared, exits with error.

How do I solve this?

Thanking you
Sagar Acharya
https://designman.org



8 Feb 2023, 16:48 by jwakely.gcc@gmail.com:

> On Wed, 8 Feb 2023 at 11:12, Sagar Acharya via Gcc-help
> <gcc-help@gcc.gnu.org> wrote:
>
>>
>> How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.
>>
>> I have it's default gcc installed which I want to use for compiling.
>>
>
> See https://wiki.osdev.org/GCC_Cross-Compiler
>
> In summary:
> Download the gcc and binutils source.
> Configure binutils with --prefix=$DIR --target=riscv64-unknown-elf for
> some $DIR.
> Run make && make install.
> Configure gcc with the same --prefix and --target options.
> Run make && make install.
>
> If you want a hosted target like riscv64-unknown-linux-gnu for
> compiling user-space programs, then you'll need to have a copy of the
> target headers and libraries available, and point GCC to them with the
> --sysroot option.
> See https://wiki.osdev.org/Hosted_GCC_Cross-Compiler
>

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

* Re: Cross compiler riscv64 building
  2023-02-09 11:20   ` Sagar Acharya
@ 2023-02-09 13:28     ` David Brown
  2023-02-13 12:02       ` Sagar Acharya
  2023-02-09 14:31     ` Jonathan Wakely
  1 sibling, 1 reply; 8+ messages in thread
From: David Brown @ 2023-02-09 13:28 UTC (permalink / raw)
  To: Sagar Acharya, Jonathan Wakely; +Cc: Gcc Help

On 09/02/2023 12:20, Sagar Acharya via Gcc-help wrote:
> I built binutils. Installed it at /usr/local/riscv64-unknown-elf directory
> 
> Now, I tried building gcc with
> ./configure --host=riscv64-unknown-elf
> make
> 
> However, the gcc directory within gcc-12.2.0 has no Makefile made during configure command. So it enters gcc-12.2.0/gcc dir, sees no Makefile prepared, exits with error.
> 
> How do I solve this?
> 

You are mixing up "host" and "target".  "Host" is the computer that runs 
the compiler, "target" is the computer that runs the compiled code.  So 
"host" for you will be an ARM system since you are doing your builds on 
an ARM computer, while "target" will be RISCV.

If you really want to make your own cross-toolchain, you are going to 
have to spend a good amount of time reading about it and trying things 
out.  It is an educational process, but it takes work.  You can't expect 
to do it based on asking a few questions on a mailing list, any more 
than you can expect to learn C programming by asking questions in a C 
newsgroup.

Again - I strongly suggest you use pre-built packages.  Even if you 
later decide that a DIY toolchain will be fun, having the pre-built 
packages for comparison will make things much easier.

mvh.,

David



> Thanking you
> Sagar Acharya
> https://designman.org
> 
> 
> 
> 8 Feb 2023, 16:48 by jwakely.gcc@gmail.com:
> 
>> On Wed, 8 Feb 2023 at 11:12, Sagar Acharya via Gcc-help
>> <gcc-help@gcc.gnu.org> wrote:
>>
>>>
>>> How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.
>>>
>>> I have it's default gcc installed which I want to use for compiling.
>>>
>>
>> See https://wiki.osdev.org/GCC_Cross-Compiler
>>
>> In summary:
>> Download the gcc and binutils source.
>> Configure binutils with --prefix=$DIR --target=riscv64-unknown-elf for
>> some $DIR.
>> Run make && make install.
>> Configure gcc with the same --prefix and --target options.
>> Run make && make install.
>>
>> If you want a hosted target like riscv64-unknown-linux-gnu for
>> compiling user-space programs, then you'll need to have a copy of the
>> target headers and libraries available, and point GCC to them with the
>> --sysroot option.
>> See https://wiki.osdev.org/Hosted_GCC_Cross-Compiler
>>
> 


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

* Re: Cross compiler riscv64 building
  2023-02-09 11:20   ` Sagar Acharya
  2023-02-09 13:28     ` David Brown
@ 2023-02-09 14:31     ` Jonathan Wakely
  1 sibling, 0 replies; 8+ messages in thread
From: Jonathan Wakely @ 2023-02-09 14:31 UTC (permalink / raw)
  To: Sagar Acharya; +Cc: Gcc Help

On Thu, 9 Feb 2023 at 11:20, Sagar Acharya wrote:
>
> I built binutils. Installed it at /usr/local/riscv64-unknown-elf directory
>
> Now, I tried building gcc with
> ./configure --host=riscv64-unknown-elf

Why would you do that? That's not what I suggested, and not what the
links I gave suggest. And it's wrong.


> make
>
> However, the gcc directory within gcc-12.2.0 has no Makefile made during configure command. So it enters gcc-12.2.0/gcc dir, sees no Makefile prepared, exits with error.
>
> How do I solve this?
>
> Thanking you
> Sagar Acharya
> https://designman.org
>
>
>
> 8 Feb 2023, 16:48 by jwakely.gcc@gmail.com:
>
> > On Wed, 8 Feb 2023 at 11:12, Sagar Acharya via Gcc-help
> > <gcc-help@gcc.gnu.org> wrote:
> >
> >>
> >> How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.
> >>
> >> I have it's default gcc installed which I want to use for compiling.
> >>
> >
> > See https://wiki.osdev.org/GCC_Cross-Compiler
> >
> > In summary:
> > Download the gcc and binutils source.
> > Configure binutils with --prefix=$DIR --target=riscv64-unknown-elf for
> > some $DIR.
> > Run make && make install.
> > Configure gcc with the same --prefix and --target options.
> > Run make && make install.
> >
> > If you want a hosted target like riscv64-unknown-linux-gnu for
> > compiling user-space programs, then you'll need to have a copy of the
> > target headers and libraries available, and point GCC to them with the
> > --sysroot option.
> > See https://wiki.osdev.org/Hosted_GCC_Cross-Compiler
> >

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

* Re: Cross compiler riscv64 building
  2023-02-09 13:28     ` David Brown
@ 2023-02-13 12:02       ` Sagar Acharya
  2023-02-13 12:42         ` David Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Sagar Acharya @ 2023-02-13 12:02 UTC (permalink / raw)
  To: David Brown; +Cc: Jonathan Wakely, Gcc Help

Where can I get pre-built binaries for RPI3(aarch64) to compile for target riscv64?
Thanking you
Sagar Acharya
https://designman.org



9 Feb 2023, 18:58 by david@westcontrol.com:

> On 09/02/2023 12:20, Sagar Acharya via Gcc-help wrote:
>
>> I built binutils. Installed it at /usr/local/riscv64-unknown-elf directory
>>
>> Now, I tried building gcc with
>> ./configure --host=riscv64-unknown-elf
>> make
>>
>> However, the gcc directory within gcc-12.2.0 has no Makefile made during configure command. So it enters gcc-12.2.0/gcc dir, sees no Makefile prepared, exits with error.
>>
>> How do I solve this?
>>
>
> You are mixing up "host" and "target".  "Host" is the computer that runs the compiler, "target" is the computer that runs the compiled code.  So "host" for you will be an ARM system since you are doing your builds on an ARM computer, while "target" will be RISCV.
>
> If you really want to make your own cross-toolchain, you are going to have to spend a good amount of time reading about it and trying things out.  It is an educational process, but it takes work.  You can't expect to do it based on asking a few questions on a mailing list, any more than you can expect to learn C programming by asking questions in a C newsgroup.
>
> Again - I strongly suggest you use pre-built packages.  Even if you later decide that a DIY toolchain will be fun, having the pre-built packages for comparison will make things much easier.
>
> mvh.,
>
> David
>
>
>
>> Thanking you
>> Sagar Acharya
>> https://designman.org
>>
>>
>>
>> 8 Feb 2023, 16:48 by jwakely.gcc@gmail.com:
>>
>>> On Wed, 8 Feb 2023 at 11:12, Sagar Acharya via Gcc-help
>>> <gcc-help@gcc.gnu.org> wrote:
>>>
>>>>
>>>> How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.
>>>>
>>>> I have it's default gcc installed which I want to use for compiling.
>>>>
>>>
>>> See https://wiki.osdev.org/GCC_Cross-Compiler
>>>
>>> In summary:
>>> Download the gcc and binutils source.
>>> Configure binutils with --prefix=$DIR --target=riscv64-unknown-elf for
>>> some $DIR.
>>> Run make && make install.
>>> Configure gcc with the same --prefix and --target options.
>>> Run make && make install.
>>>
>>> If you want a hosted target like riscv64-unknown-linux-gnu for
>>> compiling user-space programs, then you'll need to have a copy of the
>>> target headers and libraries available, and point GCC to them with the
>>> --sysroot option.
>>> See https://wiki.osdev.org/Hosted_GCC_Cross-Compiler
>>>

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

* Re: Cross compiler riscv64 building
  2023-02-13 12:02       ` Sagar Acharya
@ 2023-02-13 12:42         ` David Brown
  0 siblings, 0 replies; 8+ messages in thread
From: David Brown @ 2023-02-13 12:42 UTC (permalink / raw)
  To: Sagar Acharya; +Cc: Jonathan Wakely, Gcc Help

Hi,

I already sent you a link in a previous answer:
<https://xpack.github.io/dev-tools/riscv-none-elf-gcc/>.

(Or you can do as I did when I found that site - Google a bit.  xpack is 
not the only project that has cross-development toolchains, it's just 
the first I found targeting RISC-V.  crosstools-ng would be another 
place to look.)

The gcc developers themselves do not make or maintain binary packages. 
They try to help people who build cross-compilers, but it is a lot more 
efficient if end-users go via projects like xpack.  And it is better for 
the users too, because you need a lot more than just gcc to put together 
a cross-development toolchain.

mvh.,

David



On 13/02/2023 13:02, Sagar Acharya wrote:
> Where can I get pre-built binaries for RPI3(aarch64) to compile for target riscv64?
> Thanking you
> Sagar Acharya
> https://designman.org
> 
> 
> 
> 9 Feb 2023, 18:58 by david@westcontrol.com:
> 
>> On 09/02/2023 12:20, Sagar Acharya via Gcc-help wrote:
>>
>>> I built binutils. Installed it at /usr/local/riscv64-unknown-elf directory
>>>
>>> Now, I tried building gcc with
>>> ./configure --host=riscv64-unknown-elf
>>> make
>>>
>>> However, the gcc directory within gcc-12.2.0 has no Makefile made during configure command. So it enters gcc-12.2.0/gcc dir, sees no Makefile prepared, exits with error.
>>>
>>> How do I solve this?
>>>
>>
>> You are mixing up "host" and "target".  "Host" is the computer that runs the compiler, "target" is the computer that runs the compiled code.  So "host" for you will be an ARM system since you are doing your builds on an ARM computer, while "target" will be RISCV.
>>
>> If you really want to make your own cross-toolchain, you are going to have to spend a good amount of time reading about it and trying things out.  It is an educational process, but it takes work.  You can't expect to do it based on asking a few questions on a mailing list, any more than you can expect to learn C programming by asking questions in a C newsgroup.
>>
>> Again - I strongly suggest you use pre-built packages.  Even if you later decide that a DIY toolchain will be fun, having the pre-built packages for comparison will make things much easier.
>>
>> mvh.,
>>
>> David
>>
>>
>>
>>> Thanking you
>>> Sagar Acharya
>>> https://designman.org
>>>
>>>
>>>
>>> 8 Feb 2023, 16:48 by jwakely.gcc@gmail.com:
>>>
>>>> On Wed, 8 Feb 2023 at 11:12, Sagar Acharya via Gcc-help
>>>> <gcc-help@gcc.gnu.org> wrote:
>>>>
>>>>>
>>>>> How do I configure and build a cross compiler for target riscv64 of latest gcc on aarch64 musl based void linux.
>>>>>
>>>>> I have it's default gcc installed which I want to use for compiling.
>>>>>
>>>>
>>>> See https://wiki.osdev.org/GCC_Cross-Compiler
>>>>
>>>> In summary:
>>>> Download the gcc and binutils source.
>>>> Configure binutils with --prefix=$DIR --target=riscv64-unknown-elf for
>>>> some $DIR.
>>>> Run make && make install.
>>>> Configure gcc with the same --prefix and --target options.
>>>> Run make && make install.
>>>>
>>>> If you want a hosted target like riscv64-unknown-linux-gnu for
>>>> compiling user-space programs, then you'll need to have a copy of the
>>>> target headers and libraries available, and point GCC to them with the
>>>> --sysroot option.
>>>> See https://wiki.osdev.org/Hosted_GCC_Cross-Compiler
>>>>

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 11:11 Cross compiler riscv64 building Sagar Acharya
2023-02-08 11:18 ` Jonathan Wakely
2023-02-09 11:20   ` Sagar Acharya
2023-02-09 13:28     ` David Brown
2023-02-13 12:02       ` Sagar Acharya
2023-02-13 12:42         ` David Brown
2023-02-09 14:31     ` Jonathan Wakely
2023-02-08 12:45 ` David Brown

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).