Update GHC to 8.0.2, pull in upstream Arch scripts (#2204)

* Update GHC to 8.0.2, pull in upstream Arch scripts

* Remove GHC sed patch, configure in the build step
This commit is contained in:
Alethea Rose
2017-02-27 03:35:16 -05:00
committed by Алексей
parent c54ba918ff
commit f867cfd074
21 changed files with 477 additions and 2451 deletions

View File

@@ -1,50 +0,0 @@
From 0d963caf40da4391028a3beb95b5082c87985e7d Mon Sep 17 00:00:00 2001
From: Tamar Christina <tamar@zhox.com>
Date: Sun, 5 Jun 2016 09:59:05 +0200
Subject: [PATCH] Add relocation type R_X86_64_REX_GOTPCRELX
Summary:
Adding support for the `R_X86_64_REX_GOTPCRELX` relocation type.
This relocation is treated by the linker the same as the `R_X86_64_GOTPCRELX` type
`G + GOT + A - P` to generate relative offsets to the GOT.
The `REX` prefix has no influence in this stage.
This is based on https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r252.pdf
Test Plan: ./validate
Reviewers: erikd, austin, bgamari, simonmar
Reviewed By: erikd
Subscribers: thomie, #ghc_windows_task_force
Differential Revision: https://phabricator.haskell.org/D2303
GHC Trac Issues: #12147
---
rts/Linker.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/rts/Linker.c b/rts/Linker.c
index 5a6a8c2..a1f72e5 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -5681,7 +5681,13 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
*(Elf64_Sword *)P = (Elf64_Sword)value;
#endif
break;
-
+/* These two relocations were introduced in glibc 2.23 and binutils 2.26.
+ But in order to use them the system which compiles the bindist for GHC needs
+ to have glibc >= 2.23. So only use them if they're defined. */
+#if defined(R_X86_64_REX_GOTPCRELX) && defined(R_X86_64_GOTPCRELX)
+ case R_X86_64_REX_GOTPCRELX:
+ case R_X86_64_GOTPCRELX:
+#endif
case R_X86_64_GOTPCREL:
{
StgInt64 gotAddress = (StgInt64) &makeSymbolExtra(oc, ELF_R_SYM(info), S)->addr;
--
2.9.1

View File

@@ -1,49 +0,0 @@
From da3c1ebb8a57e81f12c5be192e477f79158a2398 Mon Sep 17 00:00:00 2001
From: Simon Marlow <marlowsd@gmail.com>
Date: Sat, 21 May 2016 18:36:49 +0200
Subject: [PATCH] Enable checkProddableBlock on x86_64
We've been seeing some memory corruption after using the linker, and I
want to enable this to see if it catches anything.
Test Plan:
* validate
* modified the linker_unload test to remove the performGC calls to use
as a benchmark, saw no significant difference after this change.
Reviewers: bgamari, erikd, austin
Reviewed By: austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2245
---
rts/Linker.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rts/Linker.c b/rts/Linker.c
index 61b10d8..e867d04 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -4034,7 +4034,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
if (kind != SECTIONKIND_OTHER && end >= start) {
addSection(&sections[i], kind, SECTION_NOMEM, start, sz, 0, 0, 0);
- addProddableBlock(oc, start, end - start + 1);
+ addProddableBlock(oc, start, sz);
}
stgFree(secname);
@@ -5756,7 +5756,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
IF_DEBUG(linker,debugBelch("Reloc: P = %p S = %p A = %p\n",
(void*)P, (void*)S, (void*)A ));
- /* checkProddableBlock ( oc, (void*)P ); */
+ checkProddableBlock(oc, (void*)P, sizeof(Elf_Word));
#if defined(sparc_HOST_ARCH) || defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH)
value = S + A;
--
2.9.1

View File

@@ -1,75 +0,0 @@
From 18f06878ed5d8cb0cf366a876f2bfea29647e5f0 Mon Sep 17 00:00:00 2001
From: Tamar Christina <tamar@zhox.com>
Date: Sat, 13 Aug 2016 16:27:30 +0100
Subject: [PATCH] Fix configure detection.
Summary:
GHC's configure script seems to normalize the values returned from config.guess.
So for Windows it turns x86_64-pc-mingw64 into x86_64-unknown-mingw32.
These mangled names are stored in the values $BuildPlatform, $HostPlatform
and $TargetPlatform.
However further down the file when the comparison is done between the stage0
compiler and the host the normalized versions are not used.
So when normalization actually changes the triple this check will fail.
Not sure why it's worked for all this time.. Nor if this is the right fix?
Does it still work for cross compiling correctly?
Test Plan: ./configure
Reviewers: hvr, austin, thomie, bgamari, erikd
Reviewed By: erikd
Subscribers: erikd, #ghc_windows_task_force
Differential Revision: https://phabricator.haskell.org/D2452
GHC Trac Issues: #12487
---
configure.ac | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index e9569e9..acd33cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -410,20 +410,20 @@ dnl ** Building a cross compiler?
dnl --------------------------------------------------------------
CrossCompiling=NO
# If 'host' and 'target' differ, then this means we are building a cross-compiler.
-if test "$target" != "$host" ; then
+if test "$TargetPlatform" != "$HostPlatform" ; then
CrossCompiling=YES
cross_compiling=yes # This tells configure that it can accept just 'target',
# otherwise you get
# configure: error: cannot run C compiled programs.
# If you meant to cross compile, use `--host'.
fi
-if test "$build" != "$host" ; then
+if test "$BuildPlatform" != "$host" ; then
AC_MSG_ERROR([
You've selected:
- BUILD: $build (the architecture we're building on)
- HOST: $host (the architecture the compiler we're building will execute on)
- TARGET: $target (the architecture the compiler we're building will produce code for)
+ BUILD: $BuildPlatform (the architecture we're building on)
+ HOST: $HostPlatform (the architecture the compiler we're building will execute on)
+ TARGET: $TargetPlatform (the architecture the compiler we're building will produce code for)
BUILD must equal HOST; that is, we do not support building GHC itself
with a cross-compiler. To cross-compile GHC itself, set TARGET: stage
@@ -437,7 +437,7 @@ then
else
CrossCompilePrefix=""
fi
-TargetPlatformFull="${target}"
+TargetPlatformFull="${TargetPlatform}"
AC_SUBST(CrossCompiling)
AC_SUBST(CrossCompilePrefix)
AC_SUBST(TargetPlatformFull)
--
2.9.1

View File

@@ -1,384 +0,0 @@
From b40e1b4c6746bdc34e6a53548a3925d309201c4d Mon Sep 17 00:00:00 2001
From: Tamar Christina <tamar@zhox.com>
Date: Sat, 11 Jun 2016 10:18:19 +0200
Subject: [PATCH] Fix incorrect calculated relocations on Windows x86_64
Summary:
See #12031 for analysis, but essentially what happens is:
To sum up the issue, the reason this seems to go wrong is because
of how we initialize the `.bss` section for Windows in the runtime linker.
The first issue is where we calculate the zero space for the section:
```
zspace = stgCallocBytes(1, bss_sz, "ocGetNames_PEi386(anonymous bss)");
sectab_i->PointerToRawData = ((UChar*)zspace) - ((UChar*)(oc->image));
```
Where
```
UInt32 PointerToRawData;
```
This means we're stuffing a `64-bit` value into a `32-bit` one. Also `zspace`
can be larger than `oc->image`. In which case it'll overflow and
then get truncated in the cast.
The address of a value in the `.bss` section is then calculated as:
```
addr = ((UChar*)(oc->image))
+ (sectabent->PointerToRawData
+ symtab_i->Value);
```
If it does truncate then this calculation won't be correct (which is what is happening).
We then later use the value of `addr` as the `S` (Symbol) value for the relocations
```
S = (size_t) lookupSymbol_( (char*)symbol );
```
Now the majority of the relocations are `R_X86_64_PC32` etc.
e.g. They are guaranteed to fit in a `32-bit` value.
The `R_X86_64_64` introduced for these pseudo-relocations so they can use
the full `48-bit` addressing space isn't as lucky.
As for why it sometimes work has to do on whether the value is truncated or not.
`PointerToRawData` can't be changed because it's size is fixed by the PE specification.
Instead just like with the other platforms, we now use `section` on Windows as well.
This gives us a `start` parameter of type `void*` which solves the issue.
This refactors the code to use `section.start` and to fix the issues.
Test Plan: ./validate and new test added T12031
Reviewers: RyanGlScott, erikd, bgamari, austin, simonmar
Reviewed By: simonmar
Subscribers: thomie, #ghc_windows_task_force
Differential Revision: https://phabricator.haskell.org/D2316
GHC Trac Issues: #12031, #11317
---
rts/Linker.c | 73 ++++++++++++++++++--------------
rts/LinkerInternals.h | 4 +-
testsuite/tests/rts/T12031/ExternBug.hs | 9 ++++
testsuite/tests/rts/T12031/Makefile | 8 ++++
testsuite/tests/rts/T12031/T12031.stdout | 1 +
testsuite/tests/rts/T12031/all.T | 4 ++
testsuite/tests/rts/T12031/bar.c | 11 +++++
testsuite/tests/rts/T12031/baz.c | 9 ++++
testsuite/tests/rts/T12031/foo.h | 11 +++++
9 files changed, 97 insertions(+), 33 deletions(-)
create mode 100644 testsuite/tests/rts/T12031/ExternBug.hs
create mode 100644 testsuite/tests/rts/T12031/Makefile
create mode 100644 testsuite/tests/rts/T12031/T12031.stdout
create mode 100644 testsuite/tests/rts/T12031/all.T
create mode 100644 testsuite/tests/rts/T12031/bar.c
create mode 100644 testsuite/tests/rts/T12031/baz.c
create mode 100644 testsuite/tests/rts/T12031/foo.h
diff --git a/rts/Linker.c b/rts/Linker.c
index a1f72e5..ef909f0 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -3497,6 +3497,26 @@ ocVerifyImage_PEi386 ( ObjectCode* oc )
}
#endif
+ /* .BSS Section is initialized in ocGetNames_PEi386
+ but we need the Sections array initialized here already. */
+ Section *sections;
+ sections = (Section*)stgCallocBytes(
+ sizeof(Section),
+ hdr->NumberOfSections + 1, /* +1 for the global BSS section see ocGetNames_PEi386 */
+ "ocVerifyImage_PEi386(sections)");
+ oc->sections = sections;
+ oc->n_sections = hdr->NumberOfSections + 1;
+
+ /* Initialize the Sections */
+ for (i = 0; i < hdr->NumberOfSections; i++) {
+ COFF_section* sectab_i
+ = (COFF_section*)
+ myindex(sizeof_COFF_section, sectab, i);
+
+ /* Calculate the start of the data section */
+ sections[i].start = oc->image + sectab_i->PointerToRawData;
+ }
+
/* No further verification after this point; only debug printing. */
i = 0;
IF_DEBUG(linker, i=1);
@@ -3525,6 +3545,7 @@ ocVerifyImage_PEi386 ( ObjectCode* oc )
COFF_section* sectab_i
= (COFF_section*)
myindex ( sizeof_COFF_section, sectab, i );
+ Section section = sections[i];
debugBelch(
"\n"
"section %d\n"
@@ -3537,14 +3558,14 @@ ocVerifyImage_PEi386 ( ObjectCode* oc )
" vsize %d\n"
" vaddr %d\n"
" data sz %d\n"
- " data off %d\n"
+ " data off 0x%p\n"
" num rel %d\n"
" off rel %d\n"
" ptr raw 0x%x\n",
sectab_i->VirtualSize,
sectab_i->VirtualAddress,
sectab_i->SizeOfRawData,
- sectab_i->PointerToRawData,
+ section.start,
sectab_i->NumberOfRelocations,
sectab_i->PointerToRelocations,
sectab_i->PointerToRawData
@@ -3690,25 +3711,16 @@ ocGetNames_PEi386 ( ObjectCode* oc )
* triggered this is libraries/base/cbits/dirUtils.c:__hscore_getFolderPath())
*/
if (sectab_i->VirtualSize == 0 && sectab_i->SizeOfRawData == 0) continue;
- /* This is a non-empty .bss section. Allocate zeroed space for
- it, and set its PointerToRawData field such that oc->image +
- PointerToRawData == addr_of_zeroed_space. */
+ /* This is a non-empty .bss section.
+ Allocate zeroed space for it */
bss_sz = sectab_i->VirtualSize;
if ( bss_sz < sectab_i->SizeOfRawData) { bss_sz = sectab_i->SizeOfRawData; }
zspace = stgCallocBytes(1, bss_sz, "ocGetNames_PEi386(anonymous bss)");
- sectab_i->PointerToRawData = ((UChar*)zspace) - ((UChar*)(oc->image));
+ oc->sections[i].start = zspace;
addProddableBlock(oc, zspace, bss_sz);
/* debugBelch("BSS anon section at 0x%x\n", zspace); */
}
- Section *sections;
- sections = (Section*)stgCallocBytes(
- sizeof(Section),
- hdr->NumberOfSections + 1, /* +1 for the global BSS section see below */
- "ocGetNames_PEi386(sections)");
- oc->sections = sections;
- oc->n_sections = hdr->NumberOfSections + 1;
-
/* Copy section information into the ObjectCode. */
for (i = 0; i < hdr->NumberOfSections; i++) {
@@ -3722,6 +3734,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
COFF_section* sectab_i
= (COFF_section*)
myindex ( sizeof_COFF_section, sectab, i );
+ Section section = oc->sections[i];
char *secname = cstring_from_section_name(sectab_i->Name, strtab);
@@ -3748,11 +3761,11 @@ ocGetNames_PEi386 ( ObjectCode* oc )
sz = sectab_i->SizeOfRawData;
if (sz < sectab_i->VirtualSize) sz = sectab_i->VirtualSize;
- start = ((UChar*)(oc->image)) + sectab_i->PointerToRawData;
+ start = section.start;
end = start + sz - 1;
if (kind != SECTIONKIND_OTHER && end >= start) {
- addSection(&sections[i], kind, SECTION_NOMEM, start, sz, 0, 0, 0);
+ addSection(&oc->sections[i], kind, SECTION_NOMEM, start, sz, 0, 0, 0);
addProddableBlock(oc, start, sz);
}
@@ -3784,13 +3797,13 @@ ocGetNames_PEi386 ( ObjectCode* oc )
if (globalBssSize > 0) {
bss = stgCallocBytes(1, globalBssSize,
"ocGetNames_PEi386(non-anonymous bss)");
- addSection(&sections[oc->n_sections-1],
+ addSection(&oc->sections[oc->n_sections-1],
SECTIONKIND_RWDATA, SECTION_MALLOC,
bss, globalBssSize, 0, 0, 0);
IF_DEBUG(linker, debugBelch("bss @ %p %" FMT_Word "\n", bss, globalBssSize));
addProddableBlock(oc, bss, globalBssSize);
} else {
- addSection(&sections[oc->n_sections-1],
+ addSection(&oc->sections[oc->n_sections-1],
SECTIONKIND_OTHER, SECTION_NOMEM, NULL, 0, 0, 0, 0);
}
@@ -3817,9 +3830,8 @@ ocGetNames_PEi386 ( ObjectCode* oc )
|| ( symtab_i->StorageClass == MYIMAGE_SYM_CLASS_STATIC
&& sectabent->Characteristics & MYIMAGE_SCN_LNK_COMDAT)
) {
- addr = ((UChar*)(oc->image))
- + (sectabent->PointerToRawData
- + symtab_i->Value);
+ addr = (void*)((size_t)oc->sections[symtab_i->SectionNumber-1].start
+ + symtab_i->Value);
if (sectabent->Characteristics & MYIMAGE_SCN_LNK_COMDAT) {
isWeak = HS_BOOL_TRUE;
}
@@ -3969,6 +3981,7 @@ ocResolve_PEi386 ( ObjectCode* oc )
= (COFF_reloc*) (
((UChar*)(oc->image)) + sectab_i->PointerToRelocations
);
+ Section section = oc->sections[i];
char *secname = cstring_from_section_name(sectab_i->Name, strtab);
@@ -4020,11 +4033,10 @@ ocResolve_PEi386 ( ObjectCode* oc )
myindex ( sizeof_COFF_reloc, reltab, j );
/* the location to patch */
- pP = (
- ((UChar*)(oc->image))
- + (sectab_i->PointerToRawData
- + reltab_j->VirtualAddress
- - sectab_i->VirtualAddress )
+ pP = (void*)(
+ (size_t)section.start
+ + reltab_j->VirtualAddress
+ - sectab_i->VirtualAddress
);
/* the existing contents of pP */
A = *(UInt32*)pP;
@@ -4043,10 +4055,8 @@ ocResolve_PEi386 ( ObjectCode* oc )
debugBelch("'\n" ));
if (sym->StorageClass == MYIMAGE_SYM_CLASS_STATIC) {
- COFF_section* section_sym
- = (COFF_section*) myindex ( sizeof_COFF_section, sectab, sym->SectionNumber-1 );
- S = ((size_t)(oc->image))
- + ((size_t)(section_sym->PointerToRawData))
+ Section section = oc->sections[sym->SectionNumber-1];
+ S = ((size_t)(section.start))
+ ((size_t)(sym->Value));
} else {
copyName ( sym->Name, strtab, symbol, 1000-1 );
@@ -4201,9 +4211,10 @@ ocRunInit_PEi386 ( ObjectCode *oc )
COFF_section* sectab_i
= (COFF_section*)
myindex ( sizeof_COFF_section, sectab, i );
+ Section section = oc->sections[i];
char *secname = cstring_from_section_name(sectab_i->Name, strtab);
if (0 == strcmp(".ctors", (char*)secname)) {
- UChar *init_startC = (UChar*)(oc->image) + sectab_i->PointerToRawData;
+ UChar *init_startC = section.start;
init_t *init_start, *init_end, *init;
init_start = (init_t*)init_startC;
init_end = (init_t*)(init_startC + sectab_i->SizeOfRawData);
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 815180c..5686863 100644
--- a/rts/LinkerInternals.h
+++ b/rts/LinkerInternals.h
@@ -43,8 +43,8 @@ typedef
typedef
struct _Section {
- void* start; /* actual start of section in memory */
- StgWord size; /* actual size of section in memory */
+ void* start; /* actual start of section in memory */
+ StgWord size; /* actual size of section in memory */
SectionKind kind;
SectionAlloc alloc;
diff --git a/testsuite/tests/rts/T12031/ExternBug.hs b/testsuite/tests/rts/T12031/ExternBug.hs
new file mode 100644
index 0000000..5c28aed
--- /dev/null
+++ b/testsuite/tests/rts/T12031/ExternBug.hs
@@ -0,0 +1,9 @@
+-- Copyright (c) 2016, Ryan Scott
+-- ExternBug.hs
+{-# LANGUAGE ForeignFunctionInterface #-}
+module ExternBug (bar) where
+
+{-# INCLUDE foo.h #-}
+
+foreign import ccall "bar"
+ bar :: IO ()
diff --git a/testsuite/tests/rts/T12031/Makefile b/testsuite/tests/rts/T12031/Makefile
new file mode 100644
index 0000000..0a94206
--- /dev/null
+++ b/testsuite/tests/rts/T12031/Makefile
@@ -0,0 +1,8 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+T12031:
+ '$(TEST_HC)' -c bar.c -o bar.o
+ '$(TEST_HC)' -c baz.c -o baz.o
+ echo bar | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) bar.o baz.o ExternBug.hs
diff --git a/testsuite/tests/rts/T12031/T12031.stdout b/testsuite/tests/rts/T12031/T12031.stdout
new file mode 100644
index 0000000..e5cc126
--- /dev/null
+++ b/testsuite/tests/rts/T12031/T12031.stdout
@@ -0,0 +1 @@
+The value of foo is 1
diff --git a/testsuite/tests/rts/T12031/all.T b/testsuite/tests/rts/T12031/all.T
new file mode 100644
index 0000000..b051514
--- /dev/null
+++ b/testsuite/tests/rts/T12031/all.T
@@ -0,0 +1,4 @@
+test('T12031', [ extra_clean(['bar.o', 'baz.o', 'ExternBug.o'])
+ , extra_files(['bar.c', 'baz.c', 'ExternBug.hs', 'foo.h'])
+ ],
+ run_command, ['$MAKE -s --no-print-directory T12031'])
diff --git a/testsuite/tests/rts/T12031/bar.c b/testsuite/tests/rts/T12031/bar.c
new file mode 100644
index 0000000..257cc19
--- /dev/null
+++ b/testsuite/tests/rts/T12031/bar.c
@@ -0,0 +1,11 @@
+// Copyright (c) 2016, Ryan Scott
+// bar.c
+#include "foo.h"
+
+int foo = 0;
+
+void bar(void) {
+ foo = 1;
+
+ baz();
+}
diff --git a/testsuite/tests/rts/T12031/baz.c b/testsuite/tests/rts/T12031/baz.c
new file mode 100644
index 0000000..d710148
--- /dev/null
+++ b/testsuite/tests/rts/T12031/baz.c
@@ -0,0 +1,9 @@
+// Copyright (c) 2016, Ryan Scott
+// baz.c
+#include "foo.h"
+#include <stdio.h>
+
+void baz(void) {
+ printf("The value of foo is %d\n", foo); // Segfaults on this line
+ fflush(stdout);
+}
diff --git a/testsuite/tests/rts/T12031/foo.h b/testsuite/tests/rts/T12031/foo.h
new file mode 100644
index 0000000..d3ca4aa
--- /dev/null
+++ b/testsuite/tests/rts/T12031/foo.h
@@ -0,0 +1,11 @@
+// Copyright (c) 2016, Ryan Scott
+// foo.h
+#ifndef FOO_H
+#define FOO_H
+
+extern int foo;
+
+void bar(void);
+void baz(void);
+
+#endif
--
2.9.1

View File

@@ -1,161 +0,0 @@
From 48385cb2fc295eb8af9188cbe140142c1807d5a7 Mon Sep 17 00:00:00 2001
From: Tamar Christina <tamar@zhox.com>
Date: Tue, 31 May 2016 20:12:55 +0200
Subject: [PATCH] Remove special casing of Windows in generic files
Summary:
Remove some Windows specific code from the .m4 files
and have configure figure it out.
Unfortunately touchy can't be removed since there
is no mingw build of coreutils. Only msys builds
which would give us a dependency on the msys runtime.
Reviewers: hvr, austin, thomie, bgamari
Reviewed By: thomie, bgamari
Subscribers: thomie, erikd, #ghc_windows_task_force
Differential Revision: https://phabricator.haskell.org/D2248
---
aclocal.m4 | 49 +++++++++++++++++++++++++++++++------------------
configure.ac | 13 +++++--------
utils/touchy/touchy.c | 5 +++++
3 files changed, 41 insertions(+), 26 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index dcc3448..cbf51df 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -458,42 +458,55 @@ AC_DEFUN([GET_ARM_ISA],
# Set the variables used in the settings file
AC_DEFUN([FP_SETTINGS],
[
- if test "$windows" = YES
+ SettingsCCompilerCommand="$CC"
+ SettingsHaskellCPPCommand="$HaskellCPPCmd"
+ SettingsHaskellCPPFlags="$HaskellCPPArgs"
+ SettingsLdCommand="$LdCmd"
+ SettingsArCommand="$ArCmd"
+ SettingsPerlCommand="$PerlCmd"
+
+ if test -z "$DllWrap"
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"
- SettingsPerlCommand='$topdir/../perl/perl.exe'
- SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe"
- SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
- SettingsTouchCommand='$topdir/bin/touchy.exe'
- else
- SettingsCCompilerCommand="$CC"
- SettingsHaskellCPPCommand="$HaskellCPPCmd"
- SettingsHaskellCPPFlags="$HaskellCPPArgs"
- SettingsLdCommand="$LdCmd"
- SettingsArCommand="$ArCmd"
- SettingsPerlCommand="$PerlCmd"
SettingsDllWrapCommand="/bin/false"
+ else
+ SettingsDllWrapCommand="$DllWrap"
+ fi
+
+ if test -z "$Windres"
+ then
SettingsWindresCommand="/bin/false"
+ else
+ SettingsWindresCommand="$Windres"
+ fi
+
+ if test -z "$Libtool"
+ then
SettingsLibtoolCommand="libtool"
+ else
+ SettingsLibtoolCommand="$Libtool"
+ fi
+
+ if test -z "$Touch"
+ then
SettingsTouchCommand='touch'
+ else
+ SettingsTouchCommand='$Touch'
fi
+
if test -z "$LlcCmd"
then
SettingsLlcCommand="llc"
else
SettingsLlcCommand="$LlcCmd"
fi
+
if test -z "$OptCmd"
then
SettingsOptCommand="opt"
else
SettingsOptCommand="$OptCmd"
fi
+
SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
diff --git a/configure.ac b/configure.ac
index 15561d0..d7eb738 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,13 +177,9 @@ then
if test "$ghc_host_os" = "mingw32"
then
- if test "${OSTYPE}" = "msys"
- then
- WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"`
- else
- # Canonicalise to <drive>:/path/to/ghc
- WithGhc=`cygpath -m "${WithGhc}"`
- fi
+ # Canonicalise to <drive>:/path/to/ghc
+ WithGhc=`cygpath -m "${WithGhc}"`
+
echo "GHC path canonicalised to: ${WithGhc}"
fi
fi
@@ -366,6 +362,8 @@ then
NM="${mingwbin}nm.exe"
RANLIB="${mingwbin}ranlib.exe"
OBJDUMP="${mingwbin}objdump.exe"
+ Windres="${mingwbin}windres.exe"
+ DllWrap="${mingwbin}dllwrap.exe"
fp_prog_ar="${mingwbin}ar.exe"
# NB. Download the perl binaries if required
@@ -733,7 +731,6 @@ AC_SUBST(HaveDtrace)
AC_PATH_PROG(HSCOLOUR,HsColour)
# HsColour is passed to Cabal, so we need a native path
if test "$HostOS" = "mingw32" && \
- test "${OSTYPE}" != "msys" && \
test "${HSCOLOUR}" != ""
then
# Canonicalise to <drive>:/path/to/gcc
diff --git a/utils/touchy/touchy.c b/utils/touchy/touchy.c
index 88ababa..dbcf712 100644
--- a/utils/touchy/touchy.c
+++ b/utils/touchy/touchy.c
@@ -14,6 +14,11 @@
#include <windows.h>
/*
+touch is used by GHC both during building and during compilation of
+Haskell files. Unfortunately this means we need a 'touch' like program
+in the GHC bindist. Since touch is not standard on Windows and msys2
+doesn't include a mingw-w64 build of coreutils we need touchy for now.
+
With Windows 7 in a virtual box VM on OS X, some very odd things happen
with dates and time stamps when SSHing into cygwin. e.g. here the
"Change" time is in the past:
--
2.9.1

View File

@@ -1,311 +0,0 @@
From 865602e0beb8e30ea1e1edf7db90f24088badb9e Mon Sep 17 00:00:00 2001
From: Herbert Valerio Riedel <hvr@gnu.org>
Date: Sat, 16 Apr 2016 18:12:09 +0200
Subject: [PATCH] Rework CC/CC_STAGE0 handling in `configure.ac`
Rather than using the non-standard/idiomatic `--with-{gcc,clang}=...`
scheme use the `CC=...` style scheme.
The basic idea is to have Autoconf's CC/CFLAG/CPPFLAG apply to
stage{1,2,3}, while having a separate _STAGE0 set of env-vars
denote the bootstrap-toolchain flags/programs.
This should be simpler, less confusing, and somewhat more in line with
Autoconf's idioms (allowing us to reuse more of Autoconf rather than
(re)inventing our own confusing non-standard m4 macros to do stuff that
Autoconf could almost do already for us)
Morever, expose CC_STAGE0 as a so-called "precious" variable.
So now we can better control which bootstrapping gcc is used
(by default the one used by the stage0 ghc, unless CC_STAGE0 is
overriden)
```
Some influential environment variables:
CC_STAGE0 C compiler command (bootstrap)
CC C compiler command
CFLAGS C compiler flags
...
Use these variables to override the choices made by `configure' or to
help it to find libraries and programs with nonstandard names/locations.
```
Test Plan: I've tested that cross-compiling with
`--target=powerpc-linux-gnu` still works, and tried a few variants of
settting `CC=` and `CC_STAGE0=`; `./validate` passed as well
Reviewers: erikd, austin, bgamari, simonmar
Reviewed By: simonmar
Subscribers: Phyx, thomie
Differential Revision: https://phabricator.haskell.org/D2078
---
aclocal.m4 | 38 +++-----------------------------------
bindisttest/ghc.mk | 2 +-
configure.ac | 37 +++++++++++++++++++++++++++++--------
distrib/configure.ac.in | 4 +---
includes/ghc.mk | 2 +-
mk/config.mk.in | 10 +++++-----
rts/ghc.mk | 2 +-
rules/shell-wrapper.mk | 2 +-
8 files changed, 42 insertions(+), 55 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 6403748..477da3f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -471,7 +471,7 @@ AC_DEFUN([FP_SETTINGS],
SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
SettingsTouchCommand='$topdir/bin/touchy.exe'
else
- SettingsCCompilerCommand="$WhatGccIsCalled"
+ SettingsCCompilerCommand="$CC"
SettingsHaskellCPPCommand="$HaskellCPPCmd"
SettingsHaskellCPPFlags="$HaskellCPPArgs"
SettingsLdCommand="$LdCmd"
@@ -2067,38 +2067,6 @@ AC_DEFUN([FIND_GHC_BOOTSTRAP_PROG],[
])
-# FIND_GCC()
-# --------------------------------
-# Finds where gcc is
-#
-# $1 = the variable to set
-# $2 = the with option name
-# $3 = the command to look for
-AC_DEFUN([FIND_GCC],[
- if test "$windows" = YES
- then
- $1="$CC"
- else
- FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [$2], [$3])
- # fallback to CC if set and no --with-$2=... was used
- if test -z "$With_$2" -a -n "$CC"
- then
- With_$2="$CC"
- $1="$CC"
- # From Xcode 5 on/, OS X command line tools do not include gcc
- # anymore. Use clang.
- elif test -z "$$1"
- then
- FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [clang], [clang])
- fi
- if test -z "$$1"
- then
- AC_MSG_ERROR([cannot find $3 nor clang in your PATH])
- fi
- fi
- AC_SUBST($1)
-])
-
AC_DEFUN([MAYBE_OVERRIDE_STAGE0],[
if test ! -z "$With_$1" -a "$CrossCompiling" != "YES"; then
AC_MSG_NOTICE([Not cross-compiling, so --with-$1 also sets $2])
@@ -2132,13 +2100,13 @@ AC_ARG_WITH(hs-cpp,
# We can't use $CPP here, since HS_CPP_CMD is expected to be a single
# command (no flags), and AC_PROG_CPP defines CPP as "/usr/bin/gcc -E".
- HS_CPP_CMD=$WhatGccIsCalled
+ HS_CPP_CMD=$CC
SOLARIS_GCC_CPP_BROKEN=NO
SOLARIS_FOUND_GOOD_CPP=NO
case $host in
i386-*-solaris2)
- GCC_MAJOR_MINOR=`$WhatGccIsCalled --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
+ GCC_MAJOR_MINOR=`$CC --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
if test "$GCC_MAJOR_MINOR" != "3.4"; then
# this is not 3.4.x release so with broken CPP
SOLARIS_GCC_CPP_BROKEN=YES
diff --git a/bindisttest/ghc.mk b/bindisttest/ghc.mk
index 4b21106..cf2e481 100644
--- a/bindisttest/ghc.mk
+++ b/bindisttest/ghc.mk
@@ -38,7 +38,7 @@ test_bindist:
ifeq "$(Windows_Host)" "YES"
mv bindisttest/a/b/c/$(BIN_DIST_NAME) $(BIN_DIST_INST_DIR)
else
- cd bindisttest/a/b/c/$(BIN_DIST_NAME) && ./configure --prefix=$(TOP)/$(BIN_DIST_INST_DIR) --with-gcc="$(WhatGccIsCalled)"
+ cd bindisttest/a/b/c/$(BIN_DIST_NAME) && ./configure --prefix=$(TOP)/$(BIN_DIST_INST_DIR) CC="$(CC)"
cd bindisttest/a/b/c/$(BIN_DIST_NAME) && $(MAKE) install
endif
ifeq "$(GhcProfiled)" "NO"
diff --git a/configure.ac b/configure.ac
index dd3236c..c5260ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,11 @@ fi
AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
+dnl this makes sure `./configure --target=<cross-compile-target>`
+dnl works as expected, since we're slightly modifying how Autoconf
+dnl interprets build/host/target and how this interacts with $CC tests
+test -n "$target_alias" && ac_tool_prefix=$target_alias-
+
dnl ----------------------------------------------------------
dnl ** Find unixy sort and find commands,
dnl ** which are needed by FP_SETUP_PROJECT_VERSION
@@ -107,6 +112,11 @@ AC_ARG_ENABLE(tarballs-autodownload,
TarballsAutodownload=YES,
TarballsAutodownload=NO
)
+
+dnl CC_STAGE0 is like the "previous" variable CC (inherited by CC_STAGE[123])
+dnl but instead used by stage0 for bootstrapping stage1
+AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)])
+
if test "$WithGhc" != ""; then
FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
@@ -121,7 +131,11 @@ if test "$WithGhc" != ""; then
GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'`
GhcCanonVersion="$GhcMajVersion$GhcMinVersion2"
- BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command])
+ dnl infer CC_STAGE0 from `ghc --info` unless explicitly set by user
+ if test -z "$CC_STAGE0"; then
+ BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command])
+ fi
+
BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command])
BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command])
BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags])
@@ -432,13 +446,19 @@ AC_SUBST(TargetPlatformFull)
dnl ** Which gcc to use?
dnl --------------------------------------------------------------
-FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
-CC="$WhatGccIsCalled"
-export CC
-# If --with-gcc was used, and we're not cross-compiling, then it also
-# applies to the stage0 compiler.
-MAYBE_OVERRIDE_STAGE0([gcc],[CC_STAGE0])
+AC_ARG_WITH([gcc],
+ AS_HELP_STRING([--with-gcc=ARG], [Use ARG as the path to gcc (obsolete, use CC=ARG instead) [default=autodetect]]),
+ AC_MSG_ERROR([--with-gcc=$withval is obsolete (use './configure CC=$withval' or 'CC=$withval ./configure' instead)]))
+
+AC_ARG_WITH([clang],
+ AS_HELP_STRING([--with-clang=ARG], [Use ARG as the path to gcc (obsolete, use CC=ARG instead) [default=autodetect]]),
+ AC_MSG_ERROR([--with-clang=$withval is obsolete (use './configure CC=$withval' or 'CC=$withval ./configure' instead)]))
+
+dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set),
+dnl later CC is copied to CC_STAGE{1,2,3}
+AC_PROG_CC([gcc clang])
+
MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
dnl make extensions visible to allow feature-tests to detect them lateron
@@ -1155,7 +1175,8 @@ else
fi
echo ["\
- Using $CompilerName : $WhatGccIsCalled
+ Using (for bootstrapping) : $CC_STAGE0
+ Using $CompilerName : $CC
which is version : $GccVersion
Building a cross compiler : $CrossCompiling
hs-cpp : $HaskellCPPCmd
diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in
index c0610c6..fdd9fd9 100644
--- a/distrib/configure.ac.in
+++ b/distrib/configure.ac.in
@@ -59,9 +59,7 @@ XCODE_VERSION()
dnl ** Which gcc to use?
dnl --------------------------------------------------------------
-FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
-CC="$WhatGccIsCalled"
-export CC
+AC_PROG_CC([gcc clang])
# --with-hs-cpp/--with-hs-cpp-flags
FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
diff --git a/includes/ghc.mk b/includes/ghc.mk
index 31b2650..d08ecfb 100644
--- a/includes/ghc.mk
+++ b/includes/ghc.mk
@@ -177,7 +177,7 @@ includes_GHCCONSTANTS_HASKELL_EXPORTS = includes/dist-derivedconstants/header/GH
INSTALL_LIBS += $(includes_GHCCONSTANTS_HASKELL_VALUE)
-DERIVE_CONSTANTS_FLAGS += --gcc-program "$(WhatGccIsCalled)"
+DERIVE_CONSTANTS_FLAGS += --gcc-program "$(CC)"
DERIVE_CONSTANTS_FLAGS += $(addprefix --gcc-flag$(space),$(includes_CC_OPTS) -fcommon)
DERIVE_CONSTANTS_FLAGS += --nm-program "$(NM)"
ifneq "$(OBJDUMP)" ""
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 5d5e581..b5d910b 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -509,11 +509,10 @@ SUPPORTS_THIS_UNIT_ID = @SUPPORTS_THIS_UNIT_ID@
#-----------------------------------------------------------------------------
# C compiler
#
-# NB. Don't override $(WhatGccIsCalled) using build.mk, re-configure using
-# the flag --with-gcc=<blah> instead. The reason is that the configure script
+# NB. Don't override $(CC) using build.mk, re-configure using
+# the flag CC=<blah> instead. The reason is that the configure script
# needs to know which gcc you're using in order to perform its tests.
-WhatGccIsCalled = @WhatGccIsCalled@
GccVersion = @GccVersion@
ifeq "$(phase)" "0"
CrossCompilePrefix =
@@ -527,18 +526,19 @@ GccLT34 = @GccLT34@
GccLT46 = @GccLT46@
GccIsClang = @GccIsClang@
-CC = $(WhatGccIsCalled)
+CC = @CC@
CC_STAGE0 = @CC_STAGE0@
CC_STAGE1 = $(CC)
CC_STAGE2 = $(CC)
CC_STAGE3 = $(CC)
-AS = $(WhatGccIsCalled)
+AS = @CC@
AS_STAGE0 = @CC_STAGE0@
AS_STAGE1 = $(AS)
AS_STAGE2 = $(AS)
AS_STAGE3 = $(AS)
+# why no LD=@LD@ ?
LD_STAGE0 = @LD_STAGE0@
LD_STAGE1 = $(LD)
LD_STAGE2 = $(LD)
diff --git a/rts/ghc.mk b/rts/ghc.mk
index f57f3da..d7a46f9 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -538,7 +538,7 @@ ifeq "$(TargetOS_CPP)" "darwin"
# Darwin has a flag to tell dtrace which cpp to use.
# Unfortunately, this isn't supported on Solaris (See Solaris Dynamic Tracing
# Guide, Chapter 16, for the configuration variables available on Solaris)
-DTRACE_FLAGS = -x cpppath=$(WhatGccIsCalled)
+DTRACE_FLAGS = -x cpppath=$(CC)
endif
DTRACEPROBES_SRC = rts/RtsProbes.d
diff --git a/rules/shell-wrapper.mk b/rules/shell-wrapper.mk
index f674c0d..eb7d8f1 100644
--- a/rules/shell-wrapper.mk
+++ b/rules/shell-wrapper.mk
@@ -46,7 +46,7 @@ $$($1_$2_INPLACE_WRAPPER): $$($1_$2_INPLACE)
echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@
echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@
- echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
+ echo 'pgmgcc="$$(CC)"' >> $$@
$$($1_$2_SHELL_WRAPPER_EXTRA)
$$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
--
2.9.1

View File

@@ -0,0 +1,30 @@
From b0dccaccb304541e7f56d702bfbf65e18b98c05d Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Tue, 10 Jan 2017 16:05:31 -0600
Subject: [PATCH] SysTools: Revert linker flags change
fefe02c0324a25a52455a61f7f6e48be6d82d1ab inadvertently removed a
linker flag needed to ensure that stack allocations don't fail
(see #8870 and #12186 for original motivation). Undo this change.
Fixes #13100.
---
compiler/main/SysTools.hs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index 1ab5b138e0..e5ee54d85f 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -860,7 +860,7 @@ getLinkerInfo' dflags = do
-- Note [Windows stack usage]
-- Force static linking of libGCC
-- Note [Windows static libGCC]
- , "-static-libgcc" ]
+ , "-Xlinker", "--stack=0x800000,0x800000", "-static-libgcc" ]
_ -> do
-- In practice, we use the compiler as the linker here. Pass
-- -Wl,--version to get linker version info.
--
2.11.0

View File

@@ -1,222 +0,0 @@
diff --git a/Makefile b/Makefile
index 9b888e7..cc14663 100644
--- a/Makefile
+++ b/Makefile
@@ -131,7 +131,7 @@ endif
.PHONY: binary-dist
binary-dist: binary-dist-prep
- mv bindistprep/*.tar.$(TAR_COMP_EXT) .
+ #mv bindistprep/*.tar.$(TAR_COMP_EXT) .
.PHONY: binary-dist-prep
binary-dist-prep:
diff --git a/configure.ac b/configure.ac
index 0fceb16..03b7574 100644
--- a/configure.ac
+++ b/configure.ac
@@ -298,10 +298,10 @@ set_up_tarballs() {
else
action="download"
fi
- mk/get-win32-tarballs.sh $action $HostArch > missing-win32-tarballs
+ #mk/get-win32-tarballs.sh $action $HostArch > missing-win32-tarballs
case $? in
0)
- rm missing-win32-tarballs
+ #rm missing-win32-tarballs
;;
2)
echo
@@ -325,28 +325,28 @@ set_up_tarballs() {
esac
# Extract all the tarballs in one go
- if ! test -d inplace/mingw
- then
- AC_MSG_NOTICE([Extracting Windows toolchain from archives (may take a while)...])
- rm -rf inplace/mingw
- local base_dir="../ghc-tarballs/${tarball_dest_dir}"
- ( cd inplace &&
- find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; &&
- rm ".MTREE" &&
- rm ".PKGINFO" &&
- cd .. ) || fail "Error: Could not extract Windows toolchains."
-
- mv "inplace/${tarball_mingw_dir}" inplace/mingw &&
- touch inplace/mingw
-
- # NB. Now since the GCC is hardcoded to use /mingw32 we need to
- # make a wrapper around it to give it the proper paths
- mv inplace/mingw/bin/gcc.exe inplace/mingw/bin/realgcc.exe
- PATH=`pwd`/inplace/mingw/bin:$PATH
- inplace/mingw/bin/realgcc.exe driver/gcc/gcc.c driver/utils/cwrapper.c driver/utils/getLocation.c -Idriver/utils -o inplace/mingw/bin/gcc.exe
-
- AC_MSG_NOTICE([In-tree MingW-w64 tree created])
- fi
+ #if ! test -d inplace/mingw
+ #then
+ # AC_MSG_NOTICE([Extracting Windows toolchain from archives (may take a while)...])
+ # rm -rf inplace/mingw
+ # local base_dir="../ghc-tarballs/${tarball_dest_dir}"
+ # ( cd inplace &&
+ # find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; &&
+ # rm ".MTREE" &&
+ # rm ".PKGINFO" &&
+ # cd .. ) || fail "Error: Could not extract Windows toolchains."
+
+ # mv "inplace/${tarball_mingw_dir}" inplace/mingw &&
+ # touch inplace/mingw
+
+ # # NB. Now since the GCC is hardcoded to use /mingw32 we need to
+ # # make a wrapper around it to give it the proper paths
+ # #mv inplace/mingw/bin/gcc.exe inplace/mingw/bin/realgcc.exe
+ # #PATH=`pwd`/inplace/mingw/bin:$PATH
+ # #gcc.exe driver/gcc/gcc.c driver/utils/cwrapper.c driver/utils/getLocation.c -Idriver/utils -o inplace/mingw/bin/gcc.exe
+
+ # AC_MSG_NOTICE([In-tree MingW-w64 tree created])
+ #fi
}
if test "$HostOS" = "mingw32"
@@ -356,7 +356,8 @@ then
# NB. Download and extract the MingW-w64 distribution if required
set_up_tarballs
- mingwbin="$hardtop/inplace/mingw/bin/"
+ mingwbin=""
+ #"$hardtop/inplace/mingw/bin/"
CC="${mingwbin}gcc.exe"
LD="${mingwbin}ld.exe"
NM="${mingwbin}nm.exe"
@@ -367,18 +368,18 @@ then
fp_prog_ar="${mingwbin}ar.exe"
# NB. Download the perl binaries if required
- if ! test -d inplace/perl ||
- test inplace/perl -ot ghc-tarballs/perl/ghc-perl*.tar.gz
- then
- AC_MSG_NOTICE([Making in-tree perl tree])
- rm -rf inplace/perl
- mkdir inplace/perl
- (
- cd inplace/perl &&
- tar -zxf ../../ghc-tarballs/perl/ghc-perl*.tar.gz
- )
- AC_MSG_NOTICE([In-tree perl tree created])
- fi
+ #if ! test -d inplace/perl ||
+ # test inplace/perl -ot ghc-tarballs/perl/ghc-perl*.tar.gz
+ #then
+ # AC_MSG_NOTICE([Making in-tree perl tree])
+ # rm -rf inplace/perl
+ # mkdir inplace/perl
+ # (
+ # cd inplace/perl &&
+ # tar -zxf ../../ghc-tarballs/perl/ghc-perl*.tar.gz
+ # )
+ # AC_MSG_NOTICE([In-tree perl tree created])
+ #fi
fi
FP_ICONV
@@ -587,7 +588,7 @@ AC_SYS_INTERPRETER()
dnl ** look for `perl'
case $HostOS_CPP in
cygwin32|mingw32)
- PerlCmd=$hardtop/inplace/perl/perl
+ PerlCmd=perl
;;
*)
AC_PATH_PROG(PerlCmd,perl)
diff --git a/ghc.mk b/ghc.mk
index 792bd21..ed38bdb 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -836,13 +836,13 @@ endif
ifeq "$(Windows_Host)" "YES"
-install : install_mingw
-.PHONY: install_mingw
+#install : install_mingw
+#.PHONY: install_mingw
install_mingw : $(INPLACE_MINGW)
"$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
-install : install_perl
-.PHONY: install_perl
+#install : install_perl
+#.PHONY: install_perl
install_perl : $(INPLACE_PERL)
"$(CP)" -Rp $(INPLACE_PERL) $(prefix)
@@ -1090,7 +1090,7 @@ unix-binary-dist-prep:
windows-binary-dist-prep:
$(call removeTrees,bindistprep/)
$(MAKE) prefix=$(TOP)/$(BIN_DIST_PREP_DIR) install
- cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | $(TAR_COMP_CMD) -c > ../$(BIN_DIST_PREP_TAR_COMP)
+ #cd bindistprep && "$(TAR_CMD)" cf - $(BIN_DIST_NAME) | $(TAR_COMP_CMD) -c > ../$(BIN_DIST_PREP_TAR_COMP)
# tryTimes tries to run its third argument multiple times, until it
# succeeds. Don't call it directly; call try10Times instead.
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 2163643..3995bf4 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -522,19 +522,19 @@ GccLT46 = @GccLT46@
GccIsClang = @GccIsClang@
CC = @CC@
-CC_STAGE0 = @CC_STAGE0@
+CC_STAGE0 = $(CC)
CC_STAGE1 = $(CC)
CC_STAGE2 = $(CC)
CC_STAGE3 = $(CC)
AS = @CC@
-AS_STAGE0 = @CC_STAGE0@
+AS_STAGE0 = $(AS)
AS_STAGE1 = $(AS)
AS_STAGE2 = $(AS)
AS_STAGE3 = $(AS)
# why no LD=@LD@ ?
-LD_STAGE0 = @LD_STAGE0@
+LD_STAGE0 = $(LD)
LD_STAGE1 = $(LD)
LD_STAGE2 = $(LD)
LD_STAGE3 = $(LD)
@@ -645,9 +645,9 @@ SRC_HSC2HS_OPTS_STAGE1 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH --cflag=-D$(Targ
SRC_HSC2HS_OPTS_STAGE2 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH --cflag=-D$(TargetOS_CPP)_HOST_OS
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-WINDRES = $(INPLACE_MINGW)/bin/windres
+WINDRES = windres
else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
-WINDRES = $(INPLACE_MINGW)/bin/windres
+WINDRES = windres
endif
#-----------------------------------------------------------------------------
@@ -655,9 +655,9 @@ endif
#
HaveLibMingwEx = @HaveLibMingwEx@
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-DLLTOOL = inplace/mingw/bin/dlltool.exe
+DLLTOOL = dlltool.exe
else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
-DLLTOOL = inplace/mingw/bin/dlltool.exe
+DLLTOOL = dlltool.exe
endif
#-----------------------------------------------------------------------------
@@ -747,7 +747,7 @@ XARGS_OPTS = -s 20000
endif
ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
-STRIP_CMD = $(TOP)/inplace/mingw/bin/strip.exe
+STRIP_CMD = strip.exe
else ifeq "$(TARGETPLATFORM)" "arm-unknown-linux"
# The Cortex A8 hardware apparently has a bug which ld.gold will check for;
# however in order to do so it must have unstripped executables lest we

View File

@@ -1,121 +0,0 @@
From 6fe235543de7ea4319269f164ea444e4af68f759 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Sun, 7 Aug 2016 08:24:16 +1000
Subject: [PATCH] configure.ac: Remove checks for bug 9439
Bug #9439 only affects some ghc 7.8 versions of the compiler and since
git HEAD no longer builds with ghc-7.8 we can drop this check.
Test Plan: Works here!
Reviewers: hvr, austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2427
---
Makefile | 7 -------
configure.ac | 67 ------------------------------------------------------------
2 files changed, 74 deletions(-)
diff --git a/Makefile b/Makefile
index 82ab2f7..9b888e7 100644
--- a/Makefile
+++ b/Makefile
@@ -77,13 +77,6 @@ default : all
help:
@cat MAKEHELP.md
-# Verify that stage 0 LLVM backend isn't affected by Bug #9439 if needed
-ifeq "$(GHC_LLVM_AFFECTED_BY_9439)" "1"
-ifneq "$(findstring -fllvm,$(SRC_HC_OPTS) $(GhcHcOpts) $(GhcStage1HcOpts))" ""
-$(error Stage 0 compiler is affected by Bug #9439. Refusing to bootstrap with -fllvm)
-endif
-endif
-
# No need to update makefiles for these targets:
# (the ones we're filtering out)
REALGOALS=$(filter-out \
diff --git a/configure.ac b/configure.ac
index f4b839e..e9569e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -544,73 +544,6 @@ dnl --------------------------------------------------------------
dnl --------------------------------------------------------------
-dnl * General configuration checks
-dnl --------------------------------------------------------------
-
-dnl ** Bug 9439: Some GHC 7.8 releases had broken LLVM code generator.
-dnl Unfortunately we don't know whether the user is going to request a
-dnl build with the LLVM backend as this is only given in build.mk.
-dnl
-dnl Instead, we try to do as much work as possible here, checking
-dnl whether -fllvm is the stage 0 compiler's default. If so we
-dnl fail. If not, we check whether -fllvm is affected explicitly and
-dnl if so set a flag. The build system will later check this flag
-dnl after the desired build flags are known.
-
-dnl This problem is further complicated by the fact that the llvm
-dnl version used by the bootstrap compiler may be different from the
-dnl version we arre trying to compile GHC against. Therefore, we need
-dnl to find the boostrap compiler's `settings` file then check to see
-dnl if the `opt` and `llc` command strings are non-empty and if these
-dnl programs exist. Only if they exist to we test for bug #9439.
-
-FIND_GHC_BOOTSTRAP_PROG([BootstrapLlcCmd], [${WithGhc}], "LLVM llc command")
-FIND_GHC_BOOTSTRAP_PROG([BootstrapOptCmd], [${WithGhc}], "LLVM opt command")
-
-if test -n "$BootstrapLlcCmd" && test -n "$BootstrapOptCmd"
-then
- AC_MSG_CHECKING(whether bootstrap compiler is affected by bug 9439)
- echo "main = putStrLn \"%function\"" > conftestghc.hs
-
- # Check whether LLVM backend is default for this platform
- "${WithGhc}" -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" conftestghc.hs 2>&1 >/dev/null
- res=`./conftestghc`
- if test "x$res" = "x%object"
- then
- AC_MSG_RESULT(yes)
- echo "Buggy bootstrap compiler"
- echo ""
- echo "The stage 0 compiler $WithGhc is affected by GHC Bug \#9439"
- echo "and therefore will miscompile the LLVM backend if -fllvm is"
- echo "used."
- echo
- echo "Please use another bootstrap compiler"
- exit 1
- fi
-
- # -fllvm is not the default, but set a flag so the Makefile can check
- # -for it in the build flags later on
- "${WithGhc}" -fforce-recomp -pgmlc="${BootstrapLlcCmd}" -pgmlo="${BootstrapOptCmd}" -fllvm conftestghc.hs 2>&1 >/dev/null
- if test $? = 0
- then
- res=`./conftestghc`
- if test "x$res" = "x%object"
- then
- AC_MSG_RESULT(yes)
- GHC_LLVM_AFFECTED_BY_9439=1
- elif test "x$res" = "x%function"
- then
- AC_MSG_RESULT(no)
- GHC_LLVM_AFFECTED_BY_9439=0
- else
- AC_MSG_WARN(unexpected output $res)
- fi
- else
- AC_MSG_RESULT(failed to compile, assuming no)
- fi
-fi
-AC_SUBST([GHC_LLVM_AFFECTED_BY_9439])
-
dnl ** Can the unix package be built?
dnl --------------------------------------------------------------
--
2.9.1

View File

@@ -0,0 +1,139 @@
From 14af261259e51026b695da7c6de188e65992a114 Mon Sep 17 00:00:00 2001
From: Alethea Rose <alethea@alethearose.com>
Date: Tue, 21 Feb 2017 13:31:40 -0500
Subject: [PATCH] Use system build tools
---
aclocal.m4 | 16 ++++++++--------
configure.ac | 34 +++++++---------------------------
ghc.mk | 17 -----------------
mk/config.mk.in | 4 ++--
4 files changed, 17 insertions(+), 54 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 7723743..0f1f97a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -463,15 +463,15 @@ AC_DEFUN([FP_SETTINGS],
[
if test "$windows" = YES
then
- mingw_bin_prefix=mingw/bin/
- SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
- SettingsHaskellCPPCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
+ mingw_bin_prefix="$(cygpath -m $MINGW_PREFIX/bin/)"
+ SettingsCCompilerCommand="${mingw_bin_prefix}gcc.exe"
+ SettingsHaskellCPPCommand="${mingw_bin_prefix}gcc.exe"
SettingsHaskellCPPFlags="$HaskellCPPArgs"
- SettingsLdCommand="\$topdir/../${mingw_bin_prefix}ld.exe"
- SettingsArCommand="\$topdir/../${mingw_bin_prefix}ar.exe"
- SettingsPerlCommand='$topdir/../perl/perl.exe'
- SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe"
- SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
+ SettingsLdCommand="${mingw_bin_prefix}ld.exe"
+ SettingsArCommand="${mingw_bin_prefix}ar.exe"
+ SettingsPerlCommand='perl'
+ SettingsDllWrapCommand="${mingw_bin_prefix}dllwrap.exe"
+ SettingsWindresCommand="${mingw_bin_prefix}windres.exe"
SettingsTouchCommand='$topdir/bin/touchy.exe'
else
SettingsCCompilerCommand="$WhatGccIsCalled"
diff --git a/configure.ac b/configure.ac
index a434a39..c7b025d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,32 +362,12 @@ set_up_tarballs() {
if test "$HostOS" = "mingw32"
then
- test -d inplace || mkdir inplace
-
- # NB. Download and extract the MingW-w64 distribution if required
- set_up_tarballs
-
- mingwbin="$hardtop/inplace/mingw/bin/"
- CC="${mingwbin}gcc.exe"
- LD="${mingwbin}ld.exe"
- NM="${mingwbin}nm.exe"
- RANLIB="${mingwbin}ranlib.exe"
- OBJDUMP="${mingwbin}objdump.exe"
- fp_prog_ar="${mingwbin}ar.exe"
-
- # NB. Download the perl binaries if required
- if ! test -d inplace/perl ||
- test inplace/perl -ot ghc-tarballs/perl/ghc-perl*.tar.gz
- then
- AC_MSG_NOTICE([Making in-tree perl tree])
- rm -rf inplace/perl
- mkdir inplace/perl
- (
- cd inplace/perl &&
- tar -zxf ../../ghc-tarballs/perl/ghc-perl*.tar.gz
- )
- AC_MSG_NOTICE([In-tree perl tree created])
- fi
+ CC="gcc"
+ LD="ld"
+ NM="nm"
+ RANLIB="ranlib"
+ OBJDUMP="objdump"
+ fp_prog_ar="ar"
fi
FP_ICONV
@@ -626,7 +606,7 @@ AC_SYS_INTERPRETER()
dnl ** look for `perl'
case $HostOS_CPP in
cygwin32|mingw32)
- PerlCmd=$hardtop/inplace/perl/perl
+ PerlCmd=perl
;;
*)
AC_PATH_PROG(PerlCmd,perl)
diff --git a/ghc.mk b/ghc.mk
index ec9590a..d81fb60 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -831,23 +831,6 @@ endif
INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
endif
-# -----------------------------------------------------------------------------
-# Creating a local mingw copy on Windows
-
-ifeq "$(Windows_Host)" "YES"
-
-install : install_mingw
-.PHONY: install_mingw
-install_mingw : $(INPLACE_MINGW)
- "$(CP)" -Rp $(INPLACE_MINGW) $(prefix)
-
-install : install_perl
-.PHONY: install_perl
-install_perl : $(INPLACE_PERL)
- "$(CP)" -Rp $(INPLACE_PERL) $(prefix)
-
-endif # Windows_Host
-
ifneq "$(BINDIST)" "YES"
$(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \
libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
diff --git a/mk/config.mk.in b/mk/config.mk.in
index bfaaa66..6e1b21b 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -660,9 +660,9 @@ SRC_HSC2HS_OPTS_STAGE1 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH=1 --cflag=-D$(Ta
SRC_HSC2HS_OPTS_STAGE2 += --cflag=-D$(TargetArch_CPP)_HOST_ARCH=1 --cflag=-D$(TargetOS_CPP)_HOST_OS=1
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-WINDRES = $(INPLACE_MINGW)/bin/windres
+WINDRES = $(MINGW_PREFIX)/bin/windres
else ifeq "$(TARGETPLATFORM)" "x86_64-unknown-mingw32"
-WINDRES = $(INPLACE_MINGW)/bin/windres
+WINDRES = $(MINGW_PREFIX)/bin/windres
endif
#-----------------------------------------------------------------------------
--
2.11.1

View File

@@ -0,0 +1,43 @@
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -70,6 +70,27 @@
#define RTS_WIN64_ONLY(X) /**/
#endif
+/*
+ * Note [Symbols for MinGW's printf]
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * The printf offered by Microsoft's libc implementation, msvcrt, is quite
+ * incomplete, lacking support for even %ull. Consequently mingw-w64 offers its
+ * own implementation which we enable. However, to be thread-safe the
+ * implementation uses _lock_file. This would be fine except msvcrt.dll doesn't
+ * export _lock_file, only numbered versions do (e.g. msvcrt90.dll).
+ *
+ * To work around this mingw-w64 packages a static archive of msvcrt which
+ * includes their own implementation of _lock_file. However, this means that
+ * the archive contains things which the dynamic library does not; consequently
+ * we need to ensure that the runtime linker provides this symbol.
+ *
+ * It's all just so terrible.
+ *
+ * See also:
+ * https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/
+ * https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/
+ */
#define RTS_MINGW_ONLY_SYMBOLS \
SymI_HasProto(stg_asyncReadzh) \
SymI_HasProto(stg_asyncWritezh) \
@@ -84,7 +105,9 @@
RTS_WIN32_ONLY(SymI_HasProto(_imp___environ)) \
RTS_WIN64_ONLY(SymI_HasProto(__imp__environ)) \
RTS_WIN32_ONLY(SymI_HasProto(_imp___iob)) \
- RTS_WIN64_ONLY(SymI_HasProto(__iob_func))
+ RTS_WIN64_ONLY(SymI_HasProto(__iob_func)) \
+ /* see Note [Symbols for MinGW's printf] */ \
+ SymI_HasProto(_lock_file)
#define RTS_MINGW_COMPAT_SYMBOLS \
SymI_HasProto_deprecated(access) \

View File

@@ -0,0 +1,14 @@
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -107,7 +107,8 @@
RTS_WIN32_ONLY(SymI_HasProto(_imp___iob)) \
RTS_WIN64_ONLY(SymI_HasProto(__iob_func)) \
/* see Note [Symbols for MinGW's printf] */ \
- SymI_HasProto(_lock_file)
+ SymI_HasProto(_lock_file) \
+ SymI_HasProto(_unlock_file)
#define RTS_MINGW_COMPAT_SYMBOLS \
SymI_HasProto_deprecated(access) \

View File

@@ -1,12 +1,14 @@
# Maintainer ncihnegn <ningchen@outlook.com>
# Maintainer: Alethea Rose <alethea@alethearose.com>
_realname=ghc
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=8.0.1
pkgrel=2
pkgver=8.0.2
pkgrel=1
pkgdesc='The Glorious Glasgow Haskell Compilation System'
arch=('any')
group="$MINGW_PACKAGE_PREFIX-haskell-platform"
url='https://www.haskell.org/ghc/'
license=('The Glasgow Haskell Compiler License')
depends=("${MINGW_PACKAGE_PREFIX}-binutils"
@@ -17,89 +19,171 @@ depends=("${MINGW_PACKAGE_PREFIX}-binutils"
"${MINGW_PACKAGE_PREFIX}-headers"
"${MINGW_PACKAGE_PREFIX}-isl"
"${MINGW_PACKAGE_PREFIX}-libiconv"
"${MINGW_PACKAGE_PREFIX}-libffi"
"${MINGW_PACKAGE_PREFIX}-libwinpthread"
"${MINGW_PACKAGE_PREFIX}-mpc"
"${MINGW_PACKAGE_PREFIX}-mpfr"
"${MINGW_PACKAGE_PREFIX}-winpthreads-git"
"${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=('perl' 'unzip') #"${MINGW_PACKAGE_PREFIX}-python3-sphinx")
optdepends=("${MINGW_PACKAGE_PREFIX}-llvm: using LLVM as backend")
"${MINGW_PACKAGE_PREFIX}-mpfr")
provides=("${MINGW_PACKAGE_PREFIX}-haskell-array=0.5.1.1"
"${MINGW_PACKAGE_PREFIX}-haskell-base=4.9.1.0"
"${MINGW_PACKAGE_PREFIX}-haskell-binary=0.8.3.0"
"${MINGW_PACKAGE_PREFIX}-haskell-bytestring=0.10.8.1"
"${MINGW_PACKAGE_PREFIX}-haskell-containers=0.5.7.1"
"${MINGW_PACKAGE_PREFIX}-haskell-deepseq=1.4.2.0"
"${MINGW_PACKAGE_PREFIX}-haskell-directory=1.3.0.0"
"${MINGW_PACKAGE_PREFIX}-haskell-filepath=1.4.1.1"
"${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot=8.0.2"
"${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot-th=8.0.2"
"${MINGW_PACKAGE_PREFIX}-haskell-ghci=8.0.2"
"${MINGW_PACKAGE_PREFIX}-haskell-ghc-prim=0.5.0.0"
"${MINGW_PACKAGE_PREFIX}-haskell-haskeline=0.7.3.0"
"${MINGW_PACKAGE_PREFIX}-haskell-hoopl=3.10.2.1"
"${MINGW_PACKAGE_PREFIX}-haskell-hpc=0.6.0.3"
"${MINGW_PACKAGE_PREFIX}-haskell-integer-gmp=1.0.0.1"
"${MINGW_PACKAGE_PREFIX}-haskell-pretty=1.1.3.3"
"${MINGW_PACKAGE_PREFIX}-haskell-process=1.4.3.0"
"${MINGW_PACKAGE_PREFIX}-haskell-template-haskell=2.11.1.0"
"${MINGW_PACKAGE_PREFIX}-haskell-terminfo=0.4.0.2"
"${MINGW_PACKAGE_PREFIX}-haskell-time=1.6.0.1"
"${MINGW_PACKAGE_PREFIX}-haskell-transformers=0.5.2.0"
"${MINGW_PACKAGE_PREFIX}-haskell-win32=2.3.1.1"
"${MINGW_PACKAGE_PREFIX}-haskell-xhtml=3000.2.1"
"${MINGW_PACKAGE_PREFIX}-haskell-cabal=1.24.2.0")
replaces=("${MINGW_PACKAGE_PREFIX}-haskell-array"
"${MINGW_PACKAGE_PREFIX}-haskell-base"
"${MINGW_PACKAGE_PREFIX}-haskell-binary"
"${MINGW_PACKAGE_PREFIX}-haskell-bytestring"
"${MINGW_PACKAGE_PREFIX}-haskell-containers"
"${MINGW_PACKAGE_PREFIX}-haskell-deepseq"
"${MINGW_PACKAGE_PREFIX}-haskell-directory"
"${MINGW_PACKAGE_PREFIX}-haskell-filepath"
"${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot"
"${MINGW_PACKAGE_PREFIX}-haskell-ghc-boot-th"
"${MINGW_PACKAGE_PREFIX}-haskell-ghci"
"${MINGW_PACKAGE_PREFIX}-haskell-ghc-prim"
"${MINGW_PACKAGE_PREFIX}-haskell-haskeline"
"${MINGW_PACKAGE_PREFIX}-haskell-hoopl"
"${MINGW_PACKAGE_PREFIX}-haskell-hpc"
"${MINGW_PACKAGE_PREFIX}-haskell-integer-gmp"
"${MINGW_PACKAGE_PREFIX}-haskell-pretty"
"${MINGW_PACKAGE_PREFIX}-haskell-process"
"${MINGW_PACKAGE_PREFIX}-haskell-template-haskell"
"${MINGW_PACKAGE_PREFIX}-haskell-terminfo"
"${MINGW_PACKAGE_PREFIX}-haskell-time"
"${MINGW_PACKAGE_PREFIX}-haskell-transformers"
"${MINGW_PACKAGE_PREFIX}-haskell-win32"
"${MINGW_PACKAGE_PREFIX}-haskell-xhtml"
"${MINGW_PACKAGE_PREFIX}-haskell-cabal")
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-sphinx"
"${MINGW_PACKAGE_PREFIX}-llvm"
'make'
'perl')
optdepends=("${MINGW_PACKAGE_PREFIX}-llvm: use LLVM for an optimized backend")
install="${MINGW_PACKAGE_PREFIX}-ghc.install"
_hsarch=$CARCH
if [[ $_hsarch == "i686" ]]; then
_hsarch="i386"
fi
_hooks=('ghc-register.hook' 'ghc-unregister.hook' 'ghc-rebuild-doc-index.hook')
source=(
"https://downloads.haskell.org/~ghc/$pkgver/ghc-$pkgver-src.tar.xz"
"https://downloads.haskell.org/~ghc/$pkgver/ghc-$pkgver-testsuite.tar.xz"
"https://downloads.haskell.org/~ghc/$pkgver/ghc-$pkgver-src.tar.xz"{,.sig}
"https://downloads.haskell.org/~ghc/$pkgver/ghc-$pkgver-testsuite.tar.xz"{,.sig}
"https://downloads.haskell.org/~ghc/$pkgver/ghc-$pkgver-$_hsarch-unknown-mingw32.tar.xz"{,.sig}
'build.mk'
'0001-Rework-CC-CC_STAGE0-handling-in-configure.ac.patch'
'0001-Add-Windows-import-library-support-to-the-Runtime-Li.patch'
'0001-Remove-special-casing-of-Windows-in-generic-files.patch'
'0001-Enable-checkProddableBlock-on-x86_64.patch'
'0001-Add-relocation-type-R_X86_64_REX_GOTPCRELX.patch'
'0001-Fix-incorrect-calculated-relocations-on-Windows-x86_.patch'
'0001-Switch-to-LLVM-version-3.9.patch'
'0001-configure.ac-Remove-checks-for-bug-9439.patch'
'0001-Fix-configure-detection.patch'
'0001-Unstaged.patch'
'0001-SysTools-Revert-linker-flags-change.patch'
'0002-Switch-to-LLVM-version-3.9.patch'
'0003-Use-system-build-tools.patch'
'0004-Add-MinGW-_lock_file-symbol.patch'
'0005-Add-MinGW-_unlock_file-symbol.patch'
'ghc-register.hook'
'ghc-unregister.hook'
'ghc-rebuild-doc-index.hook'
)
noextract=("ghc-$pkgver-$_hsarch-unknown-mingw32.tar.xz")
sha256sums=('11625453e1d0686b3fa6739988f70ecac836cadc30b9f0c8b49ef9091d6118b1'
'SKIP'
'52235d299eb56292f2c273dc490792788b8ba11f4dc600035d050c8a4c1f4cf2'
'SKIP'
'SKIP'
'SKIP'
'c4284efe02de55fbd3dedadb785ad977d123a7e257ef3d77d33ee0a127e9248d'
'bf8e495a657eaacf8adfa0fb23a52f578a365e0a0f3559bef14b6ca58acb9eda'
'555dad54247f4c8b58f5b915c66f4f947341b3320a280ec08894ab812946f63b'
'f7d6c844b68be2dfcb89583c8315fe1eac97b3dca805a9021a5d52352e4fb073'
'779174f48caa342bc2515c157343dffd2b22979a65c2ae0f73a6dc30948d84af'
'c0926878e278717431a02ede49cea628d1d80a83459a0a99744d9e2cdbf1ece6'
'633b6a02efa3a6f30c4c40062f24bf0ffa9689c21d0e16da09ed8b699ba6050e'
'33bde1f07e6317017e9c7fc7b2e7ad2d63ed3dcde407a23401d0a03861301cea'
'31f3b191bcfe7ad09a886e90f6d71c3be5bee02304a81bffe61ac1f5dcdae703')
validpgpkeys=('FFEB7CE81E16A36B3E2DED6F2DE04D4E97DB64AD') # Benjamin Gamari <ben@well-typed.com>
prepare() {
SYST=$CARCH
if [[ $SYST == "i686" ]]; then
SYST="i386"
fi
mkdir -p host
curl -LO "https://www.haskell.org/cabal/release/cabal-install-1.24.0.0/cabal-install-1.24.0.0-$SYST-unknown-mingw32.zip"
curl -L "https://downloads.haskell.org/~${_realname}/$pkgver/${_realname}-$pkgver-$SYST-unknown-mingw32.tar.xz" | tar -Jx --strip-components=1 --directory=host
unzip -o cabal-install-1.24.0.0-$SYST-unknown-mingw32.zip -d host/bin
export PATH=$srcdir/host/bin:$PATH
cabal update
cabal install alex happy --prefix=$srcdir/host
cp build.mk "$srcdir/${_realname}-$pkgver/mk"
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Rework-CC-CC_STAGE0-handling-in-configure.ac.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Add-Windows-import-library-support-to-the-Runtime-Li.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Remove-special-casing-of-Windows-in-generic-files.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Enable-checkProddableBlock-on-x86_64.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Add-relocation-type-R_X86_64_REX_GOTPCRELX.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Fix-incorrect-calculated-relocations-on-Windows-x86_.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Switch-to-LLVM-version-3.9.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-configure.ac-Remove-checks-for-bug-9439.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Fix-configure-detection.patch
patch -d "$srcdir/${_realname}-$pkgver" -p1 < 0001-Unstaged.patch
cd "$srcdir"
mkdir -p $CARCH/host
rm -rf $CARCH/ghc-$pkgver
mv {,$CARCH/}ghc-$pkgver
msg "Extracting binaries: ghc-$pkgver-$_hsarch-unknown-mingw32.tar.xz..."
bsdtar -xf ghc-$pkgver-$_hsarch-unknown-mingw32.tar.xz \
-C $CARCH/host --strip-components 1
for _hook in "${_hooks[@]}"; do
echo $_hook
sed -e "s|MINGW_PREFIX|$(basename $MINGW_PREFIX)|" \
$_hook > $CARCH/$_hook
done
export PATH="$srcdir/$CARCH/host/bin:$PATH"
cp -v "$srcdir/build.mk" "$srcdir/$CARCH/ghc-$pkgver/mk/build.mk"
cd "$srcdir/$CARCH/ghc-$pkgver"
patch -Np1 -i "$srcdir/0001-SysTools-Revert-linker-flags-change.patch"
patch -Np1 -i "$srcdir/0002-Switch-to-LLVM-version-3.9.patch"
patch -Np1 -i "$srcdir/0003-Use-system-build-tools.patch"
patch -Np1 -i "$srcdir/0004-Add-MinGW-_lock_file-symbol.patch"
patch -Np1 -i "$srcdir/0005-Add-MinGW-_unlock_file-symbol.patch"
}
build() {
export PATH=$srcdir/host/bin:$PATH
cd "$srcdir/${_realname}-$pkgver"
export PATH="$srcdir/$CARCH/host/bin:$PATH"
cd "$srcdir/$CARCH/ghc-$pkgver"
./boot
./configure --prefix=${MINGW_PREFIX}
./configure \
--with-system-libffi \
--with-ffi-includes="$(cygpath -u $(pkg-config --variable=includedir libffi))"
make
#make html
#Need xelatex
#make pdf
make html
}
check() {
export PATH=$srcdir/host/bin:$PATH
cd "$srcdir/${_realname}-$pkgver"
#Don't check to save time
#make test
cd "$srcdir/$CARCH/ghc-$pkgver"
make test
}
package() {
export PATH=$srcdir/host/bin:$PATH
cd "$srcdir/${_realname}-$pkgver"
make binary-dist
mv bindistprep/${_realname}-$pkgver "$pkgdir"${MINGW_PREFIX}
}
cd "$srcdir/$CARCH/ghc-$pkgver"
sha256sums=('90fb20cd8712e3c0fbeb2eac8dab6894404c21569746655b9b12ca9684c7d1d2'
'bc57163656ece462ef61072559d491b72c5cdd694f3c39b80ac0f6b9a3dc8151'
'c4284efe02de55fbd3dedadb785ad977d123a7e257ef3d77d33ee0a127e9248d'
'b8e404b55f40bccf60a5bf93108ee845197cf4857f106018aea1c8c841ed2e14'
'5a6d3fe2ab4c49d8b1921e139907373fd93925fcfbe16d282f1735988831a07a'
'6d910a567732fcbc808d20ff17a8d7a1ead6a634d341810887fe45a217709714'
'7f8ace437031139aaab620b6fa2fb3420aeeecb46c154751283453a3842b6b82'
'36099d0e80c89eae3c79ac94e59286548802d911ed41a6cc489d233af1268088'
'b99ebe964d7d01cd2a4167e353a29e00d3fb0705ecca39f6d2e36b10e4d5bda0'
'555dad54247f4c8b58f5b915c66f4f947341b3320a280ec08894ab812946f63b'
'b11e174202e36b74dcd8d27ebc158604c902bfbdef3e470dd234fc8250c2d27a'
'039f7bf52e229ecf70f9b50819d29593ab65b5e932bc26911234cf56b3336d1d'
'53ecc3a9cbc8cda17e0f37c7ecba0878c8a512aa1735c72a2da49aa76dcf6508')
make prefix="${pkgdir}${MINGW_PREFIX}" \
docdir="${pkgdir}${MINGW_PREFIX}/share/docs/ghc" \
install
for _hook in "${_hooks[@]}"; do
install -Dm644 "$srcdir/$CARCH/$_hook" \
"$pkgdir/usr/share/libalpm/hooks/$MINGW_PACKAGE_PREFIX-$_hook"
done
mkdir -vp "${pkgdir}${MINGW_PREFIX}/share/haskell/"{register,unregister}
install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/ghc/LICENSE"
}

View File

@@ -0,0 +1,14 @@
[Trigger]
Type = File
Operation = Install
Operation = Upgrade
Operation = Remove
Target = MINGW_PREFIX/share/doc/ghc/html/libraries/*
Target = !MINGW_PREFIX/share/doc/ghc/html/libraries/index.html
[Action]
Description = Rebuilding Haskell doc index...
When = PostTransaction
Exec = /bin/bash -c "cd /MINGW_PREFIX/share/doc/ghc/html/libraries && ./gen_contents_index"
Depends = ghc
Depends = bash

View File

@@ -0,0 +1,12 @@
[Trigger]
Type = File
Operation = Install
Operation = Upgrade
Target = MINGW_PREFIX/share/haskell/register/*.sh
[Action]
Description = Registering Haskell modules...
When = PostTransaction
Exec = /bin/sh -c 'while read -r f; do /bin/sh "/$f" ; done'
Depends = ghc
NeedsTargets

View File

@@ -0,0 +1,12 @@
[Trigger]
Type = File
Operation = Upgrade
Operation = Remove
Target = MINGW_PREFIX/share/haskell/unregister/*.sh
[Action]
Description = Unregistering Haskell modules...
When = PreTransaction
Exec = /bin/sh -c 'while read -r f; do /bin/sh "/$f" ; done'
Depends = ghc
NeedsTargets

View File

@@ -0,0 +1,10 @@
pre_upgrade() {
echo '==> Unregistering cabalized packages...'
[[ -d /mingw32/share/haskell ]] && find /mingw32/share/haskell -maxdepth 2 -name 'unregister.sh' -exec {} \;
echo '==> Done.'
}
post_upgrade() {
echo '==> All cabalized packages need to be reinstalled now.'
echo '==> See /usr/mingw32/haskell/ for a tentative list of affected packages.'
}

View File

@@ -0,0 +1,10 @@
pre_upgrade() {
echo '==> Unregistering cabalized packages...'
[[ -d /mingw64/share/haskell ]] && find /mingw64/share/haskell -maxdepth 2 -name 'unregister.sh' -exec {} \;
echo '==> Done.'
}
post_upgrade() {
echo '==> All cabalized packages need to be reinstalled now.'
echo '==> See /mingw64/share/haskell/ for a tentative list of affected packages.'
}

View File

@@ -0,0 +1,40 @@
#!/bin/bash
. PKGBUILD
if [[ ! -d src/${MSYSTEM_CARCH}/ghc-${pkgver}/libraries ]]; then
echo "error: no directory src/${MSYSTEM_CARCH}/ghc-${pkgver}/libraries: You must extract the source tarball under src/"
exit 1
fi
declare -A exclude
# no unix because we're on windows
exclude['unix']=1
# no integer-simple because we use integer-gmp
exclude['integer-simple']=1
# extract excluded libraries from ghc.mk
for exclude_pkg in $(sed 's/PKGS_THAT_ARE_INTREE_ONLY := //p' -n src/${MSYSTEM_CARCH}/ghc-${pkgver}/ghc.mk); do
exclude[${exclude_pkg}]=1
done
cd src/${MSYSTEM_CARCH}/ghc-${pkgver}/libraries
# $1 is the name of the variable
# $2 is the string for the test, either '=' or '<'
print_var() {
printf "$1=("
for path in $(ls ./*/*.cabal Cabal/Cabal*/Cabal.cabal); do
dirname=$(echo $path | awk -F '/' '{ print $2 }')
cabalfile=$(echo $path | awk -F '/' '{ print $3 }')
cabalname=$(basename $cabalfile .cabal)
[[ ${exclude[${dirname}]} ]] && continue
version=$(awk 'tolower($0) ~ /^version:/ {print $2 }' $path)
printf "\"\${MINGW_PACKAGE_PREFIX}-haskell-${cabalname,,}"
[[ -n "$2" ]] && printf "$2$version"
printf "\"\n "
done
echo -e '\b)'
}
print_var 'provides' '='
print_var 'replaces'