Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not build on 32 bit architectures any more #1032

Open
tillea opened this issue Feb 2, 2023 · 15 comments
Open

Does not build on 32 bit architectures any more #1032

tillea opened this issue Feb 2, 2023 · 15 comments

Comments

@tillea
Copy link

tillea commented Feb 2, 2023

Summary:

The 32bit autobuilders of the Debian package all failed to build version 2.21.8 while these succeeded for version 2.21.7.

Description:

There is a full build log for i386 which ends with

make[1]: Entering directory '/<<PKGBUILDDIR>>/src'
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/lib/R/site-library/Rcpp/include' -I'/usr/lib/R/site-library/RcppEigen/include' -I'/usr/lib/R/site-library/BH/include' -I'/usr/lib/R/site-library/StanHeaders/include' -I'/usr/lib/R/site-library/RcppParallel/include'    -fpic  -g -O2 -ffile-prefix-map=/build/r-base-DQneTm/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -ffloat-store -Wdate-time -D_FORTIFY_SOURCE=2  -c Module.cpp -o Module.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/lib/R/site-library/Rcpp/include' -I'/usr/lib/R/site-library/RcppEigen/include' -I'/usr/lib/R/site-library/BH/include' -I'/usr/lib/R/site-library/StanHeaders/include' -I'/usr/lib/R/site-library/RcppParallel/include'    -fpic  -g -O2 -ffile-prefix-map=/build/r-base-DQneTm/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -ffloat-store -Wdate-time -D_FORTIFY_SOURCE=2  -c chains.cpp -o chains.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/lib/R/site-library/Rcpp/include' -I'/usr/lib/R/site-library/RcppEigen/include' -I'/usr/lib/R/site-library/BH/include' -I'/usr/lib/R/site-library/StanHeaders/include' -I'/usr/lib/R/site-library/RcppParallel/include'    -fpic  -g -O2 -ffile-prefix-map=/build/r-base-DQneTm/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -ffloat-store -Wdate-time -D_FORTIFY_SOURCE=2  -c grammar_inst.cpp -o grammar_inst.o

cc1plus: out of memory allocating 32 bytes after a total of 44007424 bytes
make[1]: *** [/usr/lib/R/etc/Makeconf:178: grammar_inst.o] Error 1

Reproducible Steps:

Please try to build in i386 (or armel/armhf).

RStan Version:

2.21.8

R Version:

4.2.2.20221110

Operating System:

Debian unstable

Kind regards, Andreas.

@andrjohns
Copy link
Contributor

According to the log, it's running four parallel build jobs. Is it possible to reduce that in the autobuilders? That would be the easiest way to reduce the amount of memory needed

@tillea
Copy link
Author

tillea commented Feb 2, 2023

I tried to sneak in the option --no-parallel into the Debian Build process on my local system where I'm using an i386 chroot for test builds. It says:

   dh_auto_install --destdir=debian/r-cran-rstan/ -O--buildsystem=R -O--no-parallel
I: R packages needed for DEP8: runit
I: R Package: rstan Version: 2.21.8
I: Building using R version 4.2.2.20221110-2
I: R API version: r-api-4.0
I: Using built-time from d/changelog: Thu, 02 Feb 2023 11:30:39 +0100
    mkdir -p /build/r-cran-rstan-2.21.8/debian/r-cran-rstan/usr/lib/R/site-library
    R CMD INSTALL -l /build/r-cran-rstan-2.21.8/debian/r-cran-rstan/usr/lib/R/site-library --clean . "--built-timestamp='Thu, 02 Feb 2023 11:30:39 +0100'"
* installing *source* package 'rstan' ...
files 'DESCRIPTION', 'R/plugin.R' have the wrong MD5 checksums
** using staged installation
** libs
make[1]: Entering directory '/build/r-cran-rstan-2.21.8/src'
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -     DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/lib/R/site-library/Rcpp/include' -I'/usr/lib/R/site-library/RcppEigen/include' -I'/usr/lib/R/site-library/BH/include' -I'/usr/   lib/R/site-library/StanHeaders/include' -I'/usr/lib/R/site-library/RcppParallel/include'    -fpic  -g -O2 -ffile-prefix-map=/build/r-base-DQneTm/r-base-4.2.2.20221110=. -fstack-         protector-strong -Wformat -Werror=format-security -ffloat-store -Wdate-time -D_FORTIFY_SOURCE=2  -c Module.cpp -o Module.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -     DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/lib/R/site-library/Rcpp/include' -I'/usr/lib/R/site-library/RcppEigen/include' -I'/usr/lib/R/site-library/BH/include' -I'/usr/   lib/R/site-library/StanHeaders/include' -I'/usr/lib/R/site-library/RcppParallel/include'    -fpic  -g -O2 -ffile-prefix-map=/build/r-base-DQneTm/r-base-4.2.2.20221110=. -fstack-         protector-strong -Wformat -Werror=format-security -ffloat-store -Wdate-time -D_FORTIFY_SOURCE=2  -c chains.cpp -o chains.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -     DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/lib/R/site-library/Rcpp/include' -I'/usr/lib/R/site-library/RcppEigen/include' -I'/usr/lib/R/site-library/BH/include' -I'/usr/   lib/R/site-library/StanHeaders/include' -I'/usr/lib/R/site-library/RcppParallel/include'    -fpic  -g -O2 -ffile-prefix-map=/build/r-base-DQneTm/r-base-4.2.2.20221110=. -fstack-         protector-strong -Wformat -Werror=format-security -ffloat-store -Wdate-time -D_FORTIFY_SOURCE=2  -c grammar_inst.cpp -o grammar_inst.o
virtual memory exhausted: Operation not permitted
make[1]: *** [/usr/lib/R/etc/Makeconf:178: grammar_inst.o] Error 1
make[1]: Leaving directory '/build/r-cran-rstan-2.21.8/src'
make[1]: Entering directory '/build/r-cran-rstan-2.21.8/src'
make[1]: Leaving directory '/build/r-cran-rstan-2.21.8/src'
ERROR: compilation failed for package 'rstan'
* removing '/build/r-cran-rstan-2.21.8/debian/r-cran-rstan/usr/lib/R/site-library/rstan'
dh_auto_install: error: R CMD INSTALL -l /build/r-cran-rstan-2.21.8/debian/r-cran-rstan/usr/lib/R/site-library --clean . "--built-timestamp='Thu, 02 Feb 2023 11:30:39 +0100'"        returned exit code 1

Kind regards and thanks a lot for your quick response, Andreas.

@tillea
Copy link
Author

tillea commented Feb 8, 2023

Any further ideas? Otherwise I'd restrict the build to 64bit architectures.

@andrjohns
Copy link
Contributor

Sorry about the delay, I'll be able to test this locally today and will see what a fix could be

@glin
Copy link

glin commented Feb 8, 2023

I'm running into a similar issue with the 32-bit build of rstan 2.21.8 on Windows R 4.1 and below, and CRAN is as well: https://www.r-project.org/nosvn/R.check/r-oldrel-windows-ix86+x86_64/rstan-00install.html. The error is always cc1plus.exe: out of memory allocating 65536 bytes:

...
d:/Compiler/rtools40/mingw32/bin/g++  -std=gnu++14 -I"D:/RCompile/recent/R-4.1.3/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1 -I'd:/RCompile/CRANpkg/lib/4.1/Rcpp/include' -I'd:/RCompile/CRANpkg/lib/4.1/RcppEigen/include' -I'd:/RCompile/CRANpkg/lib/4.1/BH/include' -I'd:/RCompile/CRANpkg/lib/4.1/StanHeaders/include' -I'd:/RCompile/CRANpkg/lib/4.1/RcppParallel/include'   -I"d:/Compiler/gcc-4.9.3/local330/include"  -DRCPP_PARALLEL_USE_TBB=1   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c grammar_inst.cpp -o grammar_inst.o
In file included from d:/RCompile/CRANpkg/lib/4.1/BH/include/boost/mpl/aux_/na_assert.hpp:23,
                 from d:/RCompile/CRANpkg/lib/4.1/BH/include/boost/mpl/arg.hpp:25,
                 from d:/RCompile/CRANpkg/lib/4.1/BH/include/boost/variant/variant_fwd.hpp:19,
                 from d:/RCompile/CRANpkg/lib/4.1/BH/include/boost/variant/recursive_variant.hpp:16,
                 from ./stan/lang/ast/node/expression.hpp:4,
                 from ./stan/lang/ast/type/bare_expr_type.hpp:4,
                 from ./stan/lang/ast/variable_map.hpp:5,
                 from ./stan/lang/ast.hpp:7,
                 from ./stan/lang/grammars/bare_type_grammar_def.hpp:4,
                 from grammar_inst.cpp:1:
d:/RCompile/CRANpkg/lib/4.1/BH/include/boost/mpl/assert.hpp:194:21: warning: unnecessary parentheses in declaration of 'assert_arg' [-Wparentheses]
 failed ************ (Pred::************
                     ^
d:/RCompile/CRANpkg/lib/4.1/BH/include/boost/mpl/assert.hpp:199:21: warning: unnecessary parentheses in declaration of 'assert_not_arg' [-Wparentheses]
 failed ************ (boost::mpl::not_<Pred>::************
                     ^
In file included from ./stan/lang/grammars/bare_type_grammar_def.hpp:8,
                 from grammar_inst.cpp:1:
d:/RCompile/CRANpkg/lib/4.1/BH/include/boost/spirit/include/phoenix_core.hpp:12:51: note: #pragma message: This header is deprecated. Use <boost/phoenix/core.hpp> instead.
 BOOST_HEADER_DEPRECATED("<boost/phoenix/core.hpp>")
                                                   ^

cc1plus.exe: out of memory allocating 65536 bytes
make[1]: *** [D:/RCompile/recent/R-4.1.3/etc/i386/Makeconf:245: grammar_inst.o] Error 1
make[1]: Leaving directory '/d/temp/RtmpiQHI0S/R.INSTALLe46850506192/rstan/src-i386'
ERROR: compilation failed for package 'rstan'

It looks like rstan is now bumping against the 2/4 GB memory limit with 32-bit platforms (at least on Windows). Successful workarounds I've tried so far are to:

  1. Build rstan for 64-bit only using the --no-multiarch on Windows R <= 4.1. (Support for 32-bit is dropped since R 4.2 on Windows)
  2. Modify the 32-bit cc1plus.exe from Rtools to be large address aware. I found this option first from googling, https://www.intel.com/content/www/us/en/support/programmable/articles/000086946.html. You need editbin from the MSVC build tools first, and then you can run something like this against your Rtools installation:
editbin /LARGEADDRESSAWARE "C:\rtools40\mingw32\lib\gcc\i686-w64-mingw32\8.3.0\cc1plus.exe"

I got rstan to build for 32-bit after this, but it feels like a sketchier workaround. Perhaps the older Rtools could get cc1plus.exe built with the large address aware flag, but I'm not sure how feasible that is.

@andrjohns
Copy link
Contributor

The culprit here is the src/grammar_inst.cpp file, which has several thousand lines of code to be compiled. A workaround here is to split the file into smaller parts, so that the compiler has less to deal with. But I'm not sure if this something that we would want to update for the current CRAN version, if we're hoping to obsolete it.

@bgoodri thoughts?

@bgoodri
Copy link
Contributor

bgoodri commented Feb 9, 2023 via email

@barracuda156
Copy link

@tillea I have built rstan 2.21.8 for ppc32. This seems to be Intel issue, not 32-bit issue.

@bgoodri That does not work for every platform though (I think on ppc LTO is broken – i.e., does nothing).

@tillea
Copy link
Author

tillea commented Mar 1, 2023

The Debian autobuilders matrix shows failures for armel, armhf, i386, mipsel, sh4, x32 and powerpc (latest should be what you call ppc32). On the other hand it also fails for alpha and ia64 - however with different failure. So we have issues for all 32bit architectures on the Debian autobuilders (may be there is some specific setup I'm not aware of) and other build issues on some not so common 64bit processors but with different error.
We need to find some solution on this issue soon since Debian is in freeze policy.

@tillea
Copy link
Author

tillea commented Mar 1, 2023

It will probably still build on 32bit machines if you can add -flto to the compiler flags to utilize Link Time Optimization. That should keep the intermediate files below the address space limit.

I tried this but failed (and my mail about this did not make it here to the issue tracker unfortunately).

@barracuda156
Copy link

latest should be what you call ppc32

Well, the arch name is ppc, I added 32 just to keep it explicit.

@bgoodri
Copy link
Contributor

bgoodri commented Mar 7, 2023

If bookworm is going to use a version of Boost that is less than the BH 1.81 which is on CRAN, then you could get the previous version of r-cran-rstan under the freeze. In the version of rstan on CRAN, I just changed the compilation to deal with linker errors induced by Boost 1.81, but that apparently induced different errors on 32bit architectures.

@barracuda156
Copy link

barracuda156 commented Mar 7, 2023

@bgoodri If you refer to CRAN version of rstan, could you say what specifically fails for 32-bit archs?

P. S. Noticed that I used BH 1.78, updated now, rebuilding rstan for PPC, gonna report upon result.

UPD. Yes, rstan builds fine for 32 bit with BH 1.81.

@barracuda156
Copy link

Not only it builds, but it also works (a quick random demo from online, sampling and graphics work fine):
Rstan_powerpc

@tillea
Copy link
Author

tillea commented Mar 8, 2023

If bookworm is going to use a version of Boost that is less than the BH 1.81 which is on CRAN, then you could get the previous version of r-cran-rstan under the freeze. In the version of rstan on CRAN, I just changed the compilation to deal with linker errors induced by Boost 1.81, but that apparently induced different errors on 32bit architectures.

So I think part of the solution of this issue should be

diff --git a/DESCRIPTION b/DESCRIPTION
index d6c3b7c..ddd8479 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -35,7 +35,7 @@ Imports: methods, stats4, inline, gridExtra (>= 2.0.0), Rcpp (>=
         0.12.0), RcppParallel (>= 5.0.1), loo (>= 2.3.0), pkgbuild
 Depends: R (>= 3.4.0), StanHeaders (>= 2.21.0), ggplot2 (>= 3.0.0)
 LinkingTo: Rcpp (>= 0.12.0), RcppEigen (>= 0.3.3.3.0), BH (>=
-        1.72.0-2), StanHeaders (>= 2.21.0), RcppParallel
+        1.81), StanHeaders (>= 2.21.0), RcppParallel
 Suggests: RUnit, RcppEigen (>= 0.3.3.3.0), BH (>= 1.72.0-2), parallel,
         KernSmooth, shinystan (>= 2.3.0), bayesplot (>= 1.5.0),
         rmarkdown, rstantools, rstudioapi, Matrix, knitr (>= 1.15.1),

Kind regards, Andreas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants