rwinlib / gcc-4.9.3

Building R for Windows with the new gcc 4.9.3 toolchain
28 stars 7 forks source link

Rcpp dates #1

Closed jeroen closed 8 years ago

jeroen commented 9 years ago

See https://github.com/RcppCore/Rcpp/issues/359. Only appears on win64.

jeroen commented 9 years ago

It looks like this bug is a side effect of -mno-sse.

aadler commented 9 years ago

I've built R-patched_2015-08-27 with your 4.9.3 toolchain, only passing mtune=ivybridge but no march, which should prevent msse from being thrown, since that requires at least march=pentium3 believe. I still do not get an error.

> library(Rcpp)
> setwd('C:/R')
> sourceCpp('Rcpptest.cpp')
> ctor_mdy()
[1] "2005-12-31"
> ctor_ymd()
[1] "2005-12-31"
> sessionInfo()
R version 3.2.2 Patched (2015-08-27 r69201)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Rcpp_0.12.0

loaded via a namespace (and not attached):
[1] tools_3.2.2
> 

Rcpp compiled using std=gnu++11 (CXXFLAGS = -std=gnu++11 -O2 -mtune=ivybridge -pipe)

How have you compiled R to get that error? Perhaps we should compare Mkrules.local?

Also, can you link me to the Rf_error you referenced in R-sig-windows? I did not throw -fno-asynchronous-unwind-tables so I'd like to test and see if I do not get that error either.

jeroen commented 9 years ago

Sure, try this:

devtools::install_github("kevinushey/RToolsTest")
library(RToolsTest)
ouch()

This should throw an error, but without -fno-asynchronous-unwind-table this causes a freeze.

jeroen commented 9 years ago

@aadler any luck? Are you on gchat btw?

aadler commented 9 years ago

Had to install devtools. Seems running ouch seems to have frozen R.

Gchat is blocked by corporate firewall, sorry.

I get Error in ouch(): ouch and then a frozen screen

jeroen commented 9 years ago

Can you try to recompile with -fno-asynchronous-unwind-table in your CXXFLAGS and see if you can pass the Rcpp unit tests?

aadler commented 9 years ago

Sure; it will take some time, though.

aadler commented 9 years ago

Compilation fails. The only difference between last time and this is adding -fno-asynchronous-unwind-tables to Makvares and EOPTS.

gcc -m64 -shared -s -static-libgcc -o tools.dll tmp.def text.o init.o Rmd5.o md5
.o signals.o install.o getfmts.o http.o gramLatex.o gramRd.o ../../../gnuwin32/d
llversion.o -LC:/R/RLocalSoft/extsoft/lib/x64 -LC:/R/RLocalSoft/extsoft/lib -L..
/../../../bin/x64 -lR
installing 'sysdata.rda'
make[4]: *** [sysdata] Error 127
make[3]: *** [all] Error 2
make[2]: *** [R] Error 1
make[1]: *** [all] Error 2
make: *** [distribution] Error 2
jeroen commented 9 years ago

Yes you should only add it to CXXFLAGS in /src/gnuwin32/fixed/etc/Makeconf. Honestly I don't really know why it doesn't work for EOPTS. Windows is so weird.

aadler commented 9 years ago

Weird error;

* installing *source* package 'Rcpp' ...
** package 'Rcpp' successfully unpacked and MD5 sums checked
** libs
g++ -m64 -I"C:/R/R-PATC~2/include" -DNDEBUG -I../inst/include/    -I"C:/R/RLocalSoft/extsoft/include"     -std=gnu++11 -fno-asynchronous-unwind-tables -O2 -mtune=ivybridge -pipe -c Date.cpp -o Date.o
Date.cpp:1:0: error: bad value (ivybridge) for -mtune= switch
 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
 ^
make: *** [Date.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-PATC~2/etc/x64/Makeconf" -f "C:/R/R-PATC~2/share/make/winshlib.mk" -f "\\na.ad.guycarp.com\US_Users\MOR\AADLER00/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="Rcpp.dll" WIN=64 TCLBIN=64 OBJECTS="Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o"' had status 2
ERROR: compilation failed for package 'Rcpp'
* removing 'C:/R/R-patched/library/Rcpp'

The downloaded source packages are in
        ‘C:\R\temp\RtmpuUEZxi\downloaded_packages’
Warning messages:
1: running command '"C:/R/R-patched/bin/x64/R" CMD INSTALL --byte-compile -l "C:\R\R-patched\library" C:\R\temp\RtmpuUEZxi/downloaded_packages/Rcpp_0.12.0.tar.gz' had status 1 
2: In install.packages("Rcpp", type = "source", INSTALL_opts = "--byte-compile") :
  installation of package ‘Rcpp’ had non-zero exit status
aadler commented 9 years ago

Even removing mtune=ivybridge it from Makevars doesn't help as stringi calls EOPTS. I'll have to re-compile with no tuning. The error itself is troubling, as "mtune=ivybridge" is certainly valid under GCC 4.9.2/3, and I've compiled that way a dozen times.

aadler commented 9 years ago

BTW, have you tried building your toolchain with THIS build: x86_64-4.9.3-release-win32-sjlj-rt_v4-rev0 instead of the v3?

jeroen commented 9 years ago

Yes, the last time we tried v4 had even bigger issues than v3.

aadler commented 9 years ago

Leaving out all tune parameters, I can get Rcpp and devtools to compile, passing no-asynchronous to CXXFLAGS in gnuwin32/fixed/etc/Makconf.

Howvever, RToolsTest fails now!

> devtools::install_github("kevinushey/RToolsTest")
Downloading github repo kevinushey/RToolsTest@master
Installing RToolsTest
"C:/R/R-patched/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL "C:/R/temp/RtmpAtnmH5/devtools1ab81bf34955/kevinushey-RToolsTest-ffafe82"  \
  --library="C:/R/R-patched/library" --install-tests 

* installing *source* package 'RToolsTest' ...
** libs
g++ -m64 -I"C:/R/R-PATC~2/include" -DNDEBUG     -I"C:/R/RLocalSoft/extsoft/include"     -std=gnu++11 -O2 -pipe -c test.cpp -o test.o
cc1plus.exe: error: unrecognized command line option '-std=gnu++11'
make: *** [test.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-PATC~2/etc/x64/Makeconf" -f "C:/R/R-PATC~2/share/make/winshlib.mk" -f "\[REDACTED]/.R/Makevars" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="RToolsTest.dll" WIN=64 TCLBIN=64 OBJECTS="test.o"' had status 2
ERROR: compilation failed for package 'RToolsTest'
* removing 'C:/R/R-patched/library/RToolsTest'
Error: Command failed (1)
aadler commented 9 years ago

I'm getting that Rcpp error under a "vanilla" install as well. I'm wondering if something changed https://github.com/hadley/dplyr/issues/1368#issuecomment-136438848

kevinushey commented 9 years ago

I doubt that dplyr / Rcpp would affect the ability of the installed gcc to understand the ivybridge flag. More likely it's an artefact of how the toolchain / gcc was built, or perhaps a weird interaction with -std=gnu++11.

aadler commented 9 years ago

You're probably right. I'm going to rebuild with @jeroenooms 4.92 toolchain (119MB version), and if THAT doesn't work, the smaller 4.9.2 toolchain from last week. Sorry about the spam :(

aadler commented 9 years ago

Rcpp installs fine with EOPTS = -mtune=ivybridge -pipe using the 4.9.2 (119MB) toolchain on @jeroenooms website. There must be a problem with the 4.9.3 toolchain.

jeroen commented 9 years ago

Hmm I can do another build with 4.9.2, but so far (using the standard build flags) I have not noticed any differences between gcc versions.

aadler commented 9 years ago

devtools install_github and install_bitbucket both return those unrecognized gnu++11 and ivybridge issues. I tried installing my Delaporte package from bitbucket and it failed the same way, but installing from CRAN had no issues.

kevinushey commented 9 years ago

Oh, could it be a PATH issue? Maybe older / wrong versions of gcc and friends are getting picked up.

It's also possible that devtools is putting an older, wrong version of Rtools on the PATH before install.