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

Initial implementation of cr16 cross-compile #102049

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

@siraben
Copy link
Member

@siraben siraben commented Oct 29, 2020

Motivation for this change
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.
@Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Oct 29, 2020

Oh nice, this one doesn't need a GCC or binutils forks?

@siraben
Copy link
Member Author

@siraben siraben commented Oct 29, 2020

GCC builds but cannot produce executables

$ nix-build -A pkgsCross.cr16.hello   
these derivations will be built:
  /nix/store/qkqz7wpmszv8l48xkcb4w2shp1x3ygq1-hello-2.10-cr16-elf.drv
building '/nix/store/qkqz7wpmszv8l48xkcb4w2shp1x3ygq1-hello-2.10-cr16-elf.drv'...
unpacking sources
unpacking source archive /nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz
source root is hello-2.10
setting SOURCE_DATE_EPOCH to timestamp 1416139241 of file hello-2.10/ChangeLog
patching sources
updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.guess
configuring
configure flags: --disable-dependency-tracking --prefix=/nix/store/6l4kqxw7ngsmn8zrcb9frig2m5n3ckbn-hello-2.10-cr16-elf --build=x86_64-apple-darwin --host=cr16-elf
checking for a BSD-compatible install... /nix/store/g77kammvqqn63v01ppig43m2yn2s1lqd-coreutils-8.31/bin/install -c
checking whether build environment is sane... yes
checking for cr16-elf-strip... cr16-elf-strip
checking for a thread-safe mkdir -p... /nix/store/g77kammvqqn63v01ppig43m2yn2s1lqd-coreutils-8.31/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for cr16-elf-gcc... cr16-elf-gcc
checking whether the C compiler works... no
configure: error: in `/private/tmp/nix-build-hello-2.10-cr16-elf.drv-0/hello-2.10':
configure: error: C compiler cannot create executables
See `config.log' for more details
builder for '/nix/store/qkqz7wpmszv8l48xkcb4w2shp1x3ygq1-hello-2.10-cr16-elf.drv' failed with exit code 77
error: build of '/nix/store/qkqz7wpmszv8l48xkcb4w2shp1x3ygq1-hello-2.10-cr16-elf.drv' faile
@Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Oct 29, 2020

@siraben Can you add the WIP: then to all your PRs which aren't ready to merge?

@siraben siraben changed the title cr16: add cross-compile support WIP: cr16: add cross-compile support Oct 29, 2020
@siraben siraben marked this pull request as draft Oct 29, 2020
@siraben siraben marked this pull request as ready for review Nov 3, 2020
@siraben siraben changed the title WIP: cr16: add cross-compile support Initial implementation of rc16 cross-compile Nov 3, 2020
@siraben
Copy link
Member Author

@siraben siraben commented Nov 3, 2020

@GrahamcOfBorg build pkgs.pkgsCross.cr16.hello

@siraben siraben changed the title Initial implementation of rc16 cross-compile Initial implementation of cr16 cross-compile Nov 3, 2020
@siraben
Copy link
Member Author

@siraben siraben commented Nov 3, 2020

Currently it compiles GCC successfully, however I get a linking error.

main.c
int main() {
  return 0;
}
Log
$ $CC -o hello hello.c
/nix/store/dfcdwnbsyfwqc7pl0i3f4vgcw5xrrxvg-cr16-elf-binutils-2.31.1/bin/cr16-elf-ld: warning: -z now ignored
/nix/store/dfcdwnbsyfwqc7pl0i3f4vgcw5xrrxvg-cr16-elf-binutils-2.31.1/bin/cr16-elf-ld: warning: -z relro ignored
/nix/store/dfcdwnbsyfwqc7pl0i3f4vgcw5xrrxvg-cr16-elf-binutils-2.31.1/bin/cr16-elf-ld: /nix/store/hfcz93lhbsfpkpiygnj6b26ymkw62vbj-newlib-3.3.0-cr16-elf/cr16-elf/lib/crt1.o: in function `start':
(.text+0x1c): undefined reference to `_init'
/nix/store/dfcdwnbsyfwqc7pl0i3f4vgcw5xrrxvg-cr16-elf-binutils-2.31.1/bin/cr16-elf-ld: (.text+0x20): undefined reference to `_fini'
/nix/store/dfcdwnbsyfwqc7pl0i3f4vgcw5xrrxvg-cr16-elf-binutils-2.31.1/bin/cr16-elf-ld: /nix/store/hfcz93lhbsfpkpiygnj6b26ymkw62vbj-newlib-3.3.0-cr16-elf/cr16-elf/lib/libc.a(lib_a-fini.o): in function `_libc_fini_array':
/private/tmp/nix-build-newlib-3.3.0-cr16-elf.drv-0/newlib-3.3.0/cr16-elf/newlib/libc/misc/../../../.././newlib/libc/misc/fini.c:36: undefined reference to `_fini'
collect2: error: ld returned 1 exit status
@siraben siraben force-pushed the siraben:cr16-cross branch 2 times, most recently from 707ee7b to a6f1013 Nov 4, 2020
pname = "newlib";
inherit version;
src = fetchurl {
url = "ftp://sourceware.org/pub/newlib/newlib-${version}.tar.gz";

This comment has been minimized.

@Ericson2314

Ericson2314 Nov 4, 2020
Member

This is a vanilla newlib src, so it shouldn't go in in a cr16 directory. We might also have it already packaged?

@siraben siraben marked this pull request as draft Dec 7, 2020
@stale
Copy link

@stale stale bot commented Jul 21, 2021

I marked this as stale due to inactivity. → More info

@siraben siraben force-pushed the siraben:cr16-cross branch from a6f1013 to d6d9fa7 Jul 23, 2021
@stale stale bot removed the 2.status: stale label Jul 23, 2021
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

3 participants