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

riscv-gnu-toolchain-*: init at 2023.01.04 #214185

Conversation

GenericNerdyUsername
Copy link
Contributor

@GenericNerdyUsername GenericNerdyUsername commented Feb 2, 2023

Description of changes

Added a toolchain which targets riscv(64/32)-unkown-elf. This is different to pkgsCross.riscv(64/32)-embedded, as that targets riscv(64/32)-none-elf.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Relevant: #213222

genericnerdyusername = {
name = "GenericNerdyUsername";
email = "genericnerdyusername@proton.me";

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

- cd $(srcdir) && \
- flock `git rev-parse --git-dir`/config git submodule init $(dir $@) && \
- flock `git rev-parse --git-dir`/config git submodule update $(dir $@)
+ true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
+ true

Isn't this the same?

Comment on lines 73 to 79

nativeBuildInputs = [ autoconf automake flock curl python3 gawk bison flex texinfo gperf ];
buildInputs = [ libmpc libtool expat.dev gmp.dev mpfr.dev zlib ];
hardeningDisable = [ "format" ];

patches = [ ./nodotgit.patch ];
configureFlags = [
"--with-arch=${isa}"
] ++
srcFlags ++
lib.optional withLinux "--enable-linux";

preConfigure = "patchShebangs .";

src = fetchFromGitHub {
owner = "riscv-collab";
repo = "riscv-gnu-toolchain";
rev = version;
hash = "sha256-PXPQ/ho+fOudZRErnyQZTVFdceWGBF+geo+3y0tkNm4=";
};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
nativeBuildInputs = [ autoconf automake flock curl python3 gawk bison flex texinfo gperf ];
buildInputs = [ libmpc libtool expat.dev gmp.dev mpfr.dev zlib ];
hardeningDisable = [ "format" ];
patches = [ ./nodotgit.patch ];
configureFlags = [
"--with-arch=${isa}"
] ++
srcFlags ++
lib.optional withLinux "--enable-linux";
preConfigure = "patchShebangs .";
src = fetchFromGitHub {
owner = "riscv-collab";
repo = "riscv-gnu-toolchain";
rev = version;
hash = "sha256-PXPQ/ho+fOudZRErnyQZTVFdceWGBF+geo+3y0tkNm4=";
};
src = fetchFromGitHub {
owner = "riscv-collab";
repo = "riscv-gnu-toolchain";
rev = version;
hash = "sha256-PXPQ/ho+fOudZRErnyQZTVFdceWGBF+geo+3y0tkNm4=";
};
nativeBuildInputs = [ autoconf automake flock curl python3 gawk bison flex texinfo gperf ];
buildInputs = [ libmpc libtool expat.dev gmp.dev mpfr.dev zlib ];
hardeningDisable = [ "format" ];
patches = [ ./nodotgit.patch ];
configureFlags = [
"--with-arch=${isa}"
]
++ srcFlags
++ lib.optional withLinux "--enable-linux";
preConfigure = "patchShebangs .";

Can we be more specific with files need patching? Maybe some directory?

Why do we need curl in PATH? We cannot download things anyway.

I think we can drop the .dev suffix in buildInputs.

Also patching should be done in postPatch if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

turns out the patching isn't necessary, its just leftover from when i was trying to get it working

one of curl, wget and ftp is needed for the configure

Comment on lines +32 to +49
, srcs ? {
binutils = {
url = "mirror://gnu/binutils/binutils-2.39.tar.bz2";
hash = "sha256-2iSoT+8iAQLdJAQt8G/eqFHCYUpTd/hu/6KPM7exYUg=";
};
dejagnu = {
url = "mirror://gnu/dejagnu/dejagnu-1.6.3.tar.gz";
hash = "sha256-h9rvrNeVi0pp+IxoVtvRY0JhljxBQHnQw3H1ic1mouM=";
};
gcc = gcc12.cc.src;
glibc = glibc.src;
newlib = newlib.src;
gdb = gdb.src;
qemu = qemu.src;
musl = musl.src;
spike = spike.src;
pk = riscv-pk.src;
}
Copy link
Member

Choose a reason for hiding this comment

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

Please move this out of the inputs. It is not really extensible especially when you want to change one variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could you not use pkg.override (old: new: {srcs=old.srcs//{new-pkg=new-pkg-src}})?

Copy link
Member

Choose a reason for hiding this comment

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

This is a bit hacky. Normally src and srcs are exclusive and I would rather expect that overwriting gcc and its source would affect it. Generally it is not such a great idea to put big defaults behind ?.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better mechanism, or is the ability to change the sources uneeded?

Comment on lines +66 to +67
srcs_fetched = lib.mapAttrs (name: value: if value ? outPath then value else fetchurl value) srcs;
srcs_extracted = lib.mapAttrs (name: value: extract value) srcs_fetched;
Copy link
Member

Choose a reason for hiding this comment

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

For which src are we doing this? Maybe we can just change that one package to avoid this.

Copy link
Contributor Author

@GenericNerdyUsername GenericNerdyUsername Feb 6, 2023

Choose a reason for hiding this comment

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

three of them use fetchFromGitHub, and I'm not aware of a way to make that use fetchurl instead of fetchzip

Copy link
Member

Choose a reason for hiding this comment

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

Why do we want to use fetchurl for github sources or am I mixing things up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

some use fetchFromGitHub, and some use fetchurl. This means we have a mix of compressed and uncompressed sources

buildInputs = [ libmpc libtool expat.dev gmp.dev mpfr.dev zlib ];
hardeningDisable = [ "format" ];

patches = [ ./nodotgit.patch ];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
patches = [ ./nodotgit.patch ];
patches = [ ./no-dot-git.patch ];

@GenericNerdyUsername
Copy link
Contributor Author

Everything mentioned in the review should be fixed now

@GenericNerdyUsername GenericNerdyUsername force-pushed the riscv-gnu-toolchain branch 2 times, most recently from 722b21e to 015829a Compare February 5, 2023 20:38
@GenericNerdyUsername
Copy link
Contributor Author

Ready to merge, i think @SuperSandro2000

@GenericNerdyUsername
Copy link
Contributor Author

#230160 removes the need for this

@GenericNerdyUsername GenericNerdyUsername deleted the riscv-gnu-toolchain branch May 5, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants