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
Opaque terminal messages during compilation using rtools40 and Eigen functions #321
Comments
Majority of these warnings seems to be
? (Add more |
Thanks Kasper! That eliminated all of those opaque and extraneous messages, leaving only the terminal messages that I expected based on previous versions. I also confirmed that, if I introduced an intentional error, it still displayed that error appropriately in the terminal. Case closed :) |
@kaskr I ran into the same wall of warnings so took your advice. However this causes pretty noticeable differences in the compilation, besides just suppressing output. The size of the .o and .dll files are different. I have a simple spatial model where if I compile without the flag, both .o and .dll files are about 13MB. If I turn on the flag, the .o file is 34MB and it never creates the .dll -- at least after 15 or 20 minutes. I was expecting this to simply suppress output but it's clearly doing more. Could you advise on what's going on here and whether there is another solution? To reproduce I took this model
and saved as both test1.cpp and test2.cpp (identical files). Then I compiled like
and the output files are
where the 3rd column gives disk size. Console output looks like this:
with
|
@Cole-Monnahan-NOAA that's crazy! Similar results with R-devel/Ubuntu 20.10. Can you pipe your output through
|
You mean like this?
|
I was thinking about running compilation from the shell, where p <- pipe("egrep -v \"ignor|required\"")
open(p)
sink(p,type="message")
unlink("test1.so")
unlink("test1.o")
TMB::compile("test1.cpp")
sink(type="message")
close(p) but I haven't got the incantation right to capture the output stream from |
@bbolker I also failed at pipe ninja'ing so just copied the R console output into a text file then Very curious to see what Kasper says, or someone more familiar with C++ compilers. |
See my 17 Feb 2021 comments on Issue #277. |
@John-R-Wallace-NOAA comment is that when invoking that flag it changes other flags. I confirmed that if I run
it does indeed suppress the warnings but provides the same output files as without it. So this is a good solution for one-off cases like mine. Thanks and sharp eyes @John-R-Wallace-NOAA @bbolker does that work for you as well? |
@kaskr Would you consider making this flag the default in TMB? I recently taught some folks TMB and there were so many of these warnings in RStudio that the actual error messages were bumped off console completely and they couldn't see them. It worked to add this flag but seems unnecessary and is pretty opaque. |
Unfortunately this can't be made the default for the CRAN version of the package - CRAN simply won't accept these flags. One possibility, if @kaskr felt it was worth the trouble, would be to incorporate it in the GitHub version of the package but strip it out every time the package was uploaded to CRAN. That way you could tell users to Or TMB could include a helper function to add the appropriate flags to a user's silence_warnings <- function() {
p <- readline("Please confirm that it's OK to create and/or modify your ~/R/.Makevars file to suppress TMB compilation warnings (Y/n): ")
if (!toupper(p) == "Y") return(invisible(NULL))
if (!file.exists("~/.R/Makevars")) {
message("creating ~/.R/Makevars")
file.create("~/.R/Makevars")
}
cat([STUFF], "~/.R/Makevars", append = TRUE)
} |
The Alternatively, we could let |
personally, I think editing |
No strong feelings either way, as long as modifying |
If these are warnings users should never see then I I also vote for making it the default in |
After finally fully understanding the cause of these excess warnings, I have eliminated them with a single line of code. |
@John-R-Wallace-NOAA Seems you came across an important fact left out of this thread: The github version of TMB does not have the issue with warnings from Eigen - only the CRAN version has the problem. Your idea about setting the flag depending on Unfortunately, having solved the problem on Windows does not ensure general portability. |
@kaskr so do you suggest we adopt a I can see the headache of platform specific flags. But presumably most of the TMB user base installs from CRAN and uses Rtools4 on Windows. Being able to clearly see the error messages is a pretty important function. So I think trying to find a solution is still a good idea. |
@kaskr Is the -Wno-ignored-attributes flag added for Ubuntu because it is broken otherwise? (I only have Cent-OS (ver 7) available to try, which I should have mentioned in my TMB fork.) What about adding -Wno-ignored-attributes in the same way for Windows/gcc combination, even though it is not strictly broken otherwise? The -Wno-ignored-attributes would then be added for both the GitHub and CRAN installations under Windows/gcc, even though it is only needed for the more common CRAN installation. |
I agree |
- Adds option to conditionally include DisableStupidWarnings.h - Copied recent version from Eigen main branch: Eigen/src/Core/util/DisableStupidWarnings.h - File renamed to by-pass a CRAN note - File excluded from TMB doxygen - cran-version modified to build 'simple' example without illegal flag
Hopefully portable solution now on master branch. In case you feel like testing:
|
Latest master branch pulled down and installed, deleted Eigen folder. Compiled simple.cpp with flag TRUE and FALSE. FALSE leads to the giant array of warnings as mentioned previously. TRUE results is below. Reduces maybe 95% of warnings but not all. If I repeat this but do not delete the Eigen folder then TRUE works fine. Output without Eigen folder:
Output with Eigen folder:
|
@Cole-Monnahan-NOAA I have only seen the '-Waggressive-loop-optimizations' warning when compiling 'simple.cpp', presumably because it is too simple. Use '-Wno-aggressive-loop-optimizations' in flags to remove:
Otherwise the new 'eigen.disable.warnings' argument is working fine (here with 'linreg_parallel.cpp'):
Thanks for the new flag @kaskr. Are there differences between using the Eigen library versus the RcppEigen package? Since the compile()'s help says that this new flag is not allowed for code to be compiled on CRAN, I will repeat below the information that is on my TMB fork related to this issue. Using the '-w' flag (note the lower case) in the flags argument of compile() will remove all warnings, e.g.:
Of course, such a global removal of warnings needs to be used with caution. |
@John-R-Wallace-NOAA and @Cole-Monnahan-NOAA thanks for testing - I can actually reproduce. I'll have to leave this for now but will get back to it.
Should only be a matter of the Eigen version. The version shipping with TMB github is eigen-3.4. The current version with RcppEigen is eigen-3.3 (I think). That might explain the unexpected extra warnings with the simple example, because one could hope that these warnings have been fixed in 3.4 in a cleaner way than by disabling. |
@John-R-Wallace-NOAA @Cole-Monnahan-NOAA It seems to be working now. I'll probably submit to CRAN sometime next week. |
@kaskr Looking forward to seeing that. Let me know if I can help test again. |
@Cole-Monnahan-NOAA Would be great if you could run the same tests again and hopefully confirm that it works on Windows! |
I will also test again. |
Confirmed this works on Win10 using latest master branch pull. Default to compile the simple example produced only the expected output. This is great thanks @kaskr |
I renamed the '...\include\Eigen' folder and saw the RcppEigen package is being used with no excess warnings. @kaskr, I see the added flag '-DTMB_EIGEN_DISABLE_WARNINGS' has been added which I assume works with 'DisableStupidWarnings.h', but how are you eliminating the aggressive loop optimizations warnings in the simple example? |
@John-R-Wallace-NOAA and @Cole-Monnahan-NOAA thanks for testing. This is now on CRAN.
was a bit more tricky - see commit f08ff4f |
Description:
I'm testing package VAST using R version 4.0.2, which uses rtools40 on Windows OS. Compiling any TMB CPP for package VAST using rtools40 (e.g., "VAST_v1_0_0.cpp" here) now results in a long series of compiler messages, where these messages did not occur using earlier R/rtools versions. Despite these messages, the compiler finishes successfully, and the compiled program passes all existing VAST integrated-tests (so it appears to be working correctly, except for this terminal output).
I have tried following Kasper's previous advice in eliminating needless compiler messages and therefore welcome any help eliminating these unnecessary and confusing messages.
Reproducible Steps:
To reproduce, please clone/download VAST, and compile "VAST_v1_0_0.cpp" here) using R 4.0.2 on a Windows machine (I assume it would work with other R 4.X.X. versions using rtools40).
Current Output:
A long series of compiler messages, e.g.
but hundreds of lines longer.
Expected Output:
If applicable, the output you expected from TMB.
TMB Version:
1.7.18
R Version:
R version 4.0.2 (2020-06-22)
Operating System:
Windows 10.
The text was updated successfully, but these errors were encountered: