-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
Feature/mingw fixes #43559
Feature/mingw fixes #43559
Conversation
This commit is not really correct. The `hasActiveLibrary` check is wrong. We can have an active library even if we do not ask for a static lirbary or dynamic one; we can still have just a set of objet files and archives.
Is removing lib subfolder required for this work? I saw you missed a couple of instances. |
@domenkozar to compile
In general I think putting the haskell libs in If you could outline which However I know there was some alternative to this fix somewhere(?) using response files instead? I'm slightly tending against such a solution, as it would still unnecessarily polute the library serach paths in nix. Maybe we need a way to flag some |
I think the proper solution is to not duplicate so many flags: #41340 (comment) |
@domenkozar sure. But why put them in there in the first place? Any haskell tooling will go through the package-db, and pull the proper LD flags anyway. Why have nix provide LD flags what are useless? E.g. why inject Don't get me wrong. Automatically injecting |
#41340 should of course be fixed as well. |
@domenkozar I can't comment on I believe this stuff nixpkgs/pkgs/build-support/bintools-wrapper/ld-wrapper.sh Lines 207 to 210 in 2dc8831
should be really passed via response files. And while we do nixpkgs/pkgs/build-support/bintools-wrapper/setup-hook.sh Lines 26 to 28 in 2dc8831
I think we should just not have |
@angerman fair points. I'm testing on darwin, meanwhile you also need:
|
@domenkozar right. I've also changed |
@peti I think this can go to testing. |
@@ -138,12 +138,12 @@ let | |||
buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags); | |||
|
|||
defaultConfigureFlags = [ | |||
"--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" | |||
"--verbose" "--prefix=$out" "--libdir=\\$prefix/\\$compiler" "--libsubdir=\\$pkgid" |
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.
This seems weird. Is this a windows things?
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.
This and the following is @angerman's change to avoid making cc-wrapper and ld-wrapper inject flags. But please don't do this as part of this PR; even if we end up going this route it should be done separately.
@@ -46,8 +48,7 @@ let | |||
include mk/flavours/\$(BuildFlavour).mk | |||
endif | |||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} | |||
'' + stdenv.lib.optionalString enableIntegerSimple '' | |||
INTEGER_LIBRARY = integer-simple | |||
INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} |
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.
This is definitely a good change! This really confused me with cross-built always pulling in GMP but not ever using it (on android at least).
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.
(might be worth backporting too)
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.
Yes agreed heartily with both. Great change and please back-port!
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.
This PR seems to remove the lib
directory hierarchy from the generated output, but I don't understand why it does.
(optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") | ||
(optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}") | ||
"--with-gcc=$CC" # Clang won't work without that extra information. | ||
"--package-db=$packageConfDir" | ||
(optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}") | ||
(optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/${ghc.name}/${pname}-${version}") |
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 purpose of this change?
if [ -d "$p/lib/${ghcName}/package.conf.d" ]; then | ||
cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf ${packageConfDir}/ | ||
if [ -d "$p/${ghcName}/package.conf.d" ]; then | ||
cp -f "$p/${ghcName}/package.conf.d/"*.conf ${packageConfDir}/ |
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.
Dito. Why are you changing this?
+ (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables)) '' | ||
# Work around a limit in the macOS Sierra linker on the number of paths | ||
# referenced by any one dynamic library: | ||
# | ||
# Create a local directory with symlinks of the *.dylib (macOS shared | ||
# libraries) from all the dependencies. | ||
local dynamicLinksDir="$out/lib/links" | ||
local dynamicLinksDir="$out/lib-links" |
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.
Ẁhy?
@matthewbauer, @peti: yes it dropps the For Haskell libraries however that makes little sense. First of all there aren’t even any libraries on that directory to beging with. They are in a Please also refer to the previous discussion here between @domenkozar and me. |
TLDR; |
Ok seems reasonable if this fixes the ARG_MAX issue (I wonder if you have tested it with something like stack on macOS). We should definitely be careful because a lot stuff probably depends on things like the package conf dir being |
@@ -40,7 +40,7 @@ let | |||
libc_lib = if libc == null then null else getLib libc; | |||
cc_solib = getLib cc; | |||
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils. | |||
coreutils_bin = if nativeTools then "" else getBin coreutils; | |||
coreutils_bin = if (nativeTools || targetPlatform.isWindows) then "" else getBin coreutils; |
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.
This coreutils
for the build platform, not host platform, so why disable it?
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.
This ends up trying to build coreutils
for mingw32
when cross compiling gcc
.
And coreutils
can't be built on mingw32
.
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" | ||
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ | ||
] else [ | ||
"--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" |
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.
This can just be
stdenv.lib.optional (!enableIntegerSimple) [
"--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
]
targetPackages
= pkgs
on native.
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.
IMHO, this goes into the wrong direction. The right solution is not to list Haskell packages in buildInputs
at all. They don't belong there because the generic builder has no clue how to use them anyway. Similarly, one could argue that C libraries required by the Haskell build mustn't be included in buildInputs
either because it's imperative that Cabal finds them through explicitly configured search paths -- not through some magic $NIX_XYZ
variables that don't exist outside of the Nix builder.
Arguably, buildInputs
should be empty except for build-tools
that can be discovered through $PATH
.
@peti this PR fixes several macos haskell packages in pragmatic way, without sacrificing much. It does not touch buildInputs, just renames paths. While I agree there should be a discussion about how different haskell dependencies are handled and propagated, I'd prefer we either merge these or revert cross compilation fixes that got us here, to be able to build macos again. |
I'm in the process of breaking this up into a few smaller PRs. @peti, I agree that haskell lirbaries should not be in @domenkozar the primary motivation for this change was to make cross compiling to windows work. That it resolves the issue on macOS is just a side effect :-) @matthewbauer I would really hope that not much depends on |
the problem is that Cabal must record the |
If we are going to pass |
we have to, really, because otherwise the generated packages won't work when used outside of the Nix builder.
I would prefer to revert the changes that broke Darwin support. We can move those patches into a topic branch and have it compiled by Hydra, IMHO, so that @angerman and @Ericson2314 and others can continue their work there and get it in shape for merging it into |
I came here to report that the removal of I'm happy to have a workaround now, so thanks @angerman, this came just in time. I agree with what @peti says. In the long run, we should make sure that all native libs are provided using |
Motivation for this change
Allow cross compiling haskell programs to windows using mingw
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)