public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Does newlib support x86_64-pc-linux-gnu?
@ 2022-05-14 12:50 jdoubleu
  2022-05-14 19:20 ` Keith Packard
  0 siblings, 1 reply; 3+ messages in thread
From: jdoubleu @ 2022-05-14 12:50 UTC (permalink / raw)
  To: newlib

Hello,

please excuse me asking. I'm fairly new to newlib and don't see the 
bigger picture yet. I was wondering whether it is possible to build 
newlib for the linux platform. I would like to link my program against 
newlib instead of glibc and run it on linux.

 From what I understand, it would just require some startup code and a 
backend which forwards some calls to the kernel using syscalls, doesn't it?

Is there anything that speaks against it? Besides not having a real 
use-case.

I'm trying to run the testsuite on my linux host. Right now, all tests 
are linked against glibc, causing me to test glibc instead of newlib.

This would really help me testing newlib, because I don't have any 
"special" hardware, nor emulators setup. It does also offer the 
possibility to test newlib farily easy in a CI.

My host and target platform is: x86_64-pc-linux-gnu

-- 
Cheers
---
🙎🏻‍♂️ jdoubleu

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

* Re: Does newlib support x86_64-pc-linux-gnu?
  2022-05-14 12:50 Does newlib support x86_64-pc-linux-gnu? jdoubleu
@ 2022-05-14 19:20 ` Keith Packard
  2022-05-17 11:13   ` jdoubleu
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Packard @ 2022-05-14 19:20 UTC (permalink / raw)
  To: jdoubleu, newlib

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

jdoubleu <hi@jdoubleu.de> writes:

> I'm trying to run the testsuite on my linux host. Right now, all tests 
> are linked against glibc, causing me to test glibc instead of newlib.
>
> This would really help me testing newlib, because I don't have any 
> "special" hardware, nor emulators setup. It does also offer the 
> possibility to test newlib farily easy in a CI.

It's possible, and picolibc (a newlib fork) uses this in it's CI
setup. What you do is link newlib *before* glibc so that you pull in the
newlib upper-level functions and then use glibc for the syscalls.

It does make some development easier, but there are places which are a
bit funky -- the 'stat' syscall, in particular, where you need to
declare struct stat so that it matches glibc but without using glibc
headers (as you'll be compiling against newlib headers).

It's not that hard to use an arm or risc-v emulator with semihosting
support to test the library though, and that avoids issues like that.

-- 
-keith

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: Does newlib support x86_64-pc-linux-gnu?
  2022-05-14 19:20 ` Keith Packard
@ 2022-05-17 11:13   ` jdoubleu
  0 siblings, 0 replies; 3+ messages in thread
From: jdoubleu @ 2022-05-17 11:13 UTC (permalink / raw)
  To: Keith Packard; +Cc: newlib

Hi Keith,

thanks for the info! I'll try that approach out.

But you're right, it's probably better to just run an emulator.


Cheers
---
🙎🏻‍♂️ jdoubleu
On 5/14/2022 9:20 PM, Keith Packard wrote:
> jdoubleu <hi@jdoubleu.de> writes:
> 
>> I'm trying to run the testsuite on my linux host. Right now, all tests
>> are linked against glibc, causing me to test glibc instead of newlib.
>>
>> This would really help me testing newlib, because I don't have any
>> "special" hardware, nor emulators setup. It does also offer the
>> possibility to test newlib farily easy in a CI.
> 
> It's possible, and picolibc (a newlib fork) uses this in it's CI
> setup. What you do is link newlib *before* glibc so that you pull in the
> newlib upper-level functions and then use glibc for the syscalls.
> 
> It does make some development easier, but there are places which are a
> bit funky -- the 'stat' syscall, in particular, where you need to
> declare struct stat so that it matches glibc but without using glibc
> headers (as you'll be compiling against newlib headers).
> 
> It's not that hard to use an arm or risc-v emulator with semihosting
> support to test the library though, and that avoids issues like that.
> 

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

end of thread, other threads:[~2022-05-17 11:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14 12:50 Does newlib support x86_64-pc-linux-gnu? jdoubleu
2022-05-14 19:20 ` Keith Packard
2022-05-17 11:13   ` jdoubleu

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