Skip to content

Conversation

janlazo
Copy link
Contributor

@janlazo janlazo commented May 18, 2018

Make the powershell build script not depend on Appveyor environment.

@janlazo
Copy link
Contributor Author

janlazo commented May 18, 2018

Fixing the ci/build.ps1 to work with Visual Studio 2017 without running it. I assume that the user will build neovim on cmd.exe or powershell without running the startup batchfiles from Visual Studio.

Notes:

  • default to MSVC if %CONFIGURATION% env var is undefined
    • detect MSVC and MINGW folders to know if building is possible
  • host/providers are optional because hardcoded paths may not exist in user environment.
  • modifications to $env forces the user to run powershell -NoProfile -File ci\build.ps1 to build Neovim to avoid environment corruption
  • path validation (ie. Test-Path) to ensure assumptions are met before proceeding
    • ie. mingw paths for 32/64 bit builds and mingw32-make
    • python/ruby/node directories
  • Set-PSDebug -Off in case the user runs .\ci\build.ps1 in a powershell session.

@janlazo janlazo changed the title win/package: include nvim-qt runtime files win: build: make ci/build.ps1 work without Appveyor and move nvim-qt runtime files May 18, 2018
@justinmk
Copy link
Member

I don't follow. Did the change to GetBinaryDep(...) somehow cause MSVC build to fail? Will build.ps1 be required for developers to build now?

@janlazo
Copy link
Contributor Author

janlazo commented May 18, 2018

It didn't fail but I don't know how to make cmake copy the nvim-qt runtime directory such that, in the build/share/nvim-qt is not created. I tried to add back the same command prior to adding gui_shim.vim but changing share/nvim/runtime to share/nvim-qt/runtime so that nvim-qt can set its env var for its runtime directory and append a valid path to rtp.

Since I don't want to second-guess which directory nvim-qt runtime files are, I'm running ci/build.ps1 on my machine without running Visual Studio 2017 GUI. I'm not even using its command prompt since cmake can find the Visual Studio folders anyway.

ci/build.ps1 isn't required but I want to support running it on a regular cmd/powershell session without GUIs, same as in Appveyor.

@janlazo
Copy link
Contributor Author

janlazo commented May 18, 2018

cmake warnings are "transferred" to the next cmake invocation so the functional tests always fails on my machine. Not sure if this is cmake or msbuild. I'm getting the same warnings as the passing MSVC builds on Appveyor and the warnings are from building Neovim.

Are there cmake cache files/directories that I have to delete?

Anyway, skipping the tests, only cpack is failing because of CPACK_CMAKE_GENERATOR. Where is it defined?

@justinmk
Copy link
Member

justinmk commented May 18, 2018

this?

neovim/ci/build.ps1

Lines 124 to 128 in e121b1d

# Build artifacts
cpack -G ZIP -C RelWithDebInfo
if ($env:APPVEYOR_REPO_TAG_NAME -ne $null) {
cpack -G NSIS -C RelWithDebInfo
}

we do not explicitly set CPACK_CMAKE_GENERATOR as far as I know.

@janlazo
Copy link
Contributor Author

janlazo commented May 18, 2018

Yes. I'll deal with that later.

Debugging the following failures on my machine

 [  FAILED  ] 5 tests, listed below:
  [  FAILED  ] ...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua @ 34: :write &backupcopy=auto preserves symlinks
  ...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua:47: Expected objects to be the same.
  Passed in:
  (table) {
   *[1] = 'content0' }
  Expected:
  (table) {
   *[1] = 'content1' }

  stack traceback:
        ...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua:47: in function <...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua:34>

  [  FAILED  ] ...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua @ 68: :write appends FIFO file
  ...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua:82: test_fifo: No such file or directory

  stack traceback:
        ...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua:82: in function <...d/repo/git/neovim/test/functional\ex_cmds\write_spec.lua:68>

  [  FAILED  ] .../neovim/test/functional\legacy\011_autocommands_spec.lua @ 77: file reading, writing and bufnew and filter autocommands BufReadPre, BufReadPost (using gzip)
  .../neovim/test/functional\legacy\011_autocommands_spec.lua:91: Expected objects to be the same.
  Passed in:
  (string) '▼┬ì<├┐Z ♥Xtestfile +.I,*Q├êOS(I-.I├ï├îI├Ñ├è├ë├îKU0├ótLJNIMK├Å├ê├î├è├Ä├ë├ì├ï/(,*.)-+┬»┬¿┬¼┬é┬
¿0├ª┬¼├Ç♂ ┬¬┬ÜcJ┬ö9f♦├ì1'├è∟♂┬é├ªX↕e┬Ä┬í┬ü☻▲┬âR├│RP┬é¶ !qs&e☺  '
  Expected:
  (string) 'start of testfile
  line 2        Abcdefghijklmnopqrstuvwxyz
  line 3        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  line 4        Abcdefghijklmnopqrstuvwxyz
  line 5        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  line 6        Abcdefghijklmnopqrstuvwxyz
  line 7        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  line 8        Abcdefghijklmnopqrstuvwxyz
  line 9        xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  line 10 Abcdefghijklmnopqrstuvwxyz
  end of testfile'

  stack traceback:
        .../neovim/test/functional\legacy\011_autocommands_spec.lua:91: in function <.../neovim/test/functional\legacy\011_autocommands_spec.lua:77>

  [  FAILED  ] .../neovim/test/functional\legacy\011_autocommands_spec.lua @ 98: file reading, writing and bufnew and filter autocommands FileReadPre, FileReadPost
  .../neovim/test/functional\legacy\011_autocommands_spec.lua:32: Expected objects to be the same.
  Passed in:
  (table) {
    [access] = 1526676621
    [change] = 1526676621
    [dev] = 2
    [gid] = 0
    [ino] = 0
    [mode] = 'file'
    [modification] = 1526676621
    [nlink] = 1
    [permissions] = 'rw-rw-rw-'
    [rdev] = 2
    [size] = 357
    [uid] = 0 }
  Expected:
  (nil)

  stack traceback:
        .../neovim/test/functional\legacy\011_autocommands_spec.lua:32: in function 'prepare_gz_file'
        .../neovim/test/functional\legacy\011_autocommands_spec.lua:99: in function <.../neovim/test/functional\legacy\011_autocommands_spec.lua:98>

  [  FAILED  ] ...d/repo/git/neovim/test/functional\legacy\delete_spec.lua @ 44: Test for delete() symlink delete
  ...d/repo/git/neovim/test/functional\legacy\delete_spec.lua:56: Expected objects to be the same.
  Passed in:
  (number) -1
  Expected:
  (number) 0

  stack traceback:
        ...d/repo/git/neovim/test/functional\legacy\delete_spec.lua:56: in function <...d/repo/git/neovim/test/functional\legacy\delete_spec.lua:44>

@janlazo
Copy link
Contributor Author

janlazo commented May 18, 2018

Is there a convenient way to query for admin privs other than os.execute('mklink tmplink tmpfile')?
I can do it via powershell and C# for more accurate detection.

@justinmk
Copy link
Member

You mean from vim? Not that I know of. Try-and-fail is a fine approach, as you mentioned.

@janlazo
Copy link
Contributor Author

janlazo commented May 19, 2018

@justinmk Does cmake still have an issue with sh/bash in PATH? What was the reason why it's removed again? I disabled some tests (ie. gzip, fifo) because they come with msysgit and I don't want to deal with them now.

@janlazo janlazo changed the title win: build: make ci/build.ps1 work without Appveyor and move nvim-qt runtime files [RFC] win: build: make ci/build.ps1 work without Appveyor and move nvim-qt runtime files May 19, 2018
@janlazo
Copy link
Contributor Author

janlazo commented May 19, 2018

I copied only the shim because I don't know how to copy the entire runtime/ for nvim-qt. Feedback is appreciated.

In the meantime, I'll work on more path checks and adding a mingw fallback if Visual Studio is not installed.

@marvim marvim added the RFC label May 19, 2018
@justinmk
Copy link
Member

Does cmake still have an issue with sh/bash in PATH ? What was the reason why it's removed again?

It was only a problem when building with mingw, it comes from f53c825. Only @equalsraf knows why. If it doesn't cause a problem, maybe it's not a problem anymore.

I disabled some tests (ie. gzip, fifo) because they come with msysgit and I don't want to deal with them now.

Ok. But I'm confused, how is that related to the gui shim? Aren't those tests already passing on master?

@janlazo
Copy link
Contributor Author

janlazo commented May 19, 2018

Aren't those tests already passing on master?

They were skipped because Windows doesnt have gzip and mkfifo by default. Appveyor has them because of Git. I have them in my PATH because I install Git in a different folder so the build script didnt remove sh from PATH on my machine. sh is not a problem in MSVC build.

@janlazo
Copy link
Contributor Author

janlazo commented May 20, 2018

https://github.com/Kitware/CMake/blob/master/Modules/CMakeMinGWFindMake.cmake unsets CMAKE_MAKE_PROGRAM if sh.exe is in PATH.

@janlazo
Copy link
Contributor Author

janlazo commented May 20, 2018

Having issues compiling LuaJIT because of sjlj exceptions. Not sure if it's caused by -O2

@janlazo janlazo changed the title [RFC] win: build: make ci/build.ps1 work without Appveyor and move nvim-qt runtime files [RFC] win: build: make ci/build.ps1 work without Appveyor May 20, 2018
@janlazo
Copy link
Contributor Author

janlazo commented May 20, 2018

cmake requires -DCMAKE_SH=CMAKE_SH-NOTFOUND -DCMAKE_MAKE_PROGRAM=C:/msys64/mingw$bits/bin/mingw32-make to make cmake -G work with Mingw Makefiles. mingw32-make requires passing CMAKE_SH and CMAKE_MAKE_PROGRAM to the generated Makefile. Maybe it's faster to patch https://github.com/Kitware/CMake/blob/master/Modules/CMakeMinGWFindMake.cmake.

Building LuaJIT on Mingw must omit -O2 to disable sjlj exceptions. I'm using the Debug build for now to force it.

@janlazo janlazo force-pushed the win_nvim_gui branch 2 times, most recently from 4d8a8bd to fa42155 Compare May 20, 2018 15:36
@erw7
Copy link
Contributor

erw7 commented May 20, 2018

@janlazo How about installing mingw-w64-$arch-ninja and using cmake - G Ninja? It does not complain even if there is sh in the PATH.

@janlazo
Copy link
Contributor Author

janlazo commented May 20, 2018

@erw7 I'll test Ninja after going through all the affected dependencies.

@janlazo janlazo force-pushed the win_nvim_gui branch 2 times, most recently from 662c03c to 53882e8 Compare May 31, 2018 00:45
@janlazo janlazo changed the title [WIP] win: build: make ci/build.ps1 work without Appveyor [RFC] win: build: make ci/build.ps1 work without Appveyor Jun 1, 2018
@janlazo
Copy link
Contributor Author

janlazo commented Jun 1, 2018

Is there a mingw compiler that uses seh exception for LuaJIT? I don't know how to force it for gcc so I'm leaving this PR as RFC for now.

@marvim marvim added RFC and removed WIP labels Jun 1, 2018
@justinmk
Copy link
Member

justinmk commented Jun 1, 2018

I don't know how to answer that, maybe @jszakmeister @jamessan or some other build expert can help.

@janlazo janlazo force-pushed the win_nvim_gui branch 3 times, most recently from eb61acc to ba1647e Compare June 6, 2018 00:55
@janlazo
Copy link
Contributor Author

janlazo commented Jun 6, 2018

makedeps.bat was included to conveniently build .deps/ so it will be deprecated since I'm getting tired of running everything after updating the build script. I'll rewrite ci/build.ps1, similar to scripts/vim-patch.sh.


# Build third-party dependencies
$mingwPackages = @('gcc', 'make', 'cmake', 'perl', 'diffutils', 'unibilium').ForEach({
@('mingw', 'w64', $arch, $_) -join '-'
Copy link
Member

Choose a reason for hiding this comment

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

The old code was more obvious. Is there a functional need for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I was testing the pattern so I can conveniently add gcc, make, ninja. I prefer joining arrays than 'mingw-w64-' + $arch + '-' + $_ and all packages had the same naming pattern.

$env:PATH = "C:\msys64\usr\bin;$env:PATH"
& "C:\msys64\mingw$bits\bin\mingw32-make.exe" -C $(Convert-Path ..\src\nvim\testdir) VERBOSE=1
# Old tests
if (Test-Path "C:\msys64\mingw$bits\bin\mingw32-make.exe") {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like my old comment still applies. If Test-Path fails on appveyor we don't want the build to silently continue. We want it to fail loudly.

@justinmk
Copy link
Member

justinmk commented Jun 7, 2018

build.ps1 is getting complicated, maybe it isn't worth trying to make it work outside of AppVeyor. Instead use a separate script, then we can potentially use that from ci/build.ps1 if it has a lot of duplicated ideas. But I would guess it might end up not needing much code at all, e.g. makedeps.bat is trivial.

What exactly do you use build.ps1 for, other than building .deps ?

@janlazo
Copy link
Contributor Author

janlazo commented Jun 7, 2018

@justinmk I want a convenient script to run everything and ci/build.ps1 has that use-case. I wasn't compiling nvim at all prior to this PR. Problem is the port from batchfile to powershell script is incomplete (for me) because it didn't take full advantage of powershell features.

exitIfFailed might be redundant now. There is makedeps.bat but I don't want to write a batchfile when a powershell function suffices.

janlazo added 3 commits June 9, 2018 01:09
`MinGW Makefiles` build needs it if sh.exe is in PATH.
Build with MSVC if $env:CONFIGURATION is unset.
Add codepath for Ninja generator on MinGW build.
Check git, python, ruby paths from Appveyor to not break $env:PATH.
Run codecov and oldtests if mingw is installed
Stop the build if any cmdlet fails or a program returns a terminating error.
Force all (script) local variables to be set before using them.
gcc enables sjlj exceptions but they're not native on Windows.
@janlazo janlazo mentioned this pull request Jun 9, 2018
@janlazo
Copy link
Contributor Author

janlazo commented Jun 9, 2018

I can't reproduce the error for xgettext on MSVC_64. It could be a path escaping issue with one of the arguments if it uses cmd.exe.

MINGW_32 is completely broken because of msvcrt.dll. gdb detects stack buffer overrun on ntdll.dll. How did mingw (32-bit) build before? Could be a segfault (overflow) because of the negative exit code. Strange that all of the dependencies are fine such that nvim can be compiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build building and installing Neovim using the provided scripts platform:windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants