Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picolibc #200

Merged
merged 2 commits into from
Mar 31, 2020
Merged

Picolibc #200

merged 2 commits into from
Mar 31, 2020

Conversation

keith-packard
Copy link
Contributor

Adds 'metal-pico' library which contains interfaces for picolibc to sit atop freedom-metal

Copy link
Contributor

@nategraff-sifive nategraff-sifive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Keith!

Just a few comments related to maybe de-duplicating some code here. Is there any way to get picolibc's shim library to use our existing libgloss implementations of _start and sbrk?

pico/crt0.S Outdated Show resolved Hide resolved
pico/sbrk.c Outdated Show resolved Hide resolved
Makefile.am Outdated Show resolved Hide resolved
Copy link
Contributor

@nategraff-sifive nategraff-sifive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nategraff-sifive
Copy link
Contributor

I'm happy with either version of sbrk, but the ifdef version might be slightly easier to maintain?

@keith-packard
Copy link
Contributor Author

I'm happy with either version of sbrk, but the ifdef version might be slightly easier to maintain?

let's use the ifdef one then; we can always switch back :-)

This provides a definition of size_t

Signed-off-by: Keith Packard <keithp@keithp.com>
@keith-packard
Copy link
Contributor Author

I've rebased and tested this with Nate's updated BSP generation code

Copy link
Collaborator

@bsousi5 bsousi5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some question for curiosity

gloss/sys_sbrk.c Show resolved Hide resolved
Copy link
Contributor

@nategraff-sifive nategraff-sifive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a spelling error to fix :)

Makefile.am Outdated Show resolved Hide resolved
This library hooks picolibc to libmetal, offering a small number of
APIs.

Signed-off-by: Keith Packard <keithp@keithp.com>

---

v2:

	Initialize TLS base register from __tls_base and __tdata_size

	    The RISC-V ABI sets the tp register between tls
	    initialized data and tls uninitialized data areas. The
	    linker sets __tls_base to the start of tls data and
	    __tdata_size to the size of the initialized data area, so
	    the correct tp value is the sum of these two symbols.

	libriscv__pico__metal.a → libmetal-pico.a

	    Use the name that freedom-e-sdk wants

	Use gloss/crt0.S and gloss/sys_exit.c for libmetal-pico.a

	    Share source code, especially the startup code, between
	    the two C library users to avoid duplicating work between
	    them.

	Expose sbrk/brk instead of _sbrk/_brk when compiled against picolibc

	    This changes the names of these two functions when using
	    picolibc instead of newlib. Otherwise, the implementation
	    is the same.

	Use gloss/sys_sbrk.c with picolibc

	    Instead of a separate copy with minor edits.

v3:
	Use correct TLS initialization value. Risc-V places TP
	at the base of TLS storage, not between data and BSS values.

v4:
	Fix spelling error in Makefile.am (libmetail-pico → libmetal-pico)
	Found-by: Nathaniel Graff <nathaniel.graff@sifive.com>
@nategraff-sifive nategraff-sifive merged commit ff5740f into master Mar 31, 2020
@nategraff-sifive nategraff-sifive deleted the picolibc branch March 31, 2020 17:42
bsousi5 pushed a commit that referenced this pull request Apr 8, 2020
Support Debug/Release build configurations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants