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

WIP: z80: add cross-compile support #101993

Closed
wants to merge 6 commits into from
Closed

WIP: z80: add cross-compile support #101993

wants to merge 6 commits into from

Conversation

@siraben
Copy link
Member

@siraben siraben commented Oct 29, 2020

Motivation for this change

#101990

Current difficulty seems to be two things;

  • Get z88dk to work in place of gcc
  • Use the newlib C library which is in z88dk
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@siraben
Copy link
Member Author

@siraben siraben commented Oct 29, 2020

This is the first time I've added cross-compilation support, so I'm following my intuition from #72657 and #48286.

@siraben
Copy link
Member Author

@siraben siraben commented Oct 29, 2020

Fork of GCC 4.8 that targets Z80. https://github.com/AHelper/gcc/tree/z80-target However I think it's better to try to get cross-compilation support using z88dk's compiler.

@@ -304,6 +305,12 @@ stdenv.mkDerivation {
done
''

+ optionalString (libc != null && targetPlatform.isZ80) ''
for isa in z80; do

This comment has been minimized.

@Ericson2314

Ericson2314 Oct 29, 2020
Member

Is this supposed to grow?

This comment has been minimized.

@siraben

siraben Oct 29, 2020
Author Member

I don't think so. I'll fix this.

This comment has been minimized.

@siraben

siraben Oct 29, 2020
Author Member

I'm not even sure it makes sense to modify bintools-wrapper like this, at least until the Z80 libcissue is resolved.

@siraben
Copy link
Member Author

@siraben siraben commented Oct 29, 2020

Current difficulty seems to be two things;

  1. getting z88dk to work in place of gcc
  2. using thenewlibC library also in z88dk
@Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Oct 29, 2020

@siraben I don't think z88dk is using cc-wrapper? If this isn't working try doing z88dk -> z88dk-unwraped and then making defining z88dk with wrapCC.

@siraben
Copy link
Member Author

@siraben siraben commented Oct 29, 2020

I seem to get infinite loop error;

  z88dk = wrapCC {
    cc = z88dk-unwrapped;
    extraBuildCommands = ''
      wrap zcc $wrapper $ccPath/zcc
      export named_cc=zcc
    '';
  };

  z88dk-unwrapped = callPackage ../development/compilers/z88dk { };
@siraben siraben marked this pull request as draft Oct 29, 2020
@siraben siraben changed the title z80: add cross-compile support WIP: z80: add cross-compile support Oct 29, 2020
@siraben
Copy link
Member Author

@siraben siraben commented Oct 29, 2020

@cleverca22 if you're available I'd greatly appreciate your help in this PR

@@ -68,7 +68,7 @@ in lib.init bootStages ++ [
else if crossSystem.useLLVM or false
then buildPackages.llvmPackages_8.lldClang
else if crossSystem.isZ80
then buildPackages.z88dk
then buildPackages.z88dk-unwrapped

This comment has been minimized.

@Ericson2314

Ericson2314 Oct 29, 2020
Member

This should be buildPackages.z88dk so I guess we'll need to figure out a different way to break the cycle.

@siraben
Copy link
Member Author

@siraben siraben commented Oct 30, 2020

Here's an example of cross-compilation to the reMarkable tablet, looks like we would use wrapCC similarly https://github.com/pl-semiotics/nix-remarkable/blob/15ea031e95670c95fabeb27808446f4f3a645782/rM/toolchain-pkgs.nix#L51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants