conda / conda-build

Commands and tools for building conda packages
https://docs.conda.io/projects/conda-build/
Other
383 stars 423 forks source link

RcppParallel compilation error #2671

Open torm89 opened 6 years ago

torm89 commented 6 years ago

Hi,

I'm trying to build RcppParallel package on Windows. I run conda-build. The package starts compiling but compilation breaks with error:

"C:/Windows/system32/cmd.exe" /C cscript /nologo /E:jscript ../../build/version_info_windows.js gcc intel64 "C:/Users/*******/conda-bld/r-rcppparallel_1517678566397/_h_env/R/../Library/mingw-w64/bin/g++  -g -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads -m64 -mrtm  -D__TBB_BUILD=1 -Wall -Wno-parentheses -Wno-uninitialized -DTBB_NO_LEGACY=1 -std=c++0x -D_TBB_CPP0X -I../../src -I../../src/rml/include -I../../include -I." > version_string.ver
'YCZKO~1' is not recognized as an internal or external command,
operable program or batch file.
../../build/common_rules.inc:162: recipe for target 'version_string.ver' failed
make[2]: *** [version_string.ver] Error 1
make[2]: *** Deleting file 'version_string.ver'
make[2]: Leaving directory '/c/Users/*******/conda-bld/r-rcppparallel_1517678566397/work/src/tbb/build/lib_release'
Makefile:101: recipe for target 'tbb_release' failed
make[1]: *** [tbb_release] Error 2
make[1]: Leaving directory '/c/Users/*******/conda-bld/r-rcppparallel_1517678566397/work/src/tbb/src'
/usr/bin/cp: cannot stat 'tbb/build/lib_release/tbb*.dll': No such file or directory
Makevars:74: recipe for target 'tbb' failed
make: *** [tbb] Error 1
Ostrzeżenie: uruchomione polecenie 'make -f "Makevars" -f "C:/Users/*******/conda-bld/r-rcppparallel_1517678566397/_h_env/R/etc/x64/Makeconf" -f "C:/Users/*******/conda-bld/r-rcppparallel_1517678566397/_h_env/R/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="RcppParallel.dll" WIN=64 TCLBIN=64 OBJECTS="options.o"' otrzymało status 2
ERROR: compilation failed for package 'RcppParallel'
* removing 'C:/Users/*******/Documents/R/win-library/3.4/RcppParallel'

It is strange that 'YCZKO~1' is part of TMP path TMP=C:\Users\*YCZKO~1\AppData\Local\Temp\11

Can someone help me?

active environment : r-env
    active env location : C:\Users\*******\AppData\Local\conda\conda\envs\r-env
            shell level : 1
       user config file : C:\Users\*******\.condarc
 populated config files : C:\Users\*******\.condarc
          conda version : 4.4.7
    conda-build version : 3.2.2
         python version : 3.6.4.final.0
       base environment : C:\ProgramData\Anaconda3  (read only)
           channel URLs : https://repo.continuum.io/pkgs/main/win-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/win-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/win-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/win-64
                          https://repo.continuum.io/pkgs/pro/noarch
                          https://repo.continuum.io/pkgs/msys2/win-64
                          https://repo.continuum.io/pkgs/msys2/noarch
          package cache : C:\ProgramData\Anaconda3\pkgs
                          C:\Users\*******\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\*******\AppData\Local\conda\conda\envs
                          C:\ProgramData\Anaconda3\envs
                          C:\Users\*******\.conda\envs
               platform : win-64
             user-agent : conda/4.4.7 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.14393
          administrator : False
             netrc file : None
           offline mode : False
msarahan commented 6 years ago

We'll look into this, but it may take us a little while. We are preparing the next Anaconda release, and we can't spend much time on peripheral things right now.

In the meantime, you may want to update conda-build. There have been a few releases since 3.2.2 that may have fixed something related (though I'm not sure, just a shot in the dark).

mcg1969 commented 6 years ago

@mingwandroid, this is looking like it is caused by a strange interaction with MSYS2's backslash conversion operation. This line is actually being run within an MSYS2 bash shell:

"C:/Windows/system32/cmd.exe" /C cscript /nologo /E:jscript ../../build/version_info_windows.js gcc intel64 "C:/Users/*******/conda-bld/r-rcppparallel_1517678566397/_h_env/R/../Library/mingw-w64/bin/g++  -g -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads -m64 -mrtm  -D__TBB_BUILD=1 -Wall -Wno-parentheses -Wno-uninitialized -DTBB_NO_LEGACY=1 -std=c++0x -D_TBB_CPP0X -I../../src -I../../src/rml/include -I../../include -I." > version_string.ver

I'm able to reproduce the strange error message myself here in a different, slightly more isolated way. To do this, I let the build fail, jumped over to the build directory, and ran the contents of bld.bat so that I could get the build environment activated and all of the environment variables set. Then, from the Windows command prompt, I ran sh. Here's an example of what I see:

sh-4.3$ cmd.exe
Microsoft Windows [Version 10.0.17134.112]
(c) 2018 Microsoft Corporation. All rights reserved.

(C:\Users\mcg\Miniconda3\conda-bld\r-rcppparallel_1532112145094\_h_env) C:\Users\mcg\Miniconda3\conda-bld\r-rcppparallel_1532112145094\work\src\tbb\build\lib_release>exit
sh-4.3$ cmd.exe /?
'onda-bld' is not recognized as an internal or external command,
operable program or batch file.

Now, when you call cmd.exe from Windows, cmd.exe /? is just supposed to display the help text. But I think the path conversion is going a little bonkers here.

On the other hand, I happen to have m2-bash installed in my root environment. If I run sh from there, cmd /? does exactly what I expect.

mcg1969 commented 6 years ago

Ah! Check this out:

sh-4.3$ cmd.exe //C echo "C:/WINDOWS/system32/cmd.exe" /C cscript /nologo /E:jscript ../../build/version_info_windows.j
s gcc intel64 "C:/Users/mcg/Miniconda3/conda-bld/r-rcppparallel_1532112145094/_h_env/lib/R/../../Library/mingw-w64/bin/
g++  -g -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads
-m64 -mrtm    -D__TBB_BUILD=1 -Wall  -DTBB_NO_LEGACY=1 -std=c++0x -I../../src -I../../src/rml/include -I../../include -
I."
C:/WINDOWS/system32/cmd.exe C:/ cscript C:/Users/mcg/Miniconda3/conda-bld/r-rcppparallel_1532112145094/_h_env/Library/nologo E:jscript ../../build/version_info_windows.js gcc intel64 "C:/Users/mcg/Miniconda3/conda-bld/r-rcppparallel_1532112145094/_h_env/lib/R/../../Library/mingw-w64/bin/g++  -g -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D__MSVCRT_VERSION__=0x0700 -msse -mthreads -m64 -mrtm    -D__TBB_BUILD=1 -Wall  -DTBB_NO_LEGACY=1 -std=c++0x -I../../src -I../../src/rml/include -I../../include -I."
mingwandroid commented 6 years ago

You need to use MSYS2_ARG_CONV_EXCL to disable the heuristic based path conversion that happens when Cygwin-y software calls native software, or avoid switches with / in. In most cases (e.g. for MSVC, MS fixed this many years ago), you can use - instead.

mcg1969 commented 6 years ago

Looks like judicious use of double forward slashes fixes it. I'll get a patch built

mcg1969 commented 6 years ago

This patch works, but I'm not sure I need all of the escapes:

*** src/tbb/build/windows.inc.orig  2018-07-20 19:40:45.000000000 -0500
--- src/tbb/build/windows.inc 2018-07-20 19:40:24.000000000 -0500
***************
*** 34,43 ****
    ifneq ($(COMSPEC), )
      # Use comspec env var if present
      # Since it represents a full path, quote in case there are some spaces.
!     CMD:="$(subst \,/,$(COMSPEC))" /C
    else
      # otherwise rely on cmd being in the path
!     CMD:=cmd /C
    endif
    export SHELL = sh.exe
    SLASH=/
--- 34,43 ----
    ifneq ($(COMSPEC), )
      # Use comspec env var if present
      # Since it represents a full path, quote in case there are some spaces.
!     CMD:="$(subst \,/,$(COMSPEC))" //C
    else
      # otherwise rely on cmd being in the path
!     CMD:=cmd //C
    endif
    export SHELL = sh.exe
    SLASH=/
***************
*** 49,63 ****

  # A convenience wrapper for calls to detect.js.
  # $(1) is the full command line for the script, e.g. /minversion icl 12
! detect_js = $(shell $(CMD) "cscript /nologo /E:jscript $(tbb_root)/build/detect.js $(1)")

  # TODO give an error if archs doesn't match
  ifndef arch
!   export arch:=$(call detect_js, /arch $(compiler))
  endif

  ifndef runtime
!   export runtime:=$(call detect_js, /runtime $(compiler))
  endif

  native_compiler := cl
--- 49,63 ----

  # A convenience wrapper for calls to detect.js.
  # $(1) is the full command line for the script, e.g. /minversion icl 12
! detect_js = $(shell $(CMD) "cscript //nologo //E:jscript $(tbb_root)/build/detect.js $(1)")

  # TODO give an error if archs doesn't match
  ifndef arch
!   export arch:=$(call detect_js, //arch $(compiler))
  endif

  ifndef runtime
!   export runtime:=$(call detect_js, //runtime $(compiler))
  endif

  native_compiler := cl
***************
*** 120,126 ****
  RML.MANIFEST = tbbmanifest.exe.manifest
  endif

! MAKE_VERSIONS = $(CMD) cscript /nologo /E:jscript $(subst \,/,$(tbb_root))/build/version_info_windows.js $(compiler) $(arch) $(subst \,/,"$(VERSION_FLAGS)") > version_string.ver
  MAKE_TBBVARS  = $(CMD) "$(subst /,\,$(tbb_root))\build\generate_tbbvars.bat"

  TEST_LAUNCHER = $(subst /,\,$(tbb_root))\build\test_launcher.bat $(largs)
--- 120,126 ----
  RML.MANIFEST = tbbmanifest.exe.manifest
  endif

! MAKE_VERSIONS = $(CMD) cscript //nologo //E:jscript $(subst \,/,$(tbb_root))/build/version_info_windows.js $(compiler) $(arch) $(subst \,/,"$(VERSION_FLAGS)") > version_string.ver
  MAKE_TBBVARS  = $(CMD) "$(subst /,\,$(tbb_root))\build\generate_tbbvars.bat"

  TEST_LAUNCHER = $(subst /,\,$(tbb_root))\build\test_launcher.bat $(largs)
frhino commented 5 years ago

Is it possible the error I'm seeing while updating conda is a similar issue, unescaped slashes causing a missing character in bash script? I'm worried about the error right after downloading and extracting packages. Should I be?

(base) C:\Users\Joshf>conda update -n base -c defaults conda
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\Joshf\AppData\Local\Continuum\anaconda3

  added / updated specs:
    - conda

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-4.6.14               |           py37_0         2.1 MB
    ------------------------------------------------------------
                                           Total:         2.1 MB

The following NEW packages will be INSTALLED:

  pip                pkgs/main/win-64::pip-19.0.3-py37_0

The following packages will be UPDATED:

  conda                                        4.6.8-py37_0 --> 4.6.14-py37_0

Proceed ([y]/n)? y

Downloading and Extracting Packages
conda-4.6.14         | 2.1 MB    | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) C:\Users\Joshf>ONDA (
'ONDA' is not recognized as an internal or external command,
operable program or batch file.

(base) C:\Users\Joshf>FOR %A IN ("C:\Users\Joshf\AppData\Local\Continuum\anaconda3\Scripts\conda.exe") DO @SET _sysp=%~dpA

(base) C:\Users\Joshf>FOR %A IN ("C:\Users\Joshf\AppData\Local\Continuum\anaconda3\condabin\.") DO @SET _sysp=%~dpA

(base) C:\Users\Joshf>IF NOT EXIST "!_sysp!\Scripts\conda.exe"
Collecting package metadata: done
Solving environment: done

# All requested packages already installed.