newlib: add installation of libgloss for embedded targets #367275
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to get an embedded RISC-V toolchain working, by following pretty much a documented workflow:
This is supposed to work for compiling programs that target "bare-metal". But when I tried to compile my project, GCC complained that it can't fild
-lgloss
. If you're curious what libgloss is, in very simple terms it's a glue layer that allows you to provide implementation for the bare minimum functionality that would get the rest of the libc working. (such as_sbrk
,_open
,_read
and friends).After digging into it for a while, I've figured out that newlib which is shipped by nixpkgs doesn't contain libgloss as part of the build resuts. So this isn't just me misconfiguring the search paths.
You may be wondering - why didn't anyone else find this issue? My current guess is that nobody really uses this combination (newlib-nano plus a bare-metal deployment). Most people who use the cross toolchains likely target an operating system which provides syscalls already and don't implement the stubs themselves.
If you really want to try and reproduce the bug, you need to pass this as a flag to gcc:
--specs=nano.specs
.Also, this bug is not really specific to NixOS, but happened in ArchLinux as well. Here's a relevant bug report:
https://bugs.archlinux.org/task/66548. This is where I've found the fix. Adding the fix in the way I did seems to fix the problem for good.
The fix itself doesn't seem to be dangerous because in case libgloss is absent, it would be skipped and not copied to the build results.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.