Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Fix Windows build without --enable-distro-toolchain #564

Closed
snowleopard opened this issue Apr 10, 2018 · 52 comments
Closed

Fix Windows build without --enable-distro-toolchain #564

snowleopard opened this issue Apr 10, 2018 · 52 comments

Comments

@snowleopard
Copy link
Owner

snowleopard commented Apr 10, 2018

UPDATE: I fixed the issue below by passing --enable-distro-toolchain to configure: #565. We need to make it possible to build Hadrian without --enable-distro-toolchain, but this has lower priority.


Now hitting this error on Windows:

/---------------------------------------------------------------------------------\
| Successfully built program 'ghc-pkg' (Stage0).                                  |
| Executable: _build/stage0/bin/ghc-pkg.exe                                       |
| Program synopsis: A utility for querying and managing the GHC package database. |
\---------------------------------------------------------------------------------/
ghc.exe: could not execute: C:\msys\home\nam83\ghc\_build\stage0\lib/../mingw/bin/gcc.exe
ghc.exe: could not execute: C:\msys\home\nam83\ghc\_build\stage0\lib/../mingw/bin/gcc.exe
shakeArgsWith     0.001s    0%
Function shake   13.529s    0%
Database read     0.000s    0%
With database     0.000s    0%
Running rules  1780.870s   99%  =========================
Total          1794.401s  100%
Error when running Shake build system:
* _build/stage1/lib/package.conf.d/rts-1.0.conf
* OracleQ (PackageDataFile (Context {stage = Stage1, package = Package {pkgLanguage = C, pkgType = Library, pkgName = "rts", pkgPath = "rts"}, way = v}))
* _build/stage1/rts/setup-config
ExitFailure 1
@snowleopard
Copy link
Owner Author

The error is thrown from here:

https://github.com/snowleopard/hadrian/blob/master/src/Hadrian/Haskell/Cabal/Parse.hs#L158

@alpmestan @angerman Any ideas how to fix this? Somehow, the path to gcc is wrong on Windows and is equal to C:\msys\home\nam83\ghc\_build\stage0\lib/../mingw/bin/gcc.exe on my machine.

Here is the list of arguments passed to defaultMainWithHooksNoReadArgs:

argList = ["configure",
"--cabal-file", "rts/rts.cabal",
"--distdir", "C:/msys/home/nam83/ghc/_build/stage1/rts",
"--ipid", "$pkg-$version",
"--prefix", "${pkgroot}/..",
"--with-ghc=C:/msys/home/nam83/ghc/_build/stage0/bin/ghc.exe",
"--with-ghc-pkg=C:/msys/home/nam83/ghc/_build/stage0/bin/ghc-pkg.exe",
"--ghc-pkg-option=--global-package-db=C:/msys/home/nam83/ghc/_build/stage1/lib/package.conf.d",
"--enable-library-vanilla",
"--enable-library-for-ghci",
"--disable-library-profiling",
"--disable-shared",
"--configure-option=CFLAGS=-fno-stack-protector -IC:/msys/home/nam83/ghc/_build/generated -IC:/msys/home/nam83/ghc/rts -IC:/msys/home/nam83/ghc/includes",
"--configure-option=CPPFLAGS=-I_build/generated",
"--gcc-options=-fno-stack-protector -IC:/msys/home/nam83/ghc/_build/generated -IC:/msys/home/nam83/ghc/rts -IC:/msys/home/nam83/ghc/includes",
"--configure-option=--with-cc=C:/msys/home/nam83/ghc/inplace/mingw/bin/gcc.exe",
"--ghc-option=-ghcversion-file=C:/msys/home/nam83/ghc/_build/generated/ghcversion.h",
"--with-gcc=C:/msys/home/nam83/ghc/inplace/mingw/bin/gcc.exe",
"--with-ld=C:/msys/home/nam83/ghc/inplace/mingw/bin/ld.exe",
"--with-ar=C:/msys/home/nam83/ghc/inplace/mingw/bin/ar.exe",
"--with-alex=C:/Users/nam83/AppData/Roaming/stack/snapshots/180ba486/bin/alex.exe",
"--with-happy=C:/msys/usr/local/bin/happy.exe",
"-v0",
"--configure-option=--quiet",
"--configure-option=--disable-option-checking"]

@alpmestan
Copy link
Collaborator

alpmestan commented Apr 11, 2018

@snowleopard Hmmm... I'm really confused. Given those 2 options from argList:

[...]
"--configure-option=--with-cc=C:/msys/home/nam83/ghc/inplace/mingw/bin/gcc.exe",
[...]
"--with-gcc=C:/msys/home/nam83/ghc/inplace/mingw/bin/gcc.exe",
[...]

which seem just fine... why/how do we end up with C:\msys\home\nam83\ghc\_build\stage0\lib/../mingw/bin/gcc.exe ?

Can you confirm that the path to gcc that we end up mentionning twice in argList is at least correct?

@snowleopard
Copy link
Owner Author

snowleopard commented Apr 11, 2018

@alpmestan Yes, the path in argList is correct. I have no idea where the incorrect one comes from :(

Could this be responsible: "--prefix", "${pkgroot}/.."? It has got a .. in it...

@alpmestan
Copy link
Collaborator

alpmestan commented Apr 11, 2018

Hmm, maybe? Sounds a bit odd though, why would the install path (--prefix) get mixed with the path to the C compiler, with the latter being truncated to its last 3 path components? I'm quite puzzled. Do we get any more useful information if you add "-v3" somewhere in the call to Cabal ?

@snowleopard
Copy link
Owner Author

snowleopard commented Apr 11, 2018

@alpmestan Thanks for the suggestion to try -v3! I think this helps to understand the problem. Here are two final lines of the verbose output:

"D:/msys/home/nam83/ghc/_build/stage0/bin/ghc.exe" "-hide-all-packages" "-c" "C:\Users\nam83\AppData\Local\Temp\7172-0.c" "-o" "C:\Users\nam83\AppData\Local\Temp\7172-1.o" "-ghcversion-file=D:/msys/home/nam83/ghc/_build/generated/ghcversion.h"
ghc.exe: could not execute: D:\msys\home\nam83\ghc\_build\stage0\lib/../mingw/bin/gcc.exe

As you can see we are calling Stage1 GHC that we built, and I think it's got an incorrect built-it path to GCC. So, the real issue is that Stage1 GHC is broken -- it cannot compile C files.

Any ideas how to fix this?

@snowleopard
Copy link
Owner Author

Just confirmed:

D:\msys\home\nam83\ghc\_build\stage0\bin>ghc.exe -c 1.c
ghc.exe: could not execute: D:\msys\home\nam83\ghc\_build\stage0\lib/../mingw/bin/gcc.exe

@alpmestan
Copy link
Collaborator

@snowleopard Could you share the contents of your hadrian/cfg/system.cfg (to see what ./configure filled the template with) ?

@alpmestan
Copy link
Collaborator

And maybe the output of _build\stage0\bin\ghc --info while you're at it?

@snowleopard
Copy link
Owner Author

@alpmestan Sure!

Configuration:

# This file is processed by the configure script.
# See hadrian/src/UserSettings.hs for user-defined settings.
#===========================================================

# Paths to builders:
#===================

alex           = /c/Users/nam83/AppData/Roaming/stack/snapshots/180ba486/bin/alex
ar             = D:/msys/home/nam83/ghc/inplace/mingw/bin/ar.exe
autoreconf     = autoreconf
cc             = D:/msys/home/nam83/ghc/inplace/mingw/bin/gcc.exe
happy          = /c/Users/nam83/AppData/Roaming/local/bin/happy
hs-cpp         = D:/msys/home/nam83/ghc/inplace/mingw/bin/gcc.exe
ld             = D:/msys/home/nam83/ghc/inplace/mingw/bin/ld.exe
make           = make
nm             = D:/msys/home/nam83/ghc/inplace/mingw/bin/nm.exe
objdump        = D:/msys/home/nam83/ghc/inplace/mingw/bin/objdump.exe
ranlib         = D:/msys/home/nam83/ghc/inplace/mingw/bin/ranlib.exe
sphinx-build   = 
system-ar      = C:/Users/nam83/AppData/Local/Programs/stack/x86_64-windows/ghc-8.2.2/lib/../mingw/bin/ar.exe
system-cc      = C:/Users/nam83/AppData/Local/Programs/stack/x86_64-windows/ghc-8.2.2/lib/../mingw/bin/gcc.exe
system-ghc     = c:/Users/nam83/AppData/Local/Programs/stack/x86_64-windows/ghc-8.2.2/bin/ghc
system-ghc-pkg = c:/Users/nam83/AppData/Local/Programs/stack/x86_64-windows/ghc-8.2.2/bin/ghc-pkg
tar            = /usr/bin/tar
patch          = /usr/bin/patch
perl           = D:/msys/home/nam83/ghc/inplace/perl/perl
ln-s           = cp -pR
xelatex        = /d/TeX/MiKTeX/texmf/miktex/bin/xelatex

# Python 3 is required to run test driver.
# See: https://github.com/ghc/ghc/blob/master/testsuite/mk/boilerplate.mk#L220
python         = python3

# Information about builders:
#============================

ar-supports-at-file = YES
cc-clang-backend    = 0
cc-llvm-backend     = 0
gcc-is-clang        = 
hs-cpp-args         = -E -undef -traditional

# Build options:
#===============

solaris-broken-shld  = NO
split-objects-broken = NO
ghc-unregisterised   = NO
ghc-source-path      = D:/msys/home/nam83/ghc
leading-underscore   = NO

# Information about build, host and target systems:
#==================================================

build-platform        = x86_64-unknown-mingw32
build-arch            = x86_64
build-os              = mingw32
build-vendor          = unknown

host-platform         = x86_64-unknown-mingw32
host-arch             = x86_64
host-os               = mingw32
host-vendor           = unknown

target-platform       = x86_64-unknown-mingw32
target-platform-full  = x86_64-unknown-mingw32
target-arch           = x86_64
target-os             = mingw32
target-vendor         = unknown
llvm-target           = x86_64-unknown-windows

cross-compiling       = NO

dynamic-extension     = .dll

ghc-version           = 8.2.2
ghc-major-version     = 8
ghc-minor-version     = 2
ghc-patch-level       = 2

supports-this-unit-id = @SUPPORTS_THIS_UNIT_ID@

project-name          = The Glorious Glasgow Haskell Compilation System
project-version       = 8.5.20180410
project-version-int   = 805
project-patch-level   = 20180410
project-patch-level1  = 20180410
project-patch-level2  = 
project-git-commit-id = b2eb9addcc42f6b9149015436150cd01297346b5

# Compilation and linking flags:
#===============================

conf-cc-args-stage0         =  -fno-stack-protector
conf-cc-args-stage1         =  -fno-stack-protector
conf-cc-args-stage2         =  -fno-stack-protector

conf-cpp-args-stage0        = 
conf-cpp-args-stage1        = 
conf-cpp-args-stage2        = 

conf-gcc-linker-args-stage0 = 
conf-gcc-linker-args-stage1 =  
conf-gcc-linker-args-stage2 =  

conf-ld-linker-args-stage0  = 
conf-ld-linker-args-stage1  = 
conf-ld-linker-args-stage2  = 

# Include and library directories:
#=================================

curses-lib-dir    = 

iconv-include-dir = 
iconv-lib-dir     = 

gmp-include-dir   = 
gmp-lib-dir       = 

use-system-ffi    = NO
ffi-include-dir   = 
ffi-lib-dir       = 

# Optional Dependencies:
#=======================

with-libdw = NO
have-lib-mingw-ex = YES

# Installation:
#=======================

install-prefix          = /usr/local
install-bindir          = /usr/local/bin
install-libdir          = /usr/local/lib
install-datarootdir     = /usr/local/share

install         = /usr/bin/install -c
install-program = /usr/bin/install -c -m 755
install-script  = /usr/bin/install -c -m 755
install-data    = /usr/bin/install -c -m 644
install-dir     = /usr/bin/install -c -m 755 -d

GHC info:

 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv -fno-builtin")
 ,("C compiler command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/gcc.exe")
 ,("C compiler flags"," -fno-stack-protector")
 ,("C compiler link flags"," ")
 ,("C compiler supports -no-pie","YES")
 ,("Haskell CPP command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/gcc.exe")
 ,("Haskell CPP flags","-E -undef -traditional")
 ,("ld command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/ld.exe")
 ,("ld flags","")
 ,("ld supports compact unwind","YES")
 ,("ld supports build-id","YES")
 ,("ld supports filelist","NO")
 ,("ld is GNU ld","YES")
 ,("ar command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/ar.exe")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("ranlib command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/ranlib.exe")
 ,("touch command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/bin/touchy.exe")
 ,("dllwrap command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/dllwrap.exe")
 ,("windres command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/windres.exe")
 ,("libtool command","libtool")
 ,("perl command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../perl/perl.exe")
 ,("cross compiling","NO")
 ,("target os","OSMinGW32")
 ,("target arch","ArchX86_64")
 ,("target word size","8")
 ,("target has GNU nonexec stack","False")
 ,("target has .ident directive","True")
 ,("target has subsections via symbols","False")
 ,("target has RTS linker","YES")
 ,("Unregisterised","NO")
 ,("LLVM llc command","llc")
 ,("LLVM opt command","opt")
 ,("LLVM clang command","clang")
 ,("Project version","8.5.20180410")
 ,("Project Git commit id","b2eb9addcc42f6b9149015436150cd01297346b5")
 ,("Booter version","8.2.2")
 ,("Stage","1")
 ,("Build platform","x86_64-unknown-mingw32")
 ,("Host platform","x86_64-unknown-mingw32")
 ,("Target platform","x86_64-unknown-mingw32")
 ,("Have interpreter","YES")
 ,("Object splitting supported","YES")
 ,("Have native code generator","YES")
 ,("Support SMP","YES")
 ,("Tables next to code","YES")
 ,("RTS ways","v l debug thr thr_debug thr_l")
 ,("RTS expects libdw","NO")
 ,("Support dynamic-too","NO")
 ,("Support parallel --make","YES")
 ,("Support reexported-modules","YES")
 ,("Support thinning and renaming package flags","YES")
 ,("Support Backpack","YES")
 ,("Requires unified installed package IDs","YES")
 ,("Uses package keys","YES")
 ,("Uses unit IDs","YES")
 ,("Dynamic by default","NO")
 ,("GHC Dynamic","NO")
 ,("GHC Profiled","NO")
 ,("Leading underscore","NO")
 ,("Debug on","False")
 ,("LibDir","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib")
 ,("Global Package DB","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib\\package.conf.d")
 ]

As you can see, we have lots of incorrect paths there, including the cause of this issue:

 ,("C compiler command","D:\\msys\\home\\nam83\\ghc\\_build\\stage0\\lib/../mingw/bin/gcc.exe")

@snowleopard
Copy link
Owner Author

snowleopard commented Apr 11, 2018

The configuration path to GCC on the other hand is correct:

C:/Users/nam83/AppData/Local/Programs/stack/x86_64-windows/ghc-8.2.2/lib/../mingw/bin/gcc.exe

@snowleopard
Copy link
Owner Author

snowleopard commented Apr 11, 2018

The top-level settings file contains this line: ("C compiler command", "$topdir/../mingw/bin/gcc.exe").

@snowleopard
Copy link
Owner Author

I think I figured out the problem: when GHC was built in the inplace directory, it used the bundled gcc from inplace/mingw/bin. Now that we moved GHC binaries to _build/stageN/bin it can no longer locate the bundled gcc using the "$topdir/../mingw/bin/gcc.exe" recipe.

@alpmestan
Copy link
Collaborator

alpmestan commented Apr 11, 2018

Hmm... That sounds like a very plausible explanation. In settings.in I can see:

 ("C compiler command", "@SettingsCCompilerCommand@"),

so... should we augment the logic that produces that value, to cover the case where we don't build inplace? I'm not sure what the additional logic should do though. The current one is implemented in aclocal.m4:

# FP_SETTINGS
# ----------------------------------
# Set the variables used in the settings file
AC_DEFUN([FP_SETTINGS],
[
    if test "$windows" = YES -a "$EnableDistroToolchain" = "NO"
    then
        mingw_bin_prefix=mingw/bin/
        SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
        SettingsHaskellCPPCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
        SettingsHaskellCPPFlags="$HaskellCPPArgs"
        SettingsLdCommand="\$topdir/../${mingw_bin_prefix}ld.exe"
        SettingsArCommand="\$topdir/../${mingw_bin_prefix}ar.exe"
        SettingsRanlibCommand="\$topdir/../${mingw_bin_prefix}ranlib.exe"
        SettingsPerlCommand='$topdir/../perl/perl.exe'
        SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe"
        SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
        SettingsTouchCommand='$topdir/bin/touchy.exe'
    elif test "$EnableDistroToolchain" = "YES"
    [...]

I'm not entirely sure how we can say "use the C toolchain at <root of ghc source tree>/inplace/mingw/bin/" (the "root of ghc source tree" part in particular). This is anyway going to be problematic when using GHC produced this way outside of the source tree. So I suppose the nicer fix is to actually copy gcc (and perphaps the whole mingw dir that lives under inplace) wherever it is that GHC is expecting them, under <build root>/stage<N>/mingw?

@alpmestan
Copy link
Collaborator

Oh, I see you're trying to use the "enable the distro toolchain" knob, that should be even simpler =)

@snowleopard
Copy link
Owner Author

@alpmestan Yep, let's see if it works :) Currently building on my machine too.

@snowleopard
Copy link
Owner Author

Ha, it worked! We now hit the _build/stage1/lib/package.conf.d/rts-1.0.conf issue on AppVeyor :)

@snowleopard
Copy link
Owner Author

snowleopard commented Apr 11, 2018

@Mistuke Thanks for implementing --enable-distro-toolchain in https://phabricator.haskell.org/D3637!

@snowleopard snowleopard changed the title Windows failure: ghc.exe: could not execute: gcc.exe Fix Windows build without --enable-distro-toolchain Apr 11, 2018
@Mistuke
Copy link
Contributor

Mistuke commented Apr 11, 2018

@snowleopard you're correct in that the issue is happening because of the layout change. SysTools has a hard assumption about the layout of GHC's binaries.

In particular it assumes:

-- Assuming we are running ghc, accessed by path  $(stuff)/<foo>/ghc.exe,
-- return the path $(stuff)/lib.

But now the layout is different, not just for the build but in the resulting tarball if you were to package up ghc. Have you thought about what the layout should be in the final binary distribution. Once you know that SysTools can be patched to support Hadrian's layout.

Also be careful with copying or changing mingw's layout. that gcc.exe is actually a stub that we build, and it has some assumptions about where the real gcc and it's libraries are. See https://github.com/ghc/ghc/blob/master/driver/gcc/gcc.c

@snowleopard
Copy link
Owner Author

Have you thought about what the layout should be in the final binary distribution

@Mistuke No, I haven't thought of this and I don't think I have enough knowledge to make the right call. Could you please advise?

Naively I'd suggest something along the lines @alpmestan mentioned: simply copy mingw from inplace into the build directory, but your comment suggests that this may be not the best solution. What are the alternatives?

@Mistuke
Copy link
Contributor

Mistuke commented Apr 11, 2018 via email

@snowleopard
Copy link
Owner Author

Great, thanks @Mistuke!

alpmestan added a commit to alpmestan/ghc that referenced this issue Apr 13, 2018
This patch affects several files that affect how we detect mingw and perl
on Windows. The initial motivation is:

    snowleopard/hadrian#564

where, with Hadrian building relocatable (non-inplace) GHCs, the current
detection mechanism falls short by e.g only trying $topdir/../mingw. But
in Hadrian, for reasons given in that issue, we would need to store e.g mingw
under $topdir/../../mingw except for binary distributions, where we want
to follow the existing structure, in which case $topdir/../mingw is correct. So
we need to support both, which is what this patch hopefully implements.
@alpmestan
Copy link
Collaborator

@Mistuke @snowleopard How does this look: alpmestan/ghc@f429ee8 ? Andrey, could you perhaps try out this patch? I intend to give it a spin in a Windows VM as soon as I can but I have to run away from my laptop now.

@alpmestan
Copy link
Collaborator

To be clear, this would require hadrian to place mingw/perl under <build root>/{mingw, perl}, except in the bindists I suppose.

@Mistuke
Copy link
Contributor

Mistuke commented Apr 13, 2018 via email

alpmestan added a commit to alpmestan/ghc that referenced this issue Apr 14, 2018
This patch affects several files that affect how we detect mingw and perl
on Windows. The initial motivation is:

    snowleopard/hadrian#564

where, with Hadrian building relocatable (non-inplace) GHCs, the current
detection mechanism falls short by e.g only trying $topdir/../mingw. But
in Hadrian, for reasons given in that issue, we would need to store e.g mingw
under $topdir/../../mingw except for binary distributions, where we want
to follow the existing structure, in which case $topdir/../mingw is correct. So
we need to support both, which is what this patch hopefully implements.
@alpmestan
Copy link
Collaborator

@Mistuke Wow... sorry for the silly mistakes. I also refactored findToolDir as suggested. I got around to spinning up a build with this patch in a Windows VM. I then tried compiling a C file with inplace/bin/ghc-stage1.exe, it works. The affected commands in the settings file do use the new $tooldir variable, etc. So at least it looks like I did not break the inplace workflow. The patch: alpmestan/ghc@d1b3323

@snowleopard Could you perhaps try it out whenever you get a chance to?

@snowleopard
Copy link
Owner Author

@alpmestan Thank you, this looks good to me!

Shall we also do anything about the last occurrence of $topdir in $topdir/bin/touchy.exe? See #570.

@alpmestan
Copy link
Collaborator

alpmestan commented Apr 16, 2018

Oh, I didn't change this one but please do let me know if you'd like me to change how the path to touchy is determined in the same patch. Judging from the comments in #570 though, it's not obvious to me whether the problem is in hadrian or in aclocal.m4/settings.in. Could you share your thoughts on how you think we should fix touchy and whether it should go in my patch mentionned above, in case we need a change on the GHC side?

alpmestan added a commit to alpmestan/ghc that referenced this issue Apr 16, 2018
This patch affects several files that affect how we detect mingw and perl
on Windows. The initial motivation is:

    snowleopard/hadrian#564

where, with Hadrian building relocatable (non-inplace) GHCs, the current
detection mechanism falls short by e.g only trying $topdir/../mingw. But
in Hadrian, for reasons given in that issue, we would need to store e.g mingw
under $topdir/../../mingw except for binary distributions, where we want
to follow the existing structure, in which case $topdir/../mingw is correct. So
we need to support both, which is what this patch hopefully implements.
alpmestan added a commit to alpmestan/ghc that referenced this issue Apr 16, 2018
Summary:
This patch affects several files that affect how we detect mingw and perl
on Windows. The initial motivation is:

    snowleopard/hadrian#564

where, with Hadrian building relocatable (non-inplace) GHCs, the current
detection mechanism falls short by e.g only trying $topdir/../mingw. But
in Hadrian, for reasons given in that issue, we would need to store e.g mingw
under $topdir/../../mingw except for binary distributions, where we want
to follow the existing structure, in which case $topdir/../mingw is correct. So
we need to support both, which is what this patch hopefully implements.

Test Plan: ./validate

Reviewers: Phyx

Subscribers:

GHC Trac Issues:
alpmestan added a commit to alpmestan/ghc that referenced this issue Apr 16, 2018
Summary:
This patch affects several files that affect how we detect mingw and perl
on Windows. The initial motivation is:

    snowleopard/hadrian#564

where, with Hadrian building relocatable (non-inplace) GHCs, the current
detection mechanism falls short by e.g only trying $topdir/../mingw. But
in Hadrian, for reasons given in that issue, we would need to store e.g mingw
under $topdir/../../mingw except for binary distributions, where we want
to follow the existing structure, in which case $topdir/../mingw is correct. So
we need to support both, which is what this patch hopefully implements.

Test Plan: ./validate

Reviewers: Phyx, hvr, bgamari, erikd

Subscribers: thomie, carter

Differential Revision: https://phabricator.haskell.org/D4598
@alpmestan
Copy link
Collaborator

Got a diff up on phabricator at https://phabricator.haskell.org/D4598 -- feedback/review welcome (if/once the build passes).

@snowleopard
Copy link
Owner Author

Thanks @alpmestan! Hope it will soon be accepted.

I think relocating touchy belongs to a separate patch, because it feels like an unrelated problem.

@alpmestan
Copy link
Collaborator

alpmestan commented Apr 16, 2018

Sounds good to me. GHC HEAD is however broken at the moment so CI errors out on something completely unrelated. And the diff won't be reviewable/mergeable until CI passes IIRC (due to a recent phabricator update).

@Mistuke
Copy link
Contributor

Mistuke commented Apr 16, 2018 via email

@alpmestan
Copy link
Collaborator

However I'd like to see CI build before I accept it.

Yeah, me too! =)

alpmestan added a commit to alpmestan/ghc that referenced this issue Apr 17, 2018
Summary:
This patch affects several files that affect how we detect mingw and perl
on Windows. The initial motivation is:

    snowleopard/hadrian#564

where, with Hadrian building relocatable (non-inplace) GHCs, the current
detection mechanism falls short by e.g only trying $topdir/../mingw. But
in Hadrian, for reasons given in that issue, we would need to store e.g mingw
under $topdir/../../mingw except for binary distributions, where we want
to follow the existing structure, in which case $topdir/../mingw is correct. So
we need to support both, which is what this patch hopefully implements.

Test Plan: ./validate

Reviewers: Phyx, hvr, bgamari, erikd

Subscribers: thomie, carter

Differential Revision: https://phabricator.haskell.org/D4598
@alpmestan
Copy link
Collaborator

@snowleopard My patch passed GHC's CI and @Mistuke accepted it, so it'll land soon. As soon as it's in master, we should be able to get rid of the distro toolchain flag to configure.

@Mistuke Thanks for being so responsive!

@snowleopard
Copy link
Owner Author

@alpmestan @Mistuke Awesome, thank you both!

This was referenced Apr 17, 2018
bgamari pushed a commit to ghc/ghc that referenced this issue Apr 17, 2018
Summary:
This patch affects several files that affect how we detect mingw and perl
on Windows. The initial motivation is:

    snowleopard/hadrian#564

where, with Hadrian building relocatable (non-inplace) GHCs, the current
detection mechanism falls short by e.g only trying $topdir/../mingw. But
in Hadrian, for reasons given in that issue, we would need to store e.g mingw
under $topdir/../../mingw except for binary distributions, where we want
to follow the existing structure, in which case $topdir/../mingw is correct. So
we need to support both, which is what this patch hopefully implements.

Test Plan: ./validate

Reviewers: Phyx, hvr, bgamari, erikd

Reviewed By: Phyx

Subscribers: snowleopard, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4598
@Mistuke
Copy link
Contributor

Mistuke commented Apr 17, 2018

No problem :) I pushed the commit as well.

@alpmestan
Copy link
Collaborator

@snowleopard Do you want to try getting rid of --enable-distro-toolchain?

@snowleopard
Copy link
Owner Author

@alpmestan I'm working on this -- now testing on my machine.

@snowleopard
Copy link
Owner Author

The above commit works on my machine -- will close this if AppVeyor succeeds too.

@snowleopard
Copy link
Owner Author

🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants