On Wed, Jul 26, 2017 at 13:30 Danny Navarro <j...@dannynavarro.net> wrote:
> Hi Alain, > > I don't the knowledge to help you bootstrap new versions of GHC and create > the PKGSRC, but I'm really missing a package with a more recent version of > GHC for SmartOS. So I really appreciate the effort you are making. > > You can definitely count me in as a tester for the GHC 8.0.2 package when > you get there. > Thank you, Danny. I appreciate it. Sorry for my delayed reply. I've paused this for a bit as it has been very slow going. I'm not in a position to fix the way it is currently broken. The problem with getting GHC 7.10.x or later is a bad boot bootstrap compiler which needs to be replaced in Manta. If you need Haskell immediately for something, the manual build process works. On Mon, Jul 24, 2017 at 10:52 PM, Alain O'Dea <alain.o...@gmail.com> wrote: > >> On Sun, Jul 23, 2017 at 11:49 AM Alain O'Dea <alain.o...@gmail.com> >> wrote: >> >>> On Sat, Jul 22, 2017 at 5:01 PM Alain O'Dea <alain.o...@gmail.com> >>> wrote: >>> >>>> On Sun, Jul 9, 2017 at 12:25 AM Alain O'Dea <alain.o...@gmail.com> >>>> wrote: >>>> >>>>> On Sat, Jul 8, 2017 at 2:23 PM Alain O'Dea <alain.o...@gmail.com> >>>>> wrote: >>>>> >>>>>> On Sat, Jul 8, 2017 at 10:41 AM Alain O'Dea <alain.o...@gmail.com> >>>>>> wrote: >>>>>> >>>>>>> I've got the build from GHC 7.6.3 in PKGSRC thru GHC 7.10.3 up to >>>>>>> GHC 8.0.2 (latest stable) working with manual builds. >>>>>>> >>>>>>> I've been working in a PKGSRC 2017Q1 sandbox on the latest pkgbuild >>>>>>> image to make it package-friendly. >>>>>>> >>>>>>> Here's my plan: >>>>>>> 1. Create wip/ghc7x which builds GHC 7.10.3 by build depending on >>>>>>> lang/ghc >>>>>>> 2. Create wip/ghc8 which builds GHC 8.0.2 by build depending on >>>>>>> wip/ghc7x >>>>>>> >>>>>>> I ran into an odd issue with the GHC 7.10.3 I built. It is a 64-bit >>>>>>> binary, but is somehow linked against some 32-bit libraries (ncurses, >>>>>>> iconv, gmp) and won't run. >>>>>>> >>>>>>> [root@ghc-builder-x86-64-smartos ~]# ghc >>>>>>> ld.so.1: ghc: fatal: /opt/local/lib//libncurses.so.6: wrong ELF >>>>>>> class: ELFCLASS32 >>>>>>> Killed >>>>>>> [root@ghc-builder-x86-64-smartos ~]# ldd >>>>>>> /opt/local/lib/ghc-7.10.3/bin/ghc >>>>>>> libncurses.so.6 => /opt/local/lib//libncurses.so.6 - >>>>>>> wrong ELF class: ELFCLASS32 >>>>>>> libiconv.so.2 => /opt/local/lib//libiconv.so.2 - >>>>>>> wrong ELF class: ELFCLASS32 >>>>>>> libgmp.so.10 => /opt/local/lib//libgmp.so.10 - wrong ELF >>>>>>> class: ELFCLASS32 >>>>>>> libm.so.2 => /usr/lib/amd64/libm.so.2 >>>>>>> librt.so.1 => /usr/lib/amd64/librt.so.1 >>>>>>> libdl.so.1 => /usr/lib/amd64/libdl.so.1 >>>>>>> libpthread.so.1 => /usr/lib/amd64/libpthread.so.1 >>>>>>> libssp.so.0 => /usr/lib/amd64/libssp.so.0 >>>>>>> libssp.so.0 (LIBSSP_1.0) => (version not found) >>>>>>> libc.so.1 => /usr/lib/amd64/libc.so.1 >>>>>>> libgcc_s.so.1 => /usr/lib/64/libgcc_s.so.1 >>>>>>> >>>>>> >>>>>> I also found this: >>>>>> => Checking for work-directory references in ghc-7.10.3b >>>>>> ERROR: /opt/local/lib/ghc-7.10.3/settings: ("readelf command", >>>>>> "/home/pbulk/build/wip/ghc7x/work/.tools/bin/readelf"), >>>>>> ERROR: *** The above files still have references to the build >>>>>> directory. >>>>>> ERROR: This is possibly an error that should be fixed by >>>>>> unwrapping >>>>>> ERROR: the files or adding missing tools to the package makefile! >>>>>> *** Error code 1 >>>>>> >>>>>> It originates in GHC's aclocal.m4. It is somehow picking up the >>>>>> sandbox tools instead of the platform tools. This came up unrelated to >>>>>> SmartOS on #ghc as well last night and I regrettably missed the >>>>>> opportunity >>>>>> to engage their core team. >>>>>> >>>>>> I fix it directly by including a patch for settings.in which >>>>>> disregards the ar, ld, and readelf detected by their autoconf and put in >>>>>> correct /opt/local/bin (ar and readelf) or /usr/bin (only for ld) >>>>>> equivalents. I also fix the libssp link errors seen in compiling client >>>>>> code with GHC by including -lssp in the linker options configs in >>>>>> settings.in. >>>>>> >>>>>> PKGSRC support for GHC 7.10.3 is pretty close to releasable now. The >>>>>> pkgbuild image is an outstanding workbench for this, so thank you >>>>>> Jonathan >>>>>> for putting that together. >>>>>> >>>>> >>>>> Still getting broken binaries out of the build: >>>>> >>>>> [root@ghc-builder-x86-64-smartos /opt/local]# ghci >>>>> ld.so.1: ghc: fatal: /opt/local/lib//libncurses.so.6: wrong ELF class: >>>>> ELFCLASS32 >>>>> Killed >>>>> [root@ghc-builder-x86-64-smartos /opt/local]# ghc >>>>> ld.so.1: ghc: fatal: /opt/local/lib//libncurses.so.6: wrong ELF class: >>>>> ELFCLASS32 >>>>> Killed >>>>> [root@ghc-builder-x86-64-smartos /opt/local]# ldd >>>>> /opt/local/lib/ghc-7.10.3/bin/ghc >>>>> libssp.so.0 => /usr/lib/amd64/libssp.so.0 >>>>> libssp.so.0 (LIBSSP_1.0) => (version not found) >>>>> libncurses.so.6 => /opt/local/lib//libncurses.so.6 - >>>>> wrong ELF class: ELFCLASS32 >>>>> libiconv.so.2 => /opt/local/lib//libiconv.so.2 - >>>>> wrong ELF class: ELFCLASS32 >>>>> libgmp.so.10 => /opt/local/lib//libgmp.so.10 - wrong ELF >>>>> class: ELFCLASS32 >>>>> libm.so.2 => /usr/lib/amd64/libm.so.2 >>>>> librt.so.1 => /usr/lib/amd64/librt.so.1 >>>>> libdl.so.1 => /usr/lib/amd64/libdl.so.1 >>>>> libpthread.so.1 => /usr/lib/amd64/libpthread.so.1 >>>>> libc.so.1 => /usr/lib/amd64/libc.so.1 >>>>> libgcc_s.so.1 => /usr/lib/64/libgcc_s.so.1 >>>>> >>>>> The ghc binary looks fine in the pkgbuild work .destdir: >>>>> --<root@pkgbuild >>>>> >-(/data/chroot/dev-2017Q1-x86_64)-</home/pbulk/build/wip/ghc7x/work>-- >>>>> -> ldd .destdir/opt/local/lib/ghc-7.10.3/bin/ghc >>>>> libssp.so.0 => >>>>> /opt/local/gcc49/x86_64-sun-solaris2.11/lib/amd64/libssp.so.0 >>>>> libncurses.so.6 => /opt/local/lib//libncurses.so.6 >>>>> libiconv.so.2 => /opt/local/lib//libiconv.so.2 >>>>> libgmp.so.10 => /opt/local/lib//libgmp.so.10 >>>>> libm.so.2 => /usr/lib/amd64/libm.so.2 >>>>> librt.so.1 => /usr/lib/amd64/librt.so.1 >>>>> libdl.so.1 => /usr/lib/amd64/libdl.so.1 >>>>> libpthread.so.1 => /usr/lib/amd64/libpthread.so.1 >>>>> libc.so.1 => /usr/lib/amd64/libc.so.1 >>>>> libgcc_s.so.1 => >>>>> /opt/local/gcc49/x86_64-sun-solaris2.11/lib/amd64/libgcc_s.so.1 >>>>> libumem.so.1 => /lib/64/libumem.so.1 >>>>> >>>>> I'm not sure why libcurses, libiconv, and libgmp come out wrong, while >>>>> libm, librt, libdl, libpthread, libc, and libgcc_s all come out fine. I >>>>> really have no idea why ldd shows a second libssp in the base-multiarch >>>>> 17.1.0 zone I extracted >>>>> /data/packages/SmartOS/2017Q1/x86_64/All/ghc-7.10.3b.tgz into. >>>>> >>>>> I think it's an issue with how I'm building my sandbox. I'm using >>>>> `run-sandbox 2017Q1-x86_64`. >>>>> >>>>> When I run my package on base-64 17.1.0, it appears to work. I can >>>>> compile hello.hs: >>>>> main = putStrLn "Hello, World" >>>>> >>>>> but ghci segfaults: >>>>> [root@ghc-builder-x86-64-smartos /opt/local]# ghci >>>>> GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help >>>>> Segmentation Fault (core dumped) >>>>> >>>>> I ran ghci with truss and got this tail: >>>>> /2: setcontext(0xFFFFFD7FFEEBE4B0) >>>>> /2: Received signal #14, SIGALRM, in lwp_park() [caught] >>>>> /2: siginfo: SIG#0 >>>>> /2: lwp_park(0x00000000, 0) Err#91 ERESTART >>>>> /2: lwp_sigmask(SIG_SETMASK, 0x00002000, 0x00000000, 0x00000000, >>>>> 0x00000000) = 0xFFBFFEFF [0xFFFFFFFF] >>>>> /2: setcontext(0xFFFFFD7FFEEBE4B0) >>>>> /1: Incurred fault #6, FLTBOUNDS %pc = 0x0432FE0C >>>>> /1: siginfo: SIGSEGV SEGV_ACCERR addr=0x0432FE0C >>>>> /1: Received signal #11, SIGSEGV [default] >>>>> /1: siginfo: SIGSEGV SEGV_ACCERR addr=0x0432FE0C >>>>> >>>>> It's not clear what ghci is attempting when it segfaults. When I build >>>>> manually external to PKGSRC it works. >>>>> >>>>> I wondering if the extra slash in the lib paths is causing grief. >>>>> >>>>> I have a branch with my WIP on it: >>>>> https://github.com/AlainODea/pkgsrc-wip/blob/ao-ghc7x/ghc7x/Makefile >>>>> >>>> >>>> New strategy. I took pkgsrc-wip/ghc as a basis (much cleaner) and used >>>> it's bootstrap to build GHC 7.10.3. >>>> >>>> Still getting segfaults, but I have decent details documented: >>>> https://gist.github.com/AlainODea/c9a1da84efc8e22e3ba637af8a3f53c2 >>>> >>>> I'm out of my depth here. I've tried some basic mdb hacking to figure >>>> out what happened, but I'm not getting far with that. >>>> >>>> I think I have it located in foreignExportStablePtr, but I'm not sure. >>>> >>>> Has anyone seen seg faults in GHCi after building GHC on SmartOS >>>> recently? >>>> >>> >>> Confirmed. The 7.10.2 boot GHC at >>> https://us-east.manta.joyent.com/pkgsrc/public/distfiles-local/ghc-7.10.2-boot-x86_64-unknown-solaris2.tar.xz >>> is >>> broken and unusable. I build GHC 7.10.3 successfully with PKGSRC GHC 7.6.3 >>> and it works. >>> >>> I have a working Illumos-compatible x86_64 GHC 7.10.3 bindist. >>> >>> Here's how I built it: >>> >>> Get dependencies: >>> >>> ```bash >>> pkgin update >>> pkgin -y full-upgrade >>> pkgin -y install build-essential ghc >>> ``` >>> >>> Fix broken PKGSRC-installed GHC handling of SSP (append -lssp to its >>> linker args): >>> >>> ```bash >>> curl -OL >>> https://gist.github.com/AlainODea/ccb4f0ad7385a691b6fe/raw/2dc2142db60ea3597d2bc1d09c5b406d66cc34e3/ghc_settings.patch >>> patch /opt/local/lib/ghc-7.6.3/settings ghc_settings.patch >>> ``` >>> >>> Get GHC 7.10.3b source distribution: >>> >>> ```bash >>> curl -OL >>> https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-src.tar.xz.sig >>> curl -OL >>> https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-src.tar.xz >>> gpg --verify ghc-7.10.3b-src.tar.xz.sig >>> curl -OL https://alainodea.com/.well-known/97DB64AD.asc >>> ``` >>> >>> Expect this output from the GPG verify (97DB64AD is Ben Gamari's PGP >>> key): >>> >>> ```plain >>> gpg: Signature made Tue Dec 29 10:20:42 2015 UTC using RSA key ID >>> 97DB64AD >>> gpg: Good signature from "Benjamin Gamari <b...@well-typed.com>" >>> gpg: WARNING: This key is not certified with a trusted signature! >>> gpg: There is no indication that the signature belongs to the >>> owner. >>> Primary key fingerprint: FFEB 7CE8 1E16 A36B 3E2D ED6F 2DE0 4D4E 97DB >>> 64AD >>> ``` >>> >>> There's a note coming on the haskell.org downloads page to clarify that >>> Ben's key is the trusted key for this. Hopefully they'll also include a TLS >>> verified link to his public key. >>> >>> Next step is to extract and build GHC 7.10.3: >>> >>> ```bash >>> tar xf ghc-7.10.3b-src.tar.xz >>> cd ghc-7.10.3/ >>> curl -OL >>> https://gist.github.com/AlainODea/ccb4f0ad7385a691b6fe/raw/c2b3a19b0e11d8287336f61b016db0072ddebc92/ghc_7.10.3_settings.in.patch >>> patch settings.in ghc_7.10.3_settings.in.patch >>> patch settings ghc_settings.patch >>> pushd utils/lndir >>> gcc lndir.c -o /opt/local/bin/lndir >>> popd >>> ./configure --prefix /opt/local --disable-ld-override >>> gmake >>> gmake binary-dist # you could stop here and use this to make a PKGSRC >>> GHC 7.10.3 for further bootstrapping >>> gmake install >>> ``` >>> >>> Completing the step above and binary packaging it is the smart thing I >>> think. The advantage of this is that it doesn't require introducing another >>> bootstrap compiler. It just uses the binary GHC 7.8.3 in PKGSRC already. >>> I'm going to try to make wip/ghc use that PKGSRC ghc binary as the >>> bootstrap and bypass the distfiles-local issue. >>> >>> Optional next step is to extract and build GHC 8.0.2, but I think it >>> would be better to complete the above and get GHC 7.10.3 into PKGSRC as a >>> binary as it has a clean story and a less insane build: >>> >>> ```bash >>> tar xf ghc-8.0.2-src.tar.xz >>> cd ghc-8.0.2/ >>> curl -OL >>> https://gist.github.com/AlainODea/ccb4f0ad7385a691b6fe/raw/c2b3a19b0e11d8287336f61b016db0072ddebc92/ghc_8.0.2_settings.in.patch >>> ./configure --prefix /opt/local --disable-ld-override >>> gmake >>> gmake binary-dist >>> gmake install >>> ``` >>> >> >> Caveat: there's almost certainly a better way a PKGSRC expert would know >> to do what I'm suggesting below. Particularly, I think there has to be a >> way to get wip/ghc to get its bootstrap from PKGSRC rather than a external >> distfile. >> >> >> https://pkgsrc.joyent.com/packages/SmartOS/2017Q2/multiarch/All/ghc-7.6.3nb11.tgz >> can >> be extracted and repackaged as >> https://us-east.manta.joyent.com/pkgsrc/public/distfiles-local/ghc-7.10.2-boot-x86_64-unknown-solaris2.tar.xz >> and >> the wip/ghc in PKGSRC WIP should work after distinfo is updated with the >> appropriate hashes. >> >> Effectively this means there is no special bootstrap compiler, it's just >> an older PKGSRC binary whose provenance is known. >> >> This is achievable by unpacking and repacking the latest PKGSRC binary >> ghc: >> >> ```bash >> curl -OL >> https://pkgsrc.joyent.com/packages/SmartOS/2017Q2/multiarch/All/ghc-7.6.3nb11.tgz >> boot_work=$(mktemp --directory) >> boot_dist=$(mktemp --directory) >> cd ${boot_work} >> ar xf ghc-7.6.3nb11.tgz >> tar xf ghc-7.6.3nb11.tmp.tgz >> cd lib >> mv ghc-7.6.3{,-boot} >> tar cJf ${boot_dist}/ghc-7.10.2-boot-x86_64-unknown-solaris2.tar.xz >> ``` >> >> And because it's Manta you can use SnapLinks (mln) to create links >> (negligible storage cost) per GHC version you want to package. Any GHC >> 7.10.* is good for GHC 7.10.* through GHC 8.2.1 and hopefully will hang on >> for a good while. No need to duplicate data. >> >> For example, you want wip/ghc to build GHC 8.0.2 so you SnapLink 8.0.2 to >> 7.10.3 (which you would regrettably need to build and upload unless there's >> a trick for pulling it direct from PKGSRC): >> >> ```bash >> mln >> ~~/public/distfiles-local/ghc-{8.0.2,7.10.3}-boot-x86_64-unknown-solaris2.tar.xz >> ``` >> >> From there on all versions of GHC are conceivably open for PKGSRC >> packaging. The obvious candidate being GHC 8.0.2 which is a stable release >> broadly supported by community tools. >> >> > > > -- > Danny Navarro | http://dannynavarro.net > *smartos-discuss* | Archives > <https://www.listbox.com/member/archive/184463/=now> > <https://www.listbox.com/member/archive/rss/184463/23736926-be9f0783> | > Modify > <https://www.listbox.com/member/?&> > Your Subscription <http://www.listbox.com> > ------------------------------------------- smartos-discuss Archives: https://www.listbox.com/member/archive/184463/=now RSS Feed: https://www.listbox.com/member/archive/rss/184463/25769125-55cfbc00 Modify Your Subscription: https://www.listbox.com/member/?member_id=25769125&id_secret=25769125-7688e9fb Powered by Listbox: http://www.listbox.com