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

[R-package] use C++ compiler for pre-compile checks on Windows #4504

Merged
merged 9 commits into from
Aug 14, 2021

Conversation

jameslamb
Copy link
Collaborator

Looking into #4131 as part of #4310, I've noticed some other areas for possible improvement in the configure and configure.win scripts.

This PR fixes one in configure.win. I noticed that the mm_prefetch and mm_malloc tests are being run with a C compiler on Windows. They should be done with a C++ compiler, as they are on Linux/Mac

AC_LANG(C++)

and for all CMake-based builds

check_cxx_source_compiles("

I'm not aware of any problems caused by the fact that these checks were being done by a C compiler, but a C++ compiler is going to be used for compiling lib_lightgbm.

Notes for Reviewers

To understand the difference between CXXFLAGS and CPPFLAGS and why they are both included, see the documentation from R CMD config.

CPPFLAGS C/C++ preprocessor flags, e.g. -I<dir> if you have headers in a nonstandard directory <dir>
CXXFLAGS compiler flags for CXX

@jameslamb jameslamb added the fix label Aug 9, 2021
@jameslamb jameslamb requested a review from StrikerRUS August 9, 2021 02:13
@jameslamb jameslamb requested a review from Laurae2 as a code owner August 9, 2021 02:13
@jameslamb
Copy link
Collaborator Author

I'm seeing several errors in CI today about connecting to GitHub.

For example, from an R package job: https://github.com/microsoft/LightGBM/pull/4504/checks?check_run_id=3282998279

  "C:\Program Files\Git\bin\git.exe" -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=5 origin +d08d1f3c51a3f4876ca39d591097269b68cc9bc3:refs/remotes/pull/4504/merge
  Error: fatal: unable to access 'https://github.com/microsoft/LightGBM/': Failed to connect to github.com port 443: Timed out
  The process 'C:\Program Files\Git\bin\git.exe' failed with exit code 128
  Waiting 11 seconds before trying again
  "C:\Program Files\Git\bin\git.exe" -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=5 origin +d08d1f3c51a3f4876ca39d591097269b68cc9bc3:refs/remotes/pull/4504/merge
  Error: fatal: unable to access 'https://github.com/microsoft/LightGBM/': Failed to connect to github.com port 443: Timed out
  The process 'C:\Program Files\Git\bin\git.exe' failed with exit code 128
  Waiting 14 seconds before trying again
  "C:\Program Files\Git\bin\git.exe" -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=5 origin +d08d1f3c51a3f4876ca39d591097269b68cc9bc3:refs/remotes/pull/4504/merge
  Error: fatal: unable to access 'https://github.com/microsoft/LightGBM/': Failed to connect to github.com port 443: Timed out
  Error: The process 'C:\Program Files\Git\bin\git.exe' failed with exit code 128

And a Python-package job: https://github.com/microsoft/LightGBM/pull/4504/checks?check_run_id=3282997602

  Submodule path 'external_libs/fast_double_parser': checked out 'ace60646c02dc54c57f19d644e49a61e7e7758ec'
  Error: fatal: unable to access 'https://github.com/fmtlib/fmt.git/': Failed to connect to github.com port 443: Operation timed out
  Fetched in submodule path 'external_libs/fmt', but it did not contain cc09f1a6798c085c325569ef466bcdcffdc266d4. Direct fetching of that commit failed.
  Error: The process '/usr/local/bin/git' failed with exit code 1

It does not seem like there were any incidents on GitHub today (https://www.githubstatus.com/history). Azure is not reporting any recent incidents either (https://status.azure.com/en-us/status/history/).

I'm not sure what's happening :/

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Aug 10, 2021

/gha run r-solaris

Workflow Solaris CRAN check has been triggered! 🚀
https://github.com/microsoft/LightGBM/actions/runs/1116581396

solaris-x86-patched: https://builder.r-hub.io/status/lightgbm_3.2.1.99.tar.gz-8fbce35a96824fd9bc025ca6079ab602
solaris-x86-patched-ods: https://builder.r-hub.io/status/lightgbm_3.2.1.99.tar.gz-7f6f062abb6744b789eaa3dcd31cd71a
Reports also have been sent to LightGBM public e-mail: http://www.yopmail.com/lightgbm_rhub_checks
Status: success ✔️.

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Aug 10, 2021

/gha run r-valgrind

Workflow R valgrind tests has been triggered! 🚀
https://github.com/microsoft/LightGBM/actions/runs/1116582111

Status: failure ❌.

@jameslamb
Copy link
Collaborator Author

jameslamb commented Aug 10, 2021

/gha run r-valgrind

Workflow R valgrind tests has been triggered! 🚀
https://github.com/microsoft/LightGBM/actions/runs/1116855777

Status: success ✔️.

@jameslamb
Copy link
Collaborator Author

Just pushed 4884a69, adding {Matrix} to the setup for the valgrind tests. It is an Imports-level dependency so it should be installed. Maybe one of the other dependencies was introducing it before and that's why it was ok for us to not explicitly install.packages() it.

@jameslamb
Copy link
Collaborator Author

Installing {Matrix} seemed to fix the failures in the valgrind job!

#4504 (comment)

@StrikerRUS
Copy link
Collaborator

Should we add Matrix in other places for the consistency, e.g. in config for sanitizers or debian clang?

@jameslamb
Copy link
Collaborator Author

Should we add Matrix in other places for the consistency, e.g. in config for sanitizers or debian clang?

I think so, yeah. I'll be away from my computer for a few hours. You can push a commit here directly if you'd like, otherwise I'll do it later tonight.

@jameslamb
Copy link
Collaborator Author

Added {Matrix} explicitly in the other places where we install R dependencies: b43b6c7

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good sign in Windows jobs!

checking whether MM_PREFETCH works...yes
checking whether MM_MALLOC works...yes

Please check two my questions about consistency with Unix version of configure below

R-package/configure.win Show resolved Hide resolved
@@ -6,7 +6,9 @@
###########################

R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R"
CC=`"${R_EXE}" CMD config CC`
CXX=`"${R_EXE}" CMD config CXX`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use CXX11 for Unix and CXX here to configure CXX variable (considering #4506 as well)??

CXX=`"${R_HOME}/bin/R" CMD config CXX11`

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! thanks for noticing, that is an oversight. It should be CXX11 since we explicitly set a C++ standard

From https://cran.r-project.org/doc/manuals/R-exts.html#Configure-and-cleanup

If the package specifies a non-default C++ standard, use the config variable names (such as CXX17) appropriate to the standard

From R's perspective, our use of C++ is "non-default". See https://cran.r-project.org/doc/manuals/R-exts.html#Using-C_002b_002b-code.

As from R 4.0.0 a C++ compiler will be selected only if it conforms to the 2011 standard (‘C++11’). A minor update43 (‘C++14’) was published in December 2014 and will be used by default as from R 4.1.0 if supported

updated in b576a4f

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we are setting less variables than it's done in the example from https://cran.r-project.org/doc/manuals/R-exts.html#Using-C_002b_002b-code.

CXX11=`"${R_EXE}" CMD config CXX11`
CXX11STD=`"${R_EXE}" CMD config CXX11STD`
CXX="${CXX11} ${CXX11STD}"
CXXFLAGS=`"${R_EXE}" CMD config CXX11FLAGS`
CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS`

Also note that CXX11FLAGS is used to configure CXXFLAGS.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo interesting, I missed that! Thanks for pointing it out. I just made those changes here and on #4506 .

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Aug 14, 2021

/gha run r-valgrind

Workflow R valgrind tests has been triggered! 🚀
https://github.com/microsoft/LightGBM/actions/runs/1130908327

Status: success ✔️.

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Aug 14, 2021

/gha run r-solaris

Workflow Solaris CRAN check has been triggered! 🚀
https://github.com/microsoft/LightGBM/actions/runs/1130908563

solaris-x86-patched: https://builder.r-hub.io/status/lightgbm_3.2.1.99.tar.gz-ffbce948622047e4a07e5e413fcbbb8d
solaris-x86-patched-ods: https://builder.r-hub.io/status/lightgbm_3.2.1.99.tar.gz-381203fd44294e08bc4e13ac3b2d374d
Reports also have been sent to LightGBM public e-mail: http://www.yopmail.com/lightgbm_rhub_checks
Status: success ✔️.

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR! LGTM!

@jameslamb jameslamb merged commit 86ead20 into master Aug 14, 2021
@jameslamb jameslamb deleted the fix/cpp-conftest branch August 14, 2021 19:04
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants