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

Make GHC work on armv7l-linux #33405

Merged
merged 4 commits into from Jan 8, 2018
Merged

Make GHC work on armv7l-linux #33405

merged 4 commits into from Jan 8, 2018

Conversation

dhess
Copy link
Contributor

@dhess dhess commented Jan 4, 2018

Motivation for this change

Get GHC working on armv7l-linux

Things done

master on armv7l-linux is currently broken due to #33403, so I can't test this yet on master, but it is currently building on the nixos-unstable-small channel. I will update this PR when I can make progress on master, but these changes are straightforward and only affect ARM builds.

Note that in a few places there are fixes that are also obviously needed for aarch64-linux (e.g., LLVM support), but these patches do not address aarch64-linux in general as there is more work needed to bootstrap that platform due to GHC 7.10.3 and 8.0.2 dependencies in the toolchain for building 8.2.2.

There will also inevitably be more haskellPackages fixes needed for armv7l-linux (usually a dontCheck here and there, in my experience with my own GHC ARM overlay), but I will tackle those as they come up, as compiling even a small subset of haskellPackages on armv7l-linux is a multi-day effort.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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/)
  • Fits CONTRIBUTING.md.

@dhess
Copy link
Contributor Author

dhess commented Jan 6, 2018

Here is an update on the status of this PR:

I am able to build ghc-8.0.2 now on armv7l-linux on Nixpkgs master with these changes. However, the ghc-8.2.2 build reliably segfaults at the same stage of the build (3 times in a row). Here is the tail of the log from my personal Hydra: https://gist.github.com/dhess/97e177541f1c047905919042f8fad075 All 3 builds broke at the same point and approximately the same time in the build (5 hours).

As it's a segfault, I assume the compile is running out of memory. Before this last attempt, I bumped the swap on my Jetson TK1 up to 2GB (so 4GB total including RAM), but that did not help. I will now try to reduce the number of concurrent jobs to 2, which will slow things down quite a bit but will hopefully address this issue and get the build to finish.

In any case, I think these changes are ready to merge -- they do not affect other platforms and are sufficient to get ghc-8.0.2 building on armv7l-linux, in any case. More work may yet need to be done to make the ghc-8.2.2 build reliable, but I don't believe that any of the commits here will be affected by such changes; if it does turn out to be memory pressure issue, then likely the number of concurrent jobs will have to be limited during the ghc-8.2.2 build.

The main thing is that I would like to get these changes committed before more of the cross-compile stuff hits master, so that I don't have to maintain these fixes across multiple upstream commits.

@peti can you please have a look?

@peti peti merged commit 48a6d1a into NixOS:master Jan 8, 2018
@dhess dhess deleted the ghc-armv7l branch January 8, 2018 18:33
@Ericson2314
Copy link
Member

Oh no, I didn't review this in time. stdenv.is* is very confusing in terms of cross cause we don't know whether we are referring to the build or host platforms.

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

@dhess might you have any time to change these accordingly?

@@ -43,6 +43,7 @@ stdenv.mkDerivation rec {
or (throw "cannot bootstrap GHC on this platform"));

nativeBuildInputs = [ perl ];
buildInputs = stdenv.lib.optionals stdenv.isArm [ llvm_35 ];
Copy link
Member

Choose a reason for hiding this comment

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

stdenv.targetPlatform.isArm

@@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
./relocation.patch
];

buildInputs = [ ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour ];
buildInputs = [ ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour ] ++ stdenv.lib.optionals stdenv.isArm [ llvm_35 ];
Copy link
Member

Choose a reason for hiding this comment

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

targetPlatform.isArm

@@ -46,7 +46,7 @@ stdenv.mkDerivation (rec {
sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk
'';

buildInputs = [ alex autoconf automake ghc happy hscolour perl python3 sphinx ];
buildInputs = [ alex autoconf automake ghc happy hscolour perl python3 sphinx ] ++ stdenv.lib.optionals (stdenv.isArm || stdenv.isAarch64) [ llvm_39 ];
Copy link
Member

Choose a reason for hiding this comment

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

(targetPlatform.isArm || targetPlatform.isAarch64)

@@ -46,6 +46,7 @@ stdenv.mkDerivation rec {
or (throw "cannot bootstrap GHC on this platform"));

nativeBuildInputs = [ perl ];
buildInputs = stdenv.lib.optionals (stdenv.isArm || stdenv.isAarch64) [ llvm_39 ];
Copy link
Member

Choose a reason for hiding this comment

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

(with stdenv.targetPlatform; isArm || isAarch64)

@@ -130,7 +130,7 @@ let
(optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
(optionalString enableParallelBuilding "--ghc-option=-j$NIX_BUILD_CORES")
(optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
(enableFeature (enableDeadCodeElimination && (versionAtLeast "8.0.1" ghc.version)) "split-objs")
(enableFeature (enableDeadCodeElimination && !stdenv.isArm && !stdenv.isAarch64 && (versionAtLeast "8.0.1" ghc.version)) "split-objs")
Copy link
Member

Choose a reason for hiding this comment

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

(hostPlatform.isArm || hostPlatform.isAarch64)

@dhess
Copy link
Contributor Author

dhess commented Jan 9, 2018

@Ericson2314 Yes, of course. I figured there would be cross fixes coming down the pipe.

@Ericson2314
Copy link
Member

@dhess Thanks! Yeah just would to confirm those additions will work for you. Then, when I land the cross stuff it will be one fewer likely regression :).

@dhess
Copy link
Contributor Author

dhess commented Jan 9, 2018

@Ericson2314 It might take me a day or two to get to this (because that is roughly the turnaround time on GHC builds for armv7l-linux, unfortunately) but ping me if you haven't seen it by then.

@dhess
Copy link
Contributor Author

dhess commented Jan 11, 2018

@Ericson2314 PR made, see #33733. Please review and make sure I didn't miss something.

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

4 participants