Last active
July 23, 2017 18:59
-
-
Save AlainODea/ccb4f0ad7385a691b6fe to your computer and use it in GitHub Desktop.
WIP: Install GHC 8.0.2 starting from PKGSRC ghc 7.6.3 on SmartOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- settings.in 2017-07-23 14:25:55.733820769 +0000 | |
+++ settings.in.patched 2017-07-23 14:26:39.156012024 +0000 | |
@@ -1,33 +1,33 @@ | |
[("GCC extra via C opts", "@GccExtraViaCOpts@"), | |
("C compiler command", "@SettingsCCompilerCommand@"), | |
("C compiler flags", "@SettingsCCompilerFlags@"), | |
- ("C compiler link flags", "@SettingsCCompilerLinkFlags@"), | |
+ ("C compiler link flags", "@SettingsCCompilerLinkFlags@ -lssp"), | |
("Haskell CPP command","@SettingsHaskellCPPCommand@"), | |
("Haskell CPP flags","@SettingsHaskellCPPFlags@"), | |
("ld command", "@SettingsLdCommand@"), | |
- ("ld flags", "@SettingsLdFlags@"), | |
+ ("ld flags", "@SettingsLdFlags@ -lssp"), | |
("ld supports compact unwind", "@LdHasNoCompactUnwind@"), | |
("ld supports build-id", "@LdHasBuildId@"), | |
("ld supports filelist", "@LdHasFilelist@"), | |
("ld is GNU ld", "@LdIsGNULd@"), | |
- ("ar command", "@SettingsArCommand@"), | |
+ ("ar command", "ar"), | |
("ar flags", "@ArArgs@"), | |
("ar supports at file", "@ArSupportsAtFile@"), | |
("touch command", "@SettingsTouchCommand@"), | |
("dllwrap command", "@SettingsDllWrapCommand@"), | |
("windres command", "@SettingsWindresCommand@"), | |
("libtool command", "@SettingsLibtoolCommand@"), | |
- ("readelf command", "@SettingsReadElfCommand@"), | |
+ ("readelf command", "readelf"), | |
("perl command", "@SettingsPerlCommand@"), | |
("cross compiling", "@CrossCompiling@"), | |
("target os", "@HaskellTargetOs@"), | |
("target arch", "@HaskellTargetArch@"), | |
("target word size", "@WordSize@"), | |
("target has GNU nonexec stack", "@HaskellHaveGnuNonexecStack@"), | |
("target has .ident directive", "@HaskellHaveIdentDirective@"), | |
("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@"), | |
("Unregisterised", "@Unregisterised@"), | |
("LLVM llc command", "@SettingsLlcCommand@"), | |
("LLVM opt command", "@SettingsOptCommand@") | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /opt/local/lib/ghc-7.6.3/settings 2017-07-06 13:03:27.535396964 +0000 | |
+++ /opt/local/lib/ghc-7.6.3/settings.fixed 2017-07-06 13:03:16.515974064 +0000 | |
@@ -1,20 +1,20 @@ | |
[("GCC extra via C opts", " -fwrapv"), | |
("C compiler command", "gcc"), | |
- ("C compiler flags", " -pipe -O2 -pipe -O2 -I/opt/local/include -I/usr/include -I/opt/local/include/ncurses -fno-stack-protector -L/opt/local/gcc49/lib/gcc/i486-sun-solaris2.11/4.9.4 -Wl,-R/opt/local/gcc49/lib/gcc/i486-sun-solaris2.11/4.9.4 -L/opt/local/lib -L/usr/lib -Wl,-R/usr/lib -Wl,-R/opt/local/lib"), | |
+ ("C compiler flags", " -pipe -O2 -pipe -O2 -I/opt/local/include -I/usr/include -I/opt/local/include/ncurses -fno-stack-protector -L/opt/local/gcc49/lib/gcc/i486-sun-solaris2.11/4.9.4 -Wl,-R/opt/local/gcc49/lib/gcc/i486-sun-solaris2.11/4.9.4 -L/opt/local/lib -L/usr/lib -Wl,-R/usr/lib -Wl,-R/opt/local/lib -lssp"), | |
("ar command", "ar"), | |
("ar flags", "q"), | |
("ar supports at file", "YES"), | |
("touch command", "touch"), | |
("dllwrap command", "/bin/false"), | |
("windres command", "/bin/false"), | |
("perl command", "/opt/local/bin/perl"), | |
("target os", "OSSolaris2"), | |
("target arch", "ArchX86"), | |
("target word size", "4"), | |
("target has GNU nonexec stack", "True"), | |
("target has .ident directive", "True"), | |
("target has subsections via symbols", "False"), | |
("LLVM llc command", "llc"), | |
("LLVM opt command", "opt") | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- settings.in 2017-07-23 14:22:44.329190132 +0000 | |
+++ settings.in.patched 2017-07-23 14:23:12.682450201 +0000 | |
@@ -1,33 +1,33 @@ | |
[("GCC extra via C opts", "@GccExtraViaCOpts@"), | |
("C compiler command", "@SettingsCCompilerCommand@"), | |
("C compiler flags", "@SettingsCCompilerFlags@"), | |
- ("C compiler link flags", "@SettingsCCompilerLinkFlags@"), | |
+ ("C compiler link flags", "@SettingsCCompilerLinkFlags@ -lssp"), | |
("C compiler supports -no-pie", "@SettingsCCompilerSupportsNoPie@"), | |
("Haskell CPP command","@SettingsHaskellCPPCommand@"), | |
("Haskell CPP flags","@SettingsHaskellCPPFlags@"), | |
("ld command", "@SettingsLdCommand@"), | |
- ("ld flags", "@SettingsLdFlags@"), | |
+ ("ld flags", "@SettingsLdFlags@ -lssp"), | |
("ld supports compact unwind", "@LdHasNoCompactUnwind@"), | |
("ld supports build-id", "@LdHasBuildId@"), | |
("ld supports filelist", "@LdHasFilelist@"), | |
("ld is GNU ld", "@LdIsGNULd@"), | |
- ("ar command", "@SettingsArCommand@"), | |
+ ("ar command", "ar"), | |
("ar flags", "@ArArgs@"), | |
("ar supports at file", "@ArSupportsAtFile@"), | |
("touch command", "@SettingsTouchCommand@"), | |
("dllwrap command", "@SettingsDllWrapCommand@"), | |
("windres command", "@SettingsWindresCommand@"), | |
("libtool command", "@SettingsLibtoolCommand@"), | |
("perl command", "@SettingsPerlCommand@"), | |
("cross compiling", "@CrossCompiling@"), | |
("target os", "@HaskellTargetOs@"), | |
("target arch", "@HaskellTargetArch@"), | |
("target word size", "@WordSize@"), | |
("target has GNU nonexec stack", "@HaskellHaveGnuNonexecStack@"), | |
("target has .ident directive", "@HaskellHaveIdentDirective@"), | |
("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@"), | |
("Unregisterised", "@Unregisterised@"), | |
("LLVM llc command", "@SettingsLlcCommand@"), | |
("LLVM opt command", "@SettingsOptCommand@") | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o xtrace | |
# use at least base/base64 14.1.0 to get the EROFS fix in GHC's included unix package | |
builder_user=get_from_gabor | |
builder_pass=get_from_gabor | |
builder_master=haskell.inf.elte.hu | |
pkgin -y update | |
pkgin -y full-upgrade | |
pkgin -y install ghc build-essential | |
pkgin -y install ghostscript # optional for h2ps tests | |
# BEGIN: HACK to work around boot GHC having been built without -lssp | |
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 | |
# END: HACK to work around boot GHC having been built with a custom ar | |
groupadd ghcbld | |
useradd -m -s /bin/bash -g ghcbld ghcbld | |
cat > /opt/local/lib/ghc-7.6.3/overridecpp.spec <<'EOF' | |
*cpp: | |
%{cpp_subtarget} | |
EOF | |
cat > /opt/local/bin/ghc-cpp <<'EOF' | |
#!/bin/bash | |
gcc -specs=/opt/local/lib/ghc-7.6.3/overridecpp.spec $@ | |
EOF | |
chmod +x /opt/local/bin/ghc-cpp | |
su - ghcbld -c " | |
# Bootstrap cabal-install (missing from PKGSRC ghc) | |
cabal_install_version=1.20.0.1 | |
cabal_install_directory=cabal-install-${cabal_install_version} | |
cabal_install_archive=${cabal_install_directory}.tar.gz | |
curl -OL https://www.haskell.org/cabal/release/${cabal_install_directory}/${cabal_install_archive} | |
tar xf ${cabal_install_archive} | |
cd ${cabal_install_directory} | |
chmod +x bootstrap.sh | |
./bootstrap.sh | |
# cabal-install bootstrap complete | |
cat >> .profile <<'EOF' | |
PATH=\$HOME/.cabal/bin:\$PATH | |
EOF | |
ln -s /bin/bash ~/.cabal/bin/sh | |
export PATH=\$HOME/.cabal/bin:\$PATH | |
cabal update | |
cabal install -j happy alex HsOpenSSL | |
curl -OL https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3b-src.tar.bz2 | |
tar xf ghc-7.10.3b-src.tar.bz2 | |
pushd ghc-7.10.3/utils/lndir | |
gcc lndir.c -o ~/.cabal/bin/lndir | |
popd | |
pushd ghc-7.10.3 | |
cat > mk/build.mk <<'EOF' | |
V=1 | |
InstallExtraPackages=YES | |
BeConservative=YES | |
EOF | |
./boot && ./configure --with-hs-cpp="ghc-cpp" --prefix /opt/local && gmake -j16 | |
popd | |
" | |
pushd ~ghcbld/ghc-7.10.3/ | |
gmake install | |
popd | |
su - ghcbld -c " | |
curl -OL https://downloads.haskell.org/~ghc/8.0.2/ghc-8.0.2-src.tar.xz | |
tar xf ghc-8.0.2-src.tar.xz | |
pushd ghc-8.0.2 | |
cat > mk/build.mk <<'EOF' | |
V=1 | |
InstallExtraPackages=YES | |
BeConservative=YES | |
EOF | |
./boot && ./configure --with-hs-cpp="ghc-cpp" --prefix /opt/local && gmake -j16 | |
popd | |
" | |
pushd ~ghcbld/ghc-8.0.2/ | |
gmake install | |
popd | |
su - ghcbld -c " | |
git clone https://github.com/haskell/ghc-builder.git | |
pushd ~/ghc-builder/ | |
cabal install common/ client/ | |
popd | |
mkdir ~/builder | |
pushd ~/builder/ | |
builder-client init \"$builder_user\" \"$builder_pass\" $builder_master | |
mkdir certs | |
curl http://haskell.inf.elte.hu/ghcBuilder/cert/root.pem > certs/root.pem | |
popd | |
" | |
curl -L https://gist.github.com/AlainODea/10431222/raw/68e66c5f6516086f2630164c0db5fcd40b81f48f/ghc-builder-client.xml > /opt/local/lib/svc/manifest/ghc-builder-client.xml | |
svccfg import /opt/local/lib/svc/manifest/ghc-builder-client.xml | |
echo Run 'svcadm enable ghc-builder-client' to enable GHC builder |
This doesn't quite work to get to GHC 8.0.2 (latest stable release as of this writing). GHC 8.0.2 runs as does GHCi, but it can't bootstrap cabal-install-1.24.0.2.
It's a separate issue. bootstrap.sh has a bug if collect2 and ld are both present it emits a mangled LINK command with both in it separately by a newline. It looks like it is fixed in master.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Key fix step is patching ${GHC_HOME}/settings "C compiler flags" to include -lssp to ensure automatic linking of the Stack Smashing Protection library (libssp). This is important because the implicit linking that resulted from older Illumos builds left binaries open to segmentation faults when the ABI of GCC changed. The SmartOS GZ has a fixed libssp and SmartMachines - by necessity - have a libssp in sync with their GCC version.