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] [ci] Add Windows CI for R package (fixes #2335) #2936

Merged
merged 93 commits into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from 91 commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
19ed854
first test of appveyor
jameslamb Mar 21, 2020
16476da
strings are strings
jameslamb Mar 21, 2020
f7573f0
lil bit of build script
jameslamb Mar 21, 2020
311d3d8
fixing paths
jameslamb Mar 21, 2020
c422b15
removed unnecessary file
jameslamb Mar 21, 2020
b2fce60
updated CRAN URL
jameslamb Mar 21, 2020
b973b7d
added a lot more printing
jameslamb Mar 21, 2020
a8873f6
fixing paths
jameslamb Mar 21, 2020
952ca55
more stuff
jameslamb Mar 21, 2020
b4cf398
fixed paths
jameslamb Mar 21, 2020
cc6d02b
more stuff
jameslamb Mar 21, 2020
adfb832
more path guessing
jameslamb Mar 21, 2020
92b0032
even more paths
jameslamb Mar 22, 2020
8d77941
more stuff
jameslamb Mar 22, 2020
b7e2abe
moar logz
jameslamb Mar 22, 2020
12fb638
and now for something totally different
jameslamb Mar 22, 2020
1091504
please work
jameslamb Mar 22, 2020
96dcc18
ok could be a thing
jameslamb Mar 22, 2020
97d9913
changing directories
jameslamb Mar 22, 2020
6ed498d
we might be in business
jameslamb Mar 22, 2020
b275d22
fixed install syntax
jameslamb Mar 22, 2020
f701325
tryinv mingw
jameslamb Mar 22, 2020
618086a
more mingw
jameslamb Mar 22, 2020
90f91e5
ignore Suggests check
jameslamb Mar 22, 2020
2f4979a
trying Azure DevOps
jameslamb Mar 22, 2020
3b07c7b
just run bare minimum for Azure DevOps
jameslamb Mar 22, 2020
2d17cae
fixed build dir thing
jameslamb Mar 22, 2020
2e9fe09
trying to set libPaths
jameslamb Mar 22, 2020
855cdc9
more testing
jameslamb Mar 22, 2020
6d8878b
trying R 3.6.3
jameslamb Mar 22, 2020
c854fe3
R 3.6.3
jameslamb Mar 22, 2020
86f4eec
this feels right
jameslamb Mar 22, 2020
8b12858
still messing around with libraries
jameslamb Mar 22, 2020
dc50ad5
more paths
jameslamb Mar 22, 2020
065df95
removed duplication in Windows testing code
jameslamb Mar 22, 2020
432df25
simpler
jameslamb Mar 22, 2020
6e73047
fixed conda stuff
jameslamb Mar 22, 2020
fec3de7
more conda stuff
jameslamb Mar 22, 2020
9b90d84
more fixes
jameslamb Mar 22, 2020
c305e9d
fixed testing script
jameslamb Mar 22, 2020
c70e352
moved AppVeyor setup to the top
jameslamb Mar 22, 2020
517e519
commenting
jameslamb Mar 22, 2020
56bf28a
ch-ch-ch-ch-chaaaanges
jameslamb Mar 22, 2020
f439ba2
paths
jameslamb Mar 22, 2020
2923111
plz work
jameslamb Mar 22, 2020
65915a1
fixed conda stuff in Windows CI
jameslamb Mar 22, 2020
f18399d
uncommented stuff to test a full build
jameslamb Mar 23, 2020
1de8f6c
fixed quotes and removed some unnecessary stuff
jameslamb Mar 23, 2020
a912213
added install.libs.R change
jameslamb Mar 23, 2020
290e5b7
quotes are impoortant
jameslamb Mar 23, 2020
2565df7
added commented-out stuff back in
jameslamb Mar 23, 2020
cd89065
added Windows script, download retries, and MSVC linking
jameslamb Mar 24, 2020
fbf494c
minor fixes
jameslamb Mar 25, 2020
244a14a
cleaned up debugging code in FindLibR
jameslamb Mar 29, 2020
42609cd
cleaned up debugging code and moved R first in CI
jameslamb Mar 29, 2020
2804d45
fixed vsts-ci indentation
jameslamb Mar 31, 2020
af3c004
cut documentation stuff out of MSVC build
jameslamb Mar 31, 2020
1c498d0
fix R CMD check for Azure
jameslamb Mar 31, 2020
9e6aa49
misc whitespace changes
jameslamb Mar 31, 2020
76d264d
merge in #2962
jameslamb Apr 2, 2020
01359ab
Merge branch 'master' into ci/r-windows-ci
jameslamb Apr 4, 2020
d100027
Added echoing of build logs from R CMD check
jameslamb Apr 4, 2020
912a2fd
cut out more documentation tests
jameslamb Apr 4, 2020
d76b551
fixed NOTE about imports from Matrix
jameslamb Apr 4, 2020
7cdfc62
Merge branch 'master' into ci/r-windows-ci
jameslamb Apr 4, 2020
1a2053f
Merge branch 'master' into ci/r-windows-ci
jameslamb Apr 13, 2020
bdf10e0
Merge branch 'master' into ci/r-windows-ci
jameslamb Apr 15, 2020
88a7a09
moved some changes out of this PR and into #2963
jameslamb Apr 15, 2020
ae813f2
fixed whitespace stuff
jameslamb Apr 15, 2020
1b2363a
added check on number of NOTES
jameslamb Apr 15, 2020
dd52dbf
adding better checks
jameslamb Apr 15, 2020
7f9eb7c
fixing check on NOTEs
jameslamb Apr 15, 2020
374ba31
removing unnecessary variable
jameslamb Apr 15, 2020
30d8af1
Update .ci/test_r_package_windows.ps1
jameslamb Apr 15, 2020
e3b9ac8
some changes
jameslamb Apr 15, 2020
419e39b
fix quoting
jameslamb Apr 15, 2020
bfebf1d
trying MINGW on Azure DevOps
jameslamb Apr 16, 2020
3e2dcfd
fixing paths
jameslamb Apr 16, 2020
8ba021a
more paths
jameslamb Apr 16, 2020
51e4d2d
fixing paths
jameslamb Apr 16, 2020
5d74019
testing paths
jameslamb Apr 16, 2020
d7c160b
fixing slashes
jameslamb Apr 16, 2020
a8582db
pinned CTAN mirror
jameslamb Apr 17, 2020
8264f4a
get better logs
jameslamb Apr 17, 2020
d843795
made sure Azure finds MinGW, fixed search for LIBR_CORE_LIBRARY, stop…
jameslamb Apr 19, 2020
10bd18d
Apply suggestions from code review
jameslamb Apr 19, 2020
6ca2be8
added CXX, CC for Windows builds and changed back to building docs on…
jameslamb Apr 19, 2020
cdf1df8
stored LIBR_CORE_LIBRARY hints in one variable
jameslamb Apr 19, 2020
9c59f33
Apply suggestions from code review
jameslamb Apr 20, 2020
747378e
changes from code review
jameslamb Apr 20, 2020
c0b87d6
increased parallel builds for Azure CI
jameslamb Apr 20, 2020
6820fc6
Apply suggestions from code review
jameslamb Apr 21, 2020
7075b80
Merge branch 'master' into ci/r-windows-ci
jameslamb Apr 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ configuration: # a trick to construct a build matrix with multiple Python versi

environment:
matrix:
- COMPILER: MINGW
TASK: r-package
- COMPILER: MSVC
TASK: python
- COMPILER: MINGW
Expand Down
108 changes: 108 additions & 0 deletions .ci/test_r_package_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Download a file and retry upon failure. This looks like
# an infinite loop but CI-level timeouts will kill it
function Download-File-With-Retries {
param(
[string]$url,
[string]$destfile
)
do {
Write-Output "Downloading ${url}"
sleep 5;
(New-Object System.Net.WebClient).DownloadFile($url, $destfile)
} while(!$?);
}

$env:R_WINDOWS_VERSION = "3.6.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should test with R 4.0 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes I think we should have a separate issue for testing on R 4.0.0 across all platforms, now that it's officially released. Good call!

I just opened #3024 to capture that work (and added it to #2302 )

$env:R_LIB_PATH = "$env:BUILD_SOURCESDIRECTORY/RLibrary" -replace '[\\]', '/'
StrikerRUS marked this conversation as resolved.
Show resolved Hide resolved
$env:PATH = "$env:R_LIB_PATH/Rtools/bin;" + "$env:R_LIB_PATH/R/bin/x64;" + "$env:R_LIB_PATH/miktex/texmfs/install/miktex/bin/x64;" + $env:PATH
$env:CRAN_MIRROR = "https://cloud.r-project.org/"
$env:CTAN_MIRROR = "https://ctan.math.illinois.edu/systems/win32/miktex/tm/packages/"

if ($env:COMPILER -eq "MINGW") {
$env:CXX = "$env:R_LIB_PATH/Rtools/mingw_64/bin/g++.exe"
$env:CC = "$env:R_LIB_PATH/Rtools/mingw_64/bin/gcc.exe"
}

cd $env:BUILD_SOURCESDIRECTORY
tzutil /s "GMT Standard Time"
[Void][System.IO.Directory]::CreateDirectory($env:R_LIB_PATH)

if ($env:COMPILER -eq "MINGW") {
Write-Output "Telling R to use MinGW"
$install_libs = "$env:BUILD_SOURCESDIRECTORY/R-package/src/install.libs.R"
((Get-Content -path $install_libs -Raw) -replace 'use_mingw <- FALSE','use_mingw <- TRUE') | Set-Content -Path $install_libs
}

# download R and RTools
Write-Output "Downloading R and Rtools"
Download-File-With-Retries -url "https://cloud.r-project.org/bin/windows/base/old/$env:R_WINDOWS_VERSION/R-$env:R_WINDOWS_VERSION-win.exe" -destfile "R-win.exe"
Download-File-With-Retries -url "https://cloud.r-project.org/bin/windows/Rtools/Rtools35.exe" -destfile "Rtools.exe"

# Install R
Write-Output "Installing R"
Start-Process -FilePath R-win.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /DIR=$env:R_LIB_PATH/R /COMPONENTS=main,x64" ; Check-Output $?
Write-Output "Done installing R"

Write-Output "Installing Rtools"
Start-Process -FilePath Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /DIR=$env:R_LIB_PATH/Rtools" ; Check-Output $?
Write-Output "Done installing Rtools"

# MiKTeX and pandoc can be skipped on non-MINGW builds, since we don't
# build the package documentation for those
if ($env:COMPILER -eq "MINGW") {
Write-Output "Downloading MiKTeX"
Download-File-With-Retries -url "https://miktex.org/download/win/miktexsetup-x64.zip" -destfile "miktexsetup-x64.zip"
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("miktexsetup-x64.zip", "miktex")
Write-Output "Setting up MiKTeX"
.\miktex\miktexsetup.exe --remote-package-repository="$env:CTAN_MIRROR" --local-package-repository=./miktex/download --package-set=essential --quiet download ; Check-Output $?
Write-Output "Installing MiKTeX"
.\miktex\download\miktexsetup.exe --remote-package-repository="$env:CTAN_MIRROR" --portable="$env:R_LIB_PATH/miktex" --quiet install ; Check-Output $?
Write-Output "Done installing MiKTeX"

initexmf --set-config-value [MPM]AutoInstall=1
conda install -y --no-deps pandoc
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
}

Add-Content .Renviron "R_LIBS=$env:R_LIB_PATH"

Write-Output "Installing dependencies"
$packages = "c('data.table', 'jsonlite', 'Matrix', 'R6', 'testthat'), dependencies = c('Imports', 'Depends', 'LinkingTo')"
Rscript --vanilla -e "options(install.packages.check.source = 'no'); install.packages($packages, repos = '$env:CRAN_MIRROR', type = 'binary', lib = '$env:R_LIB_PATH')" ; Check-Output $?

Write-Output "Building R package"
Rscript build_r.R --skip-install ; Check-Output $?

$PKG_FILE_NAME = Get-Item *.tar.gz
$LOG_FILE_NAME = "lightgbm.Rcheck/00check.log"

$env:_R_CHECK_FORCE_SUGGESTS_ = 0
if ($env:COMPILER -ne "MINGW") {
Write-Output "Running R CMD check without checking documentation"
R.exe CMD check --no-multiarch --no-examples --no-manual --ignore-vignettes ${PKG_FILE_NAME} ; $check_succeeded=$?
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
} else {
Write-Output "Running R CMD check as CRAN"
R.exe CMD check --no-multiarch --as-cran ${PKG_FILE_NAME} ; $check_succeeded=$?
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
}

Write-Output "R CMD check build logs:"
Get-Content -Path $env:BUILD_SOURCESDIRECTORY\lightgbm.Rcheck\00install.out
jameslamb marked this conversation as resolved.
Show resolved Hide resolved

Check-Output $check_succeeded

Write-Output "Looking for issues with R CMD check results"
if (Get-Content "$LOG_FILE_NAME" | Select-String -Pattern "WARNING" -Quiet) {
echo "WARNINGS have been found by R CMD check!"
Check-Output $False
}
StrikerRUS marked this conversation as resolved.
Show resolved Hide resolved

$note_str = Get-Content "${LOG_FILE_NAME}" | Select-String -Pattern ' NOTE' | Out-String ; Check-Output $?
$relevant_line = $note_str -match '.*Status: (\d+) NOTE.*'
$NUM_CHECK_NOTES = $matches[1]
$ALLOWED_CHECK_NOTES = 3
if ([int]$NUM_CHECK_NOTES -gt $ALLOWED_CHECK_NOTES) {
Write-Output "Found ${NUM_CHECK_NOTES} NOTEs from R CMD check. Only ${ALLOWED_CHECK_NOTES} are allowed"
Check-Output $False
}

Write-Output "No issues were found checking the R package"
5 changes: 5 additions & 0 deletions .ci/test_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if (Test-Path env:APPVEYOR) {
$env:BUILD_SOURCESDIRECTORY = $env:APPVEYOR_BUILD_FOLDER
}

if ($env:TASK -eq "r-package") {
& $env:BUILD_SOURCESDIRECTORY\.ci\test_r_package_windows.ps1 ; Check-Output $?
Exit 0
}

# setup for Python
conda init powershell
conda activate
Expand Down
9 changes: 6 additions & 3 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
vmImage: 'ubuntu-latest'
container: ubuntu1404
strategy:
maxParallel: 6
maxParallel: 7
matrix:
regular:
TASK: regular
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
pool:
vmImage: 'macOS-10.14'
strategy:
maxParallel: 3
maxParallel: 4
matrix:
regular:
TASK: regular
Expand Down Expand Up @@ -117,8 +117,11 @@ jobs:
pool:
vmImage: 'vs2017-win2016'
strategy:
maxParallel: 3
maxParallel: 4
matrix:
r_package:
TASK: r-package
COMPILER: MINGW
regular:
TASK: regular
PYTHON_VERSION: 3.6
Expand Down
1 change: 1 addition & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export(saveRDS.lgb.Booster)
export(setinfo)
export(slice)
import(methods)
importFrom(Matrix,Matrix)
importFrom(R6,R6Class)
importFrom(data.table,":=")
importFrom(data.table,as.data.table)
Expand Down
1 change: 1 addition & 0 deletions R-package/R/lightgbm.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ NULL

# Various imports
#' @import methods
#' @importFrom Matrix Matrix
#' @importFrom R6 R6Class
#' @useDynLib lib_lightgbm , .registration = TRUE
NULL
Expand Down
26 changes: 20 additions & 6 deletions R-package/src/cmake/modules/FindLibR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,31 @@ execute_process(
OUTPUT_VARIABLE LIBR_LIB_DIR
)

set(LIBR_HOME ${LIBR_HOME} CACHE PATH "R home directory")
set(LIBR_EXECUTABLE ${LIBR_EXECUTABLE} CACHE PATH "R executable")
set(LIBR_INCLUDE_DIRS ${LIBR_INCLUDE_DIRS} CACHE PATH "R include directory")
set(LIBR_LIB_DIR ${LIBR_LIB_DIR} CACHE PATH "R shared libraries directory")
Copy link
Contributor

Choose a reason for hiding this comment

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

In another PR, maybe we should change the name and use LIBR_LIB_DIRS instead of LIBR_LIB_DIR (cmake Find result variables should be plural for include_dirs / lib_dirs, usually they are placeholders for include_dir / lib_dir if they are singular directories).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case it is a single directory. This isn't "all directories passed to the linker in -L flags", it is "what is the one directory where R.dll / R.so is likely to live".

Anyway, I'm removing LIBR_LIB_DIR completely in #2963 . It's only being used in MSVC installs, and only indirectly as a way to find LIBR_CORE_LIBRARY.


# where is R.so / R.dll / libR.so likely to be found?
set(LIBR_PATH_HINTS "${CMAKE_CURRENT_BINARY_DIR}" "${LIBR_LIB_DIR}" "${LIBR_HOME}/bin/${R_ARCH}" "${LIBR_HOME}/bin" "${LIBR_LIBRARIES}")

# look for the core R library
find_library(
LIBR_CORE_LIBRARY
NAMES R
HINTS "${CMAKE_CURRENT_BINARY_DIR}" "${LIBR_LIB_DIR}" "${LIBR_HOME}/bin" "${LIBR_LIBRARIES}"
NAMES R R.dll
HINTS ${LIBR_PATH_HINTS}
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@StrikerRUS I'm starting a thread here for this discussion on how to find R.dll.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to summarize for reviewers:

find_library() doesn't consider .dll by default (link 1, link 2)

find_library() is similar to find_file(), but it knows about common library prefixes (e.g. lib) and suffixes (e.g. .so).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This seems to be working! In https://ci.appveyor.com/project/guolinke/lightgbm/builds/32185340/job/5tcrah61l6hlv0ab I see

Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="C:/RLibrary/R/lib": The system cannot find the file specified
-- Found LibR: C:/RLibrary/R  
-- LIBR_EXECUTABLE: C:/RLibrary/R/bin/x64/R.exe
-- LIBR_INCLUDE_DIRS: C:/RLibrary/R/include
-- LIBR_CORE_LIBRARY: C:/RLibrary/R/bin/x64/R.dll

Don't worry about that "cannot find the file specified" up above those messages, I'm fixing it in #2963

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Struggling to get this working on Azure. I wrote up this comment bit-by-bit as I tried things, which is how it got so long.

the problem:

We have "${LIBR_HOME}/bin/${R_ARCH}" in the set of paths to search, and LIBR_CORE_LIBRARY isn't being found...but when I set it directly it works.

When I say "directly", I mean going back to what I originally had

set (LIBR_CORE_LIBRARY ${LIBR_HOME}/bin/${R_ARCH}/R.dll CACHE PATH "R core shared library")

Let me show you:

  • Just adding MinGW to PATH (plus other extra logging that I'll remove):
  • Hardcoding path guess:
    • commit: jameslamb@fdd5724
    • AppVeyor: works
      • you can see log message LIBR_CORE_LIBRARYwas found by find_library()
    • Azure: works
      • you can see log message LIBR_CORE_LIBRARY still not found, trying hard-coding

From the Get-ChildItem calls and added cmake logs, I can see in the logs that these are the relevant paths

  • AppVeyor
    • R.dll: C:\projects\lightgbm\RLibrary\R\bin\x64\R.dll
    • LIBR_HOME: C:/projects/lightgbm/RLibrary/R
  • Azure
    • R.dll: D:\a\1\s\RLibrary\R\bin\x64\R.dll
    • LIBR_HOME: D:/a/1/s/RLibrary/R

So then I thought "ok, the paths are the same...maybe the CMake versions are different and find_library() behaves differently...they are! and it does!

CMake versions

We did hear in #2995 (comment) that our setup wasn't working with CMake 3.17.

I found an important-looking line in https://cmake.org/cmake/help/v3.17/release/3.17.html#id17

When using MinGW tools, the find_library() command no longer finds .dll files by default. Instead, it expects .dll.a import libraries to be available.

I'm confused though, it seems like passing R.dll to NAMES should work (CMake docs):

Each library name given to the NAMES option is first considered as a library file name and then considered with platform-specific prefixes (e.g. lib) and suffixes (e.g. .so). Therefore one may specify library file names such as libfoo.a directly.

I'm going to try something like this:

# look for the core R library
find_library(
  LIBR_CORE_LIBRARY
  NAMES R R.dll
  HINTS "${CMAKE_CURRENT_BINARY_DIR}" "${LIBR_HOME}/lib" "${LIBR_HOME}/bin/${R_ARCH}" "${LIBR_HOME}/bin" "${LIBR_LIBRARIES}"
)

if (WIN32 AND NOT LIBR_CORE_LIBRARY)
    find_file(
        LIBR_CORE_LIBRARY
        NAME R.dll
        HINTS "${CMAKE_CURRENT_BINARY_DIR}" "${LIBR_HOME}/lib" "${LIBR_HOME}/bin/${R_ARCH}" "${LIBR_HOME}/bin" "${LIBR_LIBRARIES}"
    )
endif()

I'd rather do that than replace the origin find_library() call completely, because I have seen it called different things on some Linux system (like libR.so or R.so) and I don't want our CMake code to have to know about all the variables CMake uses to store different library prefixes and suffixes.

Copy link
Collaborator Author

@jameslamb jameslamb Apr 19, 2020

Choose a reason for hiding this comment

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

I tried that strategy and it seems like it worked!

  • AppVeyor: works
  • Azure: works
    • and you can see Rtools/mingw_64/bin/g++.exe is being chosen as the compiler

Added these changes in d843795:

  • fix for find_library() in findLibR.cmake
  • put MinGW compilers on PATH so they're found instead of the ones from chocolatey
  • uncommented commented-out non-R builds in .vsts-ci.yml
  • changed back from "don't run R docs on MinGW builds" to "don't run R docs on Azure"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't that what you were supporting by #2936 (comment)? Maybe I misunderstood.

That comment was about what I thought before CTAN pinning allowed us to move forward. Sorry for confusing you.

The current plan may be the following.

  1. In this PR enable full (--as-cran) MINGW builds at both Appveyor and Azure.
  2. In next PR after speeding up VS builds change MINGW to VS at Azure to cover more use cases.
  3. If building time will still take so long, change --as-cran to config without docs building in case of VS.

Please let me know WDYT about that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure I can do that! But since both chocolatey and MinGW are g++.exe, unlike in the example you shared I'll have to do the full path. Like $env:CXX = "$env:R_LIBS_PATH/Rtools/mingw_64/bin/g++.exe".

Yeah, for sure! Just like in

#export CXX=/usr/local/bin/g++-8 CC=/usr/local/bin/gcc-8

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree with this plan --> #2936 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok these changes worked: jameslamb@c145b7d

Added back to this PR in: 6ca2be8

Copy link
Collaborator Author

@jameslamb jameslamb Apr 19, 2020

Choose a reason for hiding this comment

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

One note...in 6ca2be8, I removed Rtools mingw from PATH, so we could be sure that setting CXX explicitly was working. I think that in #2965 we'll have to add it back, because that directory is also where gendef.exe is based.

I'll add a link to this comment on that PR.


set(LIBR_HOME ${LIBR_HOME} CACHE PATH "R home directory")
set(LIBR_EXECUTABLE ${LIBR_EXECUTABLE} CACHE PATH "R executable")
set(LIBR_INCLUDE_DIRS ${LIBR_INCLUDE_DIRS} CACHE PATH "R include directory")
set(LIBR_LIB_DIR ${LIBR_LIB_DIR} CACHE PATH "R shared libraries directory")
# starting from CMake 3.17, find_library() will not find .dll files by default
# https://cmake.org/cmake/help/v3.17/release/3.17.html#other-changes
if (WIN32 AND NOT LIBR_CORE_LIBRARY)
StrikerRUS marked this conversation as resolved.
Show resolved Hide resolved
find_file(
LIBR_CORE_LIBRARY
NAME R.dll
HINTS ${LIBR_PATH_HINTS}
)
endif()

set(LIBR_CORE_LIBRARY ${LIBR_CORE_LIBRARY} CACHE PATH "R core shared library")

if(WIN32 AND MSVC)
Expand Down
1 change: 1 addition & 0 deletions R-package/src/install.libs.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ if (!use_precompile) {
# Check if Windows installation (for gcc vs Visual Studio)
if (WINDOWS) {
if (use_mingw) {
print("Trying to build with MinGW")
Copy link
Contributor

Choose a reason for hiding this comment

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

Change in another PR print for message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure! Let's talk about it in a separate issue / PR. We have several other print() statements in install.libs.R and no uses of message() so I'm curious what makes message() preferable here.

cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ")
build_cmd <- "mingw32-make.exe _lightgbm"
system(paste0(cmake_cmd, " ..")) # Must build twice for Windows due sh.exe in Rtools
Expand Down