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

Feature/mingw fixes #43559

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

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?

Copy link
Contributor Author

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.


default_cxx_stdlib_compile = optionalString (targetPlatform.isLinux && !(cc.isGNU or false) && !nativeTools && cc ? gcc)
"-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/$(${cc.gcc}/bin/gcc -dumpmachine)";
Expand Down
11 changes: 7 additions & 4 deletions pkgs/development/compilers/ghc/8.4.3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
}:

assert !enableIntegerSimple -> gmp != null;

let
inherit (bootPkgs) ghc;

Expand All @@ -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"}
Copy link
Member

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).

Copy link
Member

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)

Copy link
Member

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!

'' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
CrossCompilePrefix = ${targetPrefix}
Expand Down Expand Up @@ -133,9 +134,11 @@ stdenv.mkDerivation (rec {
configureFlags = [
"--datadir=$doc/share/doc/ghc"
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [
] ++ (if (targetPlatform == hostPlatform && !enableIntegerSimple) then [
"--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"
Copy link
Member

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.

]) ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
"--enable-bootstrap-with-devel-snapshot"
Expand Down
18 changes: 9 additions & 9 deletions pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let
main = defaultMain
'';

hasActiveLibrary = isLibrary && (enableStaticLibraries || enableSharedLibraries || enableLibraryProfiling);
hasActiveLibrary = isLibrary && (enableStaticLibraries || enableSharedLibraries || enableLibraryProfiling || hostPlatform.isWindows);

# We cannot enable -j<n> parallelism for libraries because GHC is far more
# likely to generate a non-determistic library ID in that case. Further
Expand All @@ -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"
Copy link
Member

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?

Copy link
Member

@Ericson2314 Ericson2314 Jul 16, 2018

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.

(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}")
Copy link
Member

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?

(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")
Expand Down Expand Up @@ -209,8 +209,8 @@ let
nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";

buildPkgDb = ghcName: packageConfDir: ''
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}/
Copy link
Member

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?

continue
fi
'';
Expand Down Expand Up @@ -294,14 +294,14 @@ stdenv.mkDerivation ({
''
# only use the links hack if we're actually building dylibs. otherwise, the
# "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes
# "ln -s $out/lib/links", which tries to recreate the links dir and fails
# "ln -s $out/lib-links", which tries to recreate the links dir and fails
+ (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"
Copy link
Member

Choose a reason for hiding this comment

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

Ẁhy?

mkdir -p $dynamicLinksDir
for d in $(grep dynamic-library-dirs "$packageConfDir/"*|awk '{print $2}'|sort -u); do
ln -s "$d/"*.dylib $dynamicLinksDir
Expand Down Expand Up @@ -379,7 +379,7 @@ stdenv.mkDerivation ({

${if !hasActiveLibrary then "${setupCommand} install" else ''
${setupCommand} copy
local packageConfDir="$out/lib/${ghc.name}/package.conf.d"
local packageConfDir="$out/${ghc.name}/package.conf.d"
local packageConfFile="$packageConfDir/${pname}-${version}.conf"
mkdir -p "$packageConfDir"
${setupCommand} register --gen-pkg-config=$packageConfFile
Expand All @@ -404,7 +404,7 @@ stdenv.mkDerivation ({
${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"}
${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && stdenv.lib.versionOlder ghc.version "7.10") ''
for exe in "$out/bin/"* ; do
install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe"
install_name_tool -add_rpath "$out/ghc-${ghc.version}/${pname}-${version}" "$exe"
done
''}

Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/haskell-modules/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ rec {
enableSharedExecutables = false;
isLibrary = false;
doHaddock = false;
postFixup = "rm -rf $out/lib $out/nix-support $out/share/doc";
postFixup = "rm -rf $out/ghc* $out/nix-support $out/share/doc";
});

/* Build a source distribution tarball instead of using the source files
Expand Down
1 change: 1 addition & 0 deletions pkgs/tools/misc/coreutils/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

assert aclSupport -> acl != null;
assert selinuxSupport -> libselinux != null && libsepol != null;
assert hostPlatform.libc != "msvcrt";

with lib;

Expand Down