From f6edde944e73ada7eb4965bd2ece381f3e2a47bc Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 1 Mar 2021 19:29:41 -0800 Subject: Add lowmem flag. This disables optimizations in select modules that cause problems compiling in lower memory environments. (LaTeX reader, LaTeX and Markdown writers) Performance is 10x slower for reading LaTeX, 20% slower for writing Markdown and LaTeX. --- INSTALL.md | 8 ++++++-- pandoc.cabal | 8 ++++++++ src/Text/Pandoc/Readers/LaTeX.hs | 3 +++ src/Text/Pandoc/Writers/LaTeX.hs | 4 ++++ src/Text/Pandoc/Writers/Markdown.hs | 4 ++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index d23c349c1..80bf9f4da 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -296,8 +296,12 @@ You will need cabal version 2.0 or higher. - `embed_data_files`: embed all data files into the binary (default no). This is helpful if you want to create a relocatable binary. - - `https`: enable support for downloading resources over https - (using the `http-client` and `http-client-tls` libraries). + - `lowmem`: disable optimization on a few modules that take + a lot of memory to compile. Use this flag if compiling + pandoc fails with out of memory errors. + + - `trypandoc`: build the `trypandoc` executable (a CGI web + app). 3. Build: diff --git a/pandoc.cabal b/pandoc.cabal index ad325ee24..b588c5714 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -392,6 +392,12 @@ flag embed_data_files Description: Embed data files in binary for relocatable executable. Default: False +flag lowmem + Description: Disable optimization on three modules that need a lot + of memory to compile. Set this flag if your pandoc + build is failing due to out of memory errors. + Default: False + flag trypandoc Description: Build trypandoc cgi executable. Default: False @@ -505,6 +511,8 @@ library if flag(embed_data_files) cpp-options: -DEMBED_DATA_FILES other-modules: Text.Pandoc.Data + if flag(lowmem) + cpp-options: -DLOWMEM hs-source-dirs: src exposed-modules: Text.Pandoc, diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index fc85f0545..2d5d57ae2 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1,4 +1,7 @@ {-# LANGUAGE CPP #-} +#ifdef LOWMEM +{-# OPTIONS_GHC -O0 #-} +#endif {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-} diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index e31ec9d52..4a359203f 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -1,3 +1,7 @@ +{-# LANGUAGE CPP #-} +#ifdef LOWMEM +{-# OPTIONS_GHC -O0 #-} +#endif {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE PatternGuards #-} diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index d33246a63..e3725bcf9 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -1,3 +1,7 @@ +{-# LANGUAGE CPP #-} +#ifdef LOWMEM +{-# OPTIONS_GHC -O0 #-} +#endif {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} -- cgit v1.2.3