diff --git a/.devcontainer/.gitignore b/.devcontainer/.gitignore index d48d420e9214f..527cd9f666444 100644 --- a/.devcontainer/.gitignore +++ b/.devcontainer/.gitignore @@ -1,13 +1,21 @@ * !/assets/ +!/assets/screenshots/ !/bind-mounts/ +!/conf/ +!/conf/etc/ +!/conf/etc/stack/ !/ghc-*/ !/scripts/ +!/scripts/usr/ +!/scripts/usr/local/ +!/scripts/usr/local/bin/ -!/assets/manageHLS.png +!/assets/screenshots/manageHLS.png +!/conf/etc/stack/config.yaml !/ghc-*/devcontainer.json -!/scripts/*.sh +!/scripts/usr/local/bin/*.sh !/devcontainer.json !/GHC.Dockerfile diff --git a/.devcontainer/GHC.Dockerfile b/.devcontainer/GHC.Dockerfile index b517d68dc9794..42e745845a636 100644 --- a/.devcontainer/GHC.Dockerfile +++ b/.devcontainer/GHC.Dockerfile @@ -10,9 +10,10 @@ ARG STACK_VERSION_OVERRIDE=${STACK_VERSION:-none} FROM ${BUILD_ON_IMAGE}:${GHC_VERSION} as files -RUN mkdir -p /files/usr/local/bin +RUN mkdir /files -COPY scripts /files/usr/local/bin +COPY conf /files +COPY scripts /files ## Ensure file modes are correct RUN find /files -type d -exec chmod 755 {} \; \ diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 4e98cc00244d8..d05036f14a00c 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -1,7 +1,7 @@ # Dev Containers These Dev Containers are based on the same docker images that are used to build -the amd64 and arm64 binary releases of pandoc. +the *statically linked* Linux amd64 and arm64 binary releases of pandoc. Those multi-arch (`linux/amd64`, `linux/arm64/v8`) docker images themselves are based on Alpine Linux and contain *unofficial* builds of GHC. @@ -11,7 +11,8 @@ Only use the GHC available in the Dev Containers, because 1. the *official* GHC bindists for Alpine Linux (`x86_64`) are just too buggy. 2. there are currently (2023-08-28) no bindists for Alpine Linux (`AArch64`). -Therefore, always use options `--no-install-ghc --system-ghc` with stack. +Therefore, flags `--system-ghc` and `--no-install-ghc` are set system-wide in +`/etc/stack/config.yaml`. ## Usage @@ -21,22 +22,35 @@ For use with Github Codespaces, please follow the instruction at For local/'remote host' usage with VS Code, please follow the instructions at [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers). -:information_source: Choose `Manually via PATH` when asked the following -question: +## Install pandoc -manageHLS - -## Installing pandoc - -Addendum to [Installing pandoc > Compiling from source > Quick stack method](../INSTALL.md#quick-stack-method): - -Use `stack install --no-install-ghc --system-ghc pandoc-cli` without first -running `stack setup` when building within the Dev Container (for use with -Stack). +### Using cabal Addendum to [Installing pandoc > Compiling from source > Quick cabal method](../INSTALL.md#quick-cabal-method): Use -`cabal build --enable-executable-static --ghc-option=-optl=-pthread pandoc-cli` -to build a *statically linked* `pandoc` executable that can run on any Linux +`cabal build --ghc-options '-static -optl-static -optl-pthread' pandoc-cli` to +build a *statically linked* `pandoc` executable that can run on any Linux machine of the same architecture. + +### Using stack + +See [Installing pandoc > Compiling from source > Quick stack method](../INSTALL.md#quick-stack-method) + +You may try +`stack build --ghc-options '-static -optl-static -optl-pthread' pandoc-cli` to +build a *statically linked* `pandoc` executable. +:information_source: This works on Alpine Linux/AArch64 but not x86_64[^1]. + +[^1]: Most likely due to a bug in the GCC toolchain on Linux/x86_64 that was +never fixed. See +[Bug #640734 “crtbeginT.o needs to be recompiled with -fPIC” : Bugs : gcc-4.4 package : Ubuntu](https://bugs.launchpad.net/ubuntu/+source/gcc-4.4/+bug/640734) +and +[gcc - Haskell Stack Static Binary relocation R_X86_64_32 against `TMC_END' can not be used when making a shared object - Stack Overflow](https://stackoverflow.com/questions/41419102/haskell-stack-static-binary-relocation-r-x86-64-32-against-tmc-end-can-not/41427067) +for more information. + +## Haskell Language Server (HLS) + +Choose `Manually via PATH` when asked the following question: + +manageHLS diff --git a/.devcontainer/assets/manageHLS.png b/.devcontainer/assets/screenshots/manageHLS.png similarity index 100% rename from .devcontainer/assets/manageHLS.png rename to .devcontainer/assets/screenshots/manageHLS.png diff --git a/.devcontainer/conf/etc/stack/config.yaml b/.devcontainer/conf/etc/stack/config.yaml new file mode 100644 index 0000000000000..37c999c3d6e1f --- /dev/null +++ b/.devcontainer/conf/etc/stack/config.yaml @@ -0,0 +1,4 @@ +# Use only the GHC available on the PATH +system-ghc: true +# Do not automatically install GHC when necessary +install-ghc: false diff --git a/.devcontainer/scripts/fix-chsh.sh b/.devcontainer/scripts/usr/local/bin/fix-chsh.sh similarity index 100% rename from .devcontainer/scripts/fix-chsh.sh rename to .devcontainer/scripts/usr/local/bin/fix-chsh.sh diff --git a/.devcontainer/scripts/onCreateCommand.sh b/.devcontainer/scripts/usr/local/bin/onCreateCommand.sh similarity index 100% rename from .devcontainer/scripts/onCreateCommand.sh rename to .devcontainer/scripts/usr/local/bin/onCreateCommand.sh