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

gcc-arm-embedded: 6-2017-q2-update -> 7-2018-q2-update #47542

Merged
merged 1 commit into from Oct 3, 2018

Conversation

prusnak
Copy link
Member

@prusnak prusnak commented Sep 29, 2018

Motivation for this change

gcc-arm-embedded was not updated since mid-2017, this update brings the package to the latest possible version

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Fits CONTRIBUTING.md.

@prusnak
Copy link
Member Author

prusnak commented Sep 29, 2018

I would suggest the inclusion of this change into 18-09 as well.

@tomberek
Copy link
Contributor

nox-review pr 47542 on NixOS

...
gdb_main.c: In function 'gdb_main_loop':
gdb_main.c:157:16: error: this statement may fall through [-Werror=implicit-fallthrough=]
    single_step = true;
                ^
gdb_main.c:159:3: note: here
   case 'c': /* 'c [addr]': Continue [at addr] */
   ^~~~
gdb_main.c:167:16: error: this statement may fall through [-Werror=implicit-fallthrough=]
    single_step = false;
                ^
gdb_main.c:169:3: note: here
   case '?': { /* '?': Request reason for target halt */
   ^~~~
%% bus_spi.c
cc1: all warnings being treated as errors
make: *** [Makefile:71: gdb_main.o] Error 1
%% piniobox.c
...
builder for '/nix/store/cc4pdza1zrk0izxbnqcgrjb19yl8zi0f-blackmagic-1.6.1.drv' failed with exit code 2             
error: build of '/nix/store/5pzgcm2wma2lviibja7km4w3szciw13v-inav-2.0.0-rc2.drv', '/nix/store/cc4pdza1zrk0izxbnqcgrjb19yl8zi0f-blackmagic-1.6.1.drv', '/nix/store/xmir01cxxamlpqslgp4p9cgfg643q9c7-betaflight-3.4.0-rc4.drv', '/nix/store/y4m4a0s68bqzwlwl5w55h13jhrqidkgf-axoloti-1.0.12-1.drv', '/nix/store/y6g3l860w20spam79a8hgnny1mxdpb1y-opentx-2.2.1.drv' failed

@@ -6744,7 +6744,8 @@ with pkgs;
ncurses = pkgsi686Linux.ncurses5;
};
gcc-arm-embedded-6 = callPackage ../development/compilers/gcc-arm-embedded/6 {};
gcc-arm-embedded = gcc-arm-embedded-6;
gcc-arm-embedded-7 = callPackage ../development/compilers/gcc-arm-embedded/7 {};
gcc-arm-embedded = gcc-arm-embedded-7;
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like there are some breakages. perhaps we could keep this at 6 for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in eaa8bb5be5e7b41ff1fe4aa6bc104c010ccfe1f8

@prusnak
Copy link
Member Author

prusnak commented Sep 30, 2018

@tomberek addressed in eaa8bb5be5e7b41ff1fe4aa6bc104c010ccfe1f8 by keeping the default to gcc-arm-embedded-6. Cleaner option would be set 7 as default and fix the packages built using gcc-arm-embedded, there are not too many (gnuk, blackmagic, betaflight, inav, opentx, axoloti), but I don't want to touch other's people packages now as I am quite new to this. Third option is to set dependencies of mentioned packages to "gcc-arm-embedded-6" instead of "gcc-arm-embedded". What do you think?

@jb55
Copy link
Contributor

jb55 commented Sep 30, 2018

Third option is to set dependencies of mentioned packages to "gcc-arm-embedded-6" instead of "gcc-arm-embedded"

sounds good to me

@tomberek
Copy link
Contributor

Provide feedback to the other packages so they are aware of the issue and can fix it. People seem to welcome this.

find $out -type f | while read f; do
patchelf $f > /dev/null 2>&1 || continue
patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python27 ]} "$f" || true
Copy link
Member

Choose a reason for hiding this comment

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

Please consider using autoPatchelfHook. This will make updating a bit easier and is more robust then the approach chosen here.

Copy link
Member

Choose a reason for hiding this comment

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

Adding all libraries to buildInputs will enable the hook to add it to the RPATH.

Copy link
Member Author

@prusnak prusnak Sep 30, 2018

Choose a reason for hiding this comment

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

From your comments, I figured out I should do the following, but should I also modify the find in preFixup or remove the preFixup completely (+ removing fixupPhase from phases)? Sorry, I'm quite new to this :-)

--- a/pkgs/development/compilers/gcc-arm-embedded/7/default.nix
+++ b/pkgs/development/compilers/gcc-arm-embedded/7/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ncurses5, python27 }:
+{ stdenv, fetchurl, ncurses5, python27, autoPatchelfHook }:
 
 stdenv.mkDerivation rec {
   name = "gcc-arm-embedded-${version}";
@@ -24,6 +24,10 @@ stdenv.mkDerivation rec {
     cp -r * $out
   '';
 
+  nativeBuildInputs = [ autoPatchelfHook ];
+
+  buildInputs = [ stdenv.cc.cc ncurses5 python27 ];
+
   dontPatchELF = true;
   dontStrip = true;

Copy link
Member

@Mic92 Mic92 Oct 1, 2018

Choose a reason for hiding this comment

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

In the best case preFixup should become unnecessary. You can also remove the explicit phases assignment, it actually a bit of an anti-pattern to skip phases since users might expect them. You only ever need to specify an installPhase unless there is an make install. dontPatchELF and dontStrip can also go.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am unable to get the build working using the changes you suggest, but I pushed them to a separate gcc-arm-embedded_autopatchelfhook branch, so I can return to that later. I don't want to dig into this any further, I just want to update the package and fix the blackmagic breakage for now.

Copy link
Member

Choose a reason for hiding this comment

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

fair enough.

Copy link
Member

Choose a reason for hiding this comment

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

cc @dezgeg it currently fails on

$ patchelf --remove-rpath /nix/store/0bvwvmaz3rd8iz3zc3vyclwid0sfbbhg-gcc-arm-embedded-7-2018-q2-update/arm-none-eabi/lib/redboot-crt0.o
wrong ELF type
$ file /nix/store/0bvwvmaz3rd8iz3zc3vyclwid0sfbbhg-gcc-arm-embedded-7-2018-q2-update/arm-none-eabi/lib/redboot-crt0.o
/nix/store/0bvwvmaz3rd8iz3zc3vyclwid0sfbbhg-gcc-arm-embedded-7-2018-q2-update/arm-none-eabi/lib/redboot-crt0.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped

https://dl.thalheim.io/e2GdCQGJnobRgFI7F3B73w/auto-patchelf-hook-error.log

I thought I saw some architecture related code in the hook. But I suppose this is not handled yet right?

Copy link
Member Author

@prusnak prusnak Oct 2, 2018

Choose a reason for hiding this comment

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

I suppose that's the reason why it is handled manually in the original script and failures are silently skipped. We don't want to patch stuff that is part of the package, such as lib/redboot-crt0.o which is ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped and thus should not be processed via patchElf.

@prusnak
Copy link
Member Author

prusnak commented Oct 1, 2018

@tomberek I was able to investigate the gcc-arm-embedded-7 compatibility further and found out that the only package that failed with the new gcc-arm-embedded-7 is blackmagic. Luckily, this issue was fixed in their git, so I updated it to the latest revision. Are you OK with that @pjones? This is applied in 4b4e256ed29b472dc7d189dd38c115cf3ad0e6d8, which now passed the nox-review.

@pjones
Copy link
Contributor

pjones commented Oct 1, 2018

@prusnak Sound good to me. Thanks for updating blackmagic.


urlString = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-linux.tar.bz2";

src = fetchurl { url=urlString; sha256="0sgysp3hfpgrkcbfiwkp0a7ymqs02khfbrjabm52b5z61sgi05xv"; }
Copy link
Member

Choose a reason for hiding this comment

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

trailing ; is missing.

src = fetchurl { 
  url = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/${subdir}/gcc-arm-none-eabi-${version}-linux.tar.bz2";
  sha256="0sgysp3hfpgrkcbfiwkp0a7ymqs02khfbrjabm52b5z61sgi05xv"; 
}; 

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in b3531b9

+ update blackmagic to latest commit which includes gcc7 fixes
@Mic92 Mic92 merged commit 50a3061 into NixOS:master Oct 3, 2018
@Mic92
Copy link
Member

Mic92 commented Oct 3, 2018

Thanks!

@prusnak prusnak deleted the gcc-arm-embedded_update branch October 3, 2018 16:45
@prusnak prusnak restored the gcc-arm-embedded_update branch October 3, 2018 16:45
@prusnak
Copy link
Member Author

prusnak commented Oct 3, 2018

@Mic92 Thanks for the merge. What is the correct process to get this into 18.09 release?

@Mic92
Copy link
Member

Mic92 commented Oct 3, 2018

I don't think we should backport gcc-arm-embedded = gcc-arm-embedded-7; since it is already late.
It should be ok to backport it as a new package. In that case open a new pull request targeting release-18.09 branch.

@Mic92
Copy link
Member

Mic92 commented Oct 3, 2018

Use git cherry-pick -x for backporting and then git commit --amend to remove the gcc-arm-embedded = gcc-arm-embedded-7;

@prusnak prusnak deleted the gcc-arm-embedded_update branch October 3, 2018 17:44
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.

None yet

6 participants