Opened 2 years ago

Last modified 22 months ago

#64996 assigned defect

WIP on making nhc98 build

Reported by: barracuda156 Owned by: essandess (Steve Smith)
Priority: Normal Milestone:
Component: ports Version: 2.7.2
Keywords: powerpc, leopard, snowleopard Cc:
Port: nhc98

Description

If we are to believe Macports bots, nhc98 fails across the board. At the same time its website gives impression that compilation is trivial and was working on Darwin PPC among others: https://www.haskell.org/nhc98/install.html

I have tried to update the port to @ 1.22 (the latest official release), and it still fails for me. I tried building with gcc-4.2, macports-gcc-10 and ghc-7.6.3.

Can anyone confirm whether it fails too?

Sources available here: https://www.haskell.org/nhc98/download.html Or here: https://github.com/haskell-implementations/nhc98

  1. S. To have the latest version, Portfile should be changed to:
master_sites http://www.haskell.org/nhc98/

distfiles ${name}src-${version}${extract.suffix}

checksums           md5     9c7669d3de6d217274ac4aadd63dce7e \
                    sha1    a8adc8f22371998ee0657bc0e01058a57d876abc \
                    rmd160  99a90d00f77f66938c817c813f11c3d0ea5bf244 \
                    sha256  14c5c16c336d0bb15e6e3d1baad8a2bca93c0538a129fb18df1d47d1f4eb6f3a \
                    size    29854160

Attachments (3)

main_10.5.8_ppc32.log (107.7 KB) - added by barracuda156 2 years ago.
How it fails on 10.5.8:
main_10.5.8_ppc32_v2.log (323.3 KB) - added by barracuda156 2 years ago.
And then I try with no patches and only default config args, using the old trick with reinplace to fix configure:
main-Tiger.log (129.0 KB) - added by barracuda156 2 years ago.
And it also fails on Tiger:

Download all attachments as: .zip

Change History (13)

comment:1 Changed 2 years ago by barracuda156

I have found a patch that claims to address the issue, however I cannot make it work still: https://github.com/Millak/guix/blob/master/gnu/packages/patches/nhc98-c-update.patch

# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=53964

--- Makefile.inc.orig	2010-07-09 20:40:18.000000000 +0800
+++ Makefile.inc	2022-04-13 07:12:27.000000000 +0800
@@ -1,6 +1,9 @@
 ### Configurable variables:
+# We want C89 semantics plus C++-style comments and things like the
+# 'setjmp_buf' and 'u_short' types.  More importantly, build with '-O1'
+# only to avoid modern optimizations that break the code.
 
-OPT = -O3
+OPT = -O1 -std=gnu89 -D_GNU_SOURCE=1
 #ARCH = -m32
 ARCH = 
 

--- script/nhc98heap.c.orig	2007-03-13 06:03:52.000000000 +0800
+++ script/nhc98heap.c	2022-04-13 07:09:55.000000000 +0800
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <stdio.h>
+#include <ctype.h>
 main(int argc, char **argv)
 {
   int prefix = 1;


--- src/runtime/Kernel/collector.c.orig	2007-03-13 06:03:52.000000000 +0800
+++ src/runtime/Kernel/collector.c	2022-04-13 07:11:12.000000000 +0800
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 #include "node.h"
 /*#include "newmacros.h"  -- already included in node.h */
 /*#include "runtime.h"    -- already included in node.h */

comment:2 Changed 2 years ago by barracuda156

I don't get why it can't find the header in this specific instance. The path is src/runtime/Kernel/newmacros.h:

cd src/cpphs;          /usr/bin/make -f Makefile.nhc98 fromC
make[1]: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/src/runtime'
cd Kernel; /usr/bin/make links
script/hmake-PRAGMA.hc:1:10: fatal error: newmacros.h: No such file or directory
    1 | #include "newmacros.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
…
collect2: error: ld returned 1 exit status
strip /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin10/greencard-nhc98
error: strip: can't open file: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin10/greencard-nhc98 (No such file or directory)
make[1]: *** [fromC] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/src/greencard'
make: *** [targets/powerpc-Darwin10/greencard-gcc] Error 2
  1. S. Portfile post-patch does more that needed, apparently. This is enough to fix target error:
--- Makefile.orig	2010-02-20 17:21:37.000000000 +0800
+++ Makefile	2022-04-13 10:34:37.000000000 +0800
@@ -207,7 +207,7 @@
 						prelude hsc2hs libraries
 basic-ghc: $(PRAGMA) runtime hmake-ghc greencard-ghc compiler-ghc cpphs \
 						prelude hsc2hs libraries
-basic-$(CC): runtime prelude-$(CC) pragma-$(CC) cpphs-$(CC) \
+basic-$(BUILDCOMP): runtime prelude-$(CC) pragma-$(CC) cpphs-$(CC) \
 		greencard-$(CC) hmake-$(CC) hsc2hs-$(CC) package-deps-$(CC) \
 		compiler-$(CC) libraries-$(CC)

Last edited 2 years ago by barracuda156 (previous) (diff)

comment:3 Changed 2 years ago by barracuda156

Summary: Why nhc98 fails to build, any ideas?WIP on making nhc98 build

comment:4 Changed 2 years ago by barracuda156

Owner: set to essandess
Status: newassigned

comment:5 Changed 2 years ago by barracuda156

If anyone got suggestions, please feel free to instruct me :) I am interested in fixing Haskell stuff, and nhc98 is one of the major compilers, though, admittedly, an old one.

Changed 2 years ago by barracuda156

Attachment: main_10.5.8_ppc32.log added

How it fails on 10.5.8:

comment:6 Changed 2 years ago by barracuda156

Whatever options I try, it still fails. With patches, without patches, on 10.6, on 10.5.8, using make or gmake, specifying STRIP= or not. Errors somewhat differ depending on case, but nothing works.

This is from the log above, I applied patches and used gmake:

:info:build gmake[2]: Leaving directory '/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/src/runtime/Kernel'
:info:build cd Ratio; /opt/local/bin/gmake fromC
:info:build gmake[2]: Entering directory '/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/src/prelude/Ratio'
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/primDecodeFloat.o primDecodeFloat.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/primEncodeFloat.o primEncodeFloat.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/script/nhc98 -c -d /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/prelude/Ratio  *.hc
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/primDoubleFromInteger.o primDoubleFromInteger.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/primIntFromInteger.o primIntFromInteger.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/primPackString.o primPackString.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/lengthPS.o lengthPS.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/script/nhc98 -H8M -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/cpphs  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/CppIfdef.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/HashDefine.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/MacroPass.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/Options.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/Position.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/ReadFirst.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/RunCpphs.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/SymTab.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Cpphs/Tokenise.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Language/Preprocessor/Unlit.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/Text/ParserCombinators/HuttonMeijer.o  /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/cpphs/cpphs.o
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/unpackPS.o unpackPS.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/main.o: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/mutlib.o: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/mutator.o: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/Prelude.a: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/Runtime.a: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/Prelude.a: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/Runtime.a: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/Prelude.a: No such file or directory
:info:build powerpc-apple-darwin9-gcc-4.0.1: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/Runtime.a: No such file or directory
:info:build strip /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/cpphs
:info:build gcc -c -I../Kernel -I/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/include   -O1 -std=gnu89 -DHIGH_BYTE_FIRST    -o /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/targets/powerpc-Darwin9/obj/runtime/Builtin/indexPS.o indexPS.c
:info:build /bin/sh: -c: line 0: syntax error near unexpected token `)'
:info:build /bin/sh: -c: line 0: `if [ 5493) \> 4.2 ]; then echo -Wno-pointer-to-int-cast; fi'
:info:build error: strip: can't open file: /opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/lib/powerpc-Darwin9/cpphs (No such file or directory)
:info:build gmake[1]: *** [Makefile.nhc98:61: fromC] Error 1
:info:build gmake[1]: Leaving directory '/opt/local/var/macports/build/_opt_PPCLeopardPorts_lang_nhc98/nhc98/work/nhc98-1.22/src/cpphs'
:info:build gmake: *** [Makefile:398: targets/powerpc-Darwin9/cpphs-gcc] Error 2
:info:build gmake: *** Waiting for unfinished jobs....

Changed 2 years ago by barracuda156

Attachment: main_10.5.8_ppc32_v2.log added

And then I try with no patches and only default config args, using the old trick with reinplace to fix configure:

Changed 2 years ago by barracuda156

Attachment: main-Tiger.log added

And it also fails on Tiger:

comment:7 Changed 2 years ago by barracuda156

Last edited 22 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:8 Changed 22 months ago by ryandesign (Ryan Carsten Schmidt)

That PR was faulty in a number of ways.

  1. It blacklists all compilers:
Warning: All compilers are either blacklisted or unavailable; defaulting to first fallback option

Clang is the only compiler modern macOS has in the compiler list, but this port apparently is not compatible with clang. Therefore the port must add some other suitable compiler to the compiler.fallback list.

  1. It patches configure and Makefile so that it always builds with gcc rather than with the compiler MacPorts tells it to use; in other words; it's not UsingTheRightCompiler.
Last edited 22 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:9 in reply to:  8 Changed 22 months ago by barracuda156

Replying to ryandesign:

That PR was faulty in a number of ways.

  1. It blacklists all compilers:
Warning: All compilers are either blacklisted or unavailable; defaulting to first fallback option

Clang is the only compiler modern macOS has in the compiler list, but this port apparently is not compatible with clang. Therefore the port must add some other suitable compiler to the compiler.fallback list.

  1. It patches configure and Makefile so that it always builds with gcc rather than with the compiler MacPorts tells it to use; in other words; it's not UsingTheRightCompiler.

The alternative compiler could be ghc, however I cannot verify if its current Macports version builds this port (since it is not yet fixed for PPC). As I recall, defining it to build with gcc has been both done in Macports with the earlier version of the port, as well as on FreeBSD.

comment:10 in reply to:  8 Changed 22 months ago by barracuda156

Replying to ryandesign:

  1. It patches configure and Makefile so that it always builds with gcc rather than with the compiler MacPorts tells it to use; in other words; it's not UsingTheRightCompiler.
  1. S. So once/if I manage to fix recent ghc for PPC, I will try incorporating its support into nhc98 port. The third supported compiler is hbc: https://github.com/haskell-implementations/hbc – but it does not exist in Macports.
Note: See TracTickets for help on using tickets.