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
Changes needed by Reflex Platform #23199
Conversation
b69e2e4
to
bf3cce9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a couple questions about these changes:
@@ -194,7 +194,7 @@ stdenv.mkDerivation ({ | |||
runHook preSetupCompilerEnvironment | |||
|
|||
echo "Build with ${ghc}." | |||
export PATH="${ghc}/bin:$PATH" | |||
export PATH="${if ghc.isGhcjs or false then ghcEnv else ghc}/bin:$PATH" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the intent of this change? What is now on PATH
that otherwise wouldn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original commit reads "This helps support compiler plugins." @ryantrinkle Could you give a short description of why this is so (and why we would want ghcEnv
for ghcjs but not native ghc)? I would also suggest putting the rationale as a comment somewhere near this line.
@@ -159,6 +163,7 @@ in mkDerivation (rec { | |||
--with-cabal ${cabal-install}/bin/cabal \ | |||
--with-gmp-includes ${gmp.dev}/include \ | |||
--with-gmp-libraries ${gmp.out}/lib | |||
${if isNull ghcLibdir then "" else ''echo "${ghcLibdir}" > "$out/lib/ghcjs-${version}/ghc_libdir"''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is ghc_libdir
? A quick google search doesn't find anything insightful. Is this something being used specifically by Reflex/Obsidian in some way, or something more general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other commit doesn't provide any further details, I'm afraid (just says "wip").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cstrahan, @ryantrinkle briefly explained to me that GHCJS has a "hack" that checks for the presence of this symlink and will use it as a way of adding GHCJS plugins. @ryantrinkle uses a plugin in reflex platform that is designed to add more performance optimizations. It is minimally effective at this point but he plans to expand it extensively.
However, for any sort of real accuracy or precision, we would need to hear directly from @ryantrinkle or @luite.
@@ -46,14 +47,18 @@ let | |||
llvm = lib.makeBinPath | |||
([ llvmPackages.llvm ] | |||
++ lib.optional stdenv.isDarwin llvmPackages.clang); | |||
ghcLibdirLink = runCommand "ghc_libdir" {} '' | |||
mkdir -p '${libDir}' | |||
echo '${ghcLibdir}' > '${libDir}/ghc_libdir_override' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this somehow related to ghc_libdir
above; what does ghc_libdir_override
do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @ryantrinkle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep
ing the ghcjs source only shows ghc_libdir
, so I suspect this was merely intended to plumb the path over in mv '${libDir}/ghc_libdir_override' '${libDir}/ghc_libdir'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this seems like a very roundabout way of accomplishing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think I know why this is used. Last time I checked, buildEnv
would try to create as few directories as possible, instead attempting to symlink as many existing directories as possible. If two entries in paths
have the same directory, it would then be forced to create a new directory and symlink the contents of each of those two entries into that new directory.
Because there's an option (in this patch) to allow setting a default setting for ghc_libdir
in the ghcjs/base.nix
expression, we need to toss in something like ghcLibdirLink
in paths
to force baseEnv
's hand, so the user can supply an overriding setting in ghcWithPackages
. Gross, but it works.
pkgs.symlinkJoin
behaves much better here, as it always creates directories in the derivation it produces, rather than trying to use symlinks everywhere.
@peti is there any downside you can see in switching from buildEnv
to symlinkJoin
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cstrahan, I am not aware of any particular reason why we shouldn't be able to switch to symlinkJoin
. I assume that the lndir
tool on which that function is based is no less portable that our implementation of buildEnv
is ... so IMHO we should use whichever one is more convenient. Generally speaking, being able to rely on bin
and etc
referring to real directories in a ghcWithPackages environment sounds like a good idea.
@@ -102,6 +107,9 @@ buildEnv { | |||
done | |||
|
|||
${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"} | |||
${lib.optionalString (isGhcjs && ghcLibdir != null) '' | |||
mv '${libDir}/ghc_libdir_override' '${libDir}/ghc_libdir' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I'm still not sure what we're trying to accomplish here: is there any reason not to inline the echo '${ghcLibdir}' > '${libDir}/ghc_libdir_override'
here, instead of putting ghc_libdir_override
in the symlink forest and then mv
ing it over?
I thought that the ghcjs.patch on master applied cleanly for ghcjs HEAD, but if not, an updated diff is appreciated. And, of course, tweaks to work for iOS are great too. I'm not sure what's going on with |
@cstrahan As it stands now, I would expect the patch phase to fail for ghcjsHEAD, but I have not confirmed that. However, by manually inspecting the line numbers, the new |
So, the patch as it stands actually applies successfully. @3noch Here's how I'd like things to look: master...cstrahan:ghcjs-reflex That's assuming @peti gives the 👍 on the |
@cstrahan Wow, you've gone above and beyond! So much better! I'm confused how the patch applies, since the line numbers are certainly different. :/ |
:)
From the docs:
I'll give this one last sanity check tonight, check for anything I can simplify, and then merge to master. |
@cstrahan TIL! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -105,7 +105,7 @@ in stdenv.mkDerivation (rec { | |||
"RANLIB=${stdenv.binutilsCross}/bin/${cross.config}-ranlib" | |||
"--target=${cross.config}" | |||
"--enable-bootstrap-with-devel-snapshot" | |||
]; | |||
] ++ (lib.optional ("${cross.config}" == "aarch64-apple-darwin14") "--disable-large-address-space"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a minor detail, but I tend to prefer using stdenv.lib
over expecting lib
as an explicit argument. Makes no difference in practice, though, just my 2 cents.
Motivation for this change
Trying to get Reflex-Platform to use latest nixpkgs. This is a start. I need to test this more too.
These changes are derived from NixOS/nixpkgs-channels@nixos-unstable...ryantrinkle:ghcjs-update
Some semantic differences between the original and my changes:
ghcjs/ghcjs.patch
which was being used for all variations of GHCJS. Instead of changing that, I found that the changes only apply to ghcjsHEAD (which is using theghc-8.0
branch) and not the default ghcjs package. So I madepatches
configurable andghcjsHEAD
uses a different patch file.ghcLibdir
wasnull
, then${libDir}/ghc_libdir_override
would end up being written as an empty file. I changed this so that it does not run this code at all whenghcLibdir == null
.cc @ryantrinkle @ElvishJerricco
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)