Skip to content

cmake: Simplify MSYS support patch#2422

Merged
lazka merged 1 commit into
msys2:masterfrom
orgads:cmake-simple
Apr 11, 2021
Merged

cmake: Simplify MSYS support patch#2422
lazka merged 1 commit into
msys2:masterfrom
orgads:cmake-simple

Conversation

@orgads

@orgads orgads commented Apr 1, 2021

Copy link
Copy Markdown
Contributor

Instead of setting only MSYS, set both MSYS and CYGWIN. This enables
using existing CYGWIN conditions without adapting them. It also
makes the patch maintenance much easier.

Fixes #2419.

@orgads

orgads commented Apr 1, 2021

Copy link
Copy Markdown
Contributor Author

There is a permission test that fails because MSYS uses noacl in fstab by default.

$ ctest -R 'kwsys.testSystemTools' -V
...
test 5
    Start 5: kwsys.testSystemTools

5: Test command: /f/Projects/build-cmake-msys/Source/kwsys/cmsysTestsCxx "testSystemTools"
5: Test timeout computed to be: 1500
5: SetPermissions failed to set permissions (2) for: /f/Projects/build-cmake-msys/Source/kwsys/testSystemToolsNewDir/testNewFile.txt: actual = 32768; expected = 511
5: Failed to write file: file_b
5: Failed to write file: file_b
1/1 Test #5: kwsys.testSystemTools ............***Failed    0.07 sec

I tried to change fullMask to S_IWRITE, or to 0444, but it still didn't pass. Ideas are welcome (this should not hold back the patch anyway, because it probably fails with the existing package as well).

@orgads orgads force-pushed the cmake-simple branch 3 times, most recently from d51938f to af6e098 Compare April 1, 2021 21:29
@lazka

lazka commented Apr 2, 2021

Copy link
Copy Markdown
Member

Thanks!

@piotrvv

piotrvv commented Apr 3, 2021

Copy link
Copy Markdown
Contributor

This link may be the answer to the question why ctest does not work http://cygwin.com/ml/cygwin/2013-11/msg00018.html. The symlink shortcut to the /bin /lib /share directories does not work properly in the cchache. You do not need it in cygwin because there is a virtual directory /usr mounted in binary mode. So we need a better version of gcc with the fortran -static option working. And parsing in grep sed. We also have an invalid c89 mode in gcc. You can try to compile the yasm package.

@piotrvv

piotrvv commented Apr 3, 2021

Copy link
Copy Markdown
Contributor

The following tests FAILED:
5 - kwsys.testSystemTools (Failed)
26 - FindPackageTest (Failed)
82 - Module.CheckIPOSupported-C (Failed)
83 - Module.CheckIPOSupported-CXX (Failed)
130 - CPackComponents (Failed)
136 - CPackComponentsPrefix (Failed)
137 - X11 (Failed)
145 - ExternalProject (Failed)
203 - CTest.UpdateSVN (Failed)
270 - Fortran (Failed)
272 - FortranC.Flags (Failed)
353 - RunCMake.Make (Failed)
370 - RunCMake.FileAPI (Failed)
374 - RunCMake.GenerateExportHeader (Failed)
381 - RunCMake.GenEx-TARGET_FILE (Failed)
415 - RunCMake.MaxRecursionDepth (Failed)
442 - RunCMake.file (Failed)
443 - RunCMake.file-CHMOD (Failed)
444 - RunCMake.find_file (Failed)
445 - RunCMake.find_library (Failed)
446 - RunCMake.find_package (Failed)
447 - RunCMake.find_path (Failed)
463 - RunCMake.project_injected (Failed)
480 - RunCMake.configure_file (Failed)
485 - RunCMake.SymlinkTrees (Failed)
508 - RunCMake.CommandLine (Failed)
510 - RunCMake.install (Failed)
515 - RunCMake.ExternalProject (Failed)
519 - RunCMake.CPackSymlinks (Failed)
523 - RunCMake.ClangTidy (Failed)
524 - RunCMake.IncludeWhatYouUse (Failed)
526 - RunCMake.Cppcheck (Failed)
527 - RunCMake.MultiLint (Failed)
533 - RunCMake.CPack_TGZ (Failed)
553 - CMake.GetFilenameComponentRealpath (Failed)
557 - CMake.ImplicitLinkInfo (Failed)
558 - CMake.ModuleNotices (Failed)
Errors while running CTest
make: *** [Makefile:148: test] Error 8

@orgads

orgads commented Apr 7, 2021

Copy link
Copy Markdown
Contributor Author

I now found that chmod doesn't work when umask is set. That's very strange...

It's the same on Cygwin when noacl is set.

Example:

#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include <iostream>

const char fileName[] = "foo";
const int mask = S_IWRITE;

void get()
{
  struct stat st;
  stat(fileName, &st);
  std::cout << (st.st_mode) << std::endl;
}

void set(int mode) {
  chmod(fileName, mode);
}

int main() {
  std::cout << std::oct;
  close(open(fileName, O_WRONLY | O_CREAT));
  get();
  umask(mask);
  set(0);
  get();
  set(mask);
  get();
}

Output:

100644
100444
100444

Without the umask call (or without noacl), the third line is 100644.

@orgads

orgads commented Apr 7, 2021

Copy link
Copy Markdown
Contributor Author

Reported to cygwin: https://cygwin.com/pipermail/cygwin/2021-April/248208.html

Instead of setting only MSYS, set both MSYS and CYGWIN. This enables
using existing CYGWIN conditions without adapting them. It also
makes the patch maintenance much easier.

Fixes msys2#2419.
@orgads

orgads commented Apr 9, 2021

Copy link
Copy Markdown
Contributor Author

I found the root caused. Reported here: https://cygwin.com/pipermail/cygwin/2021-April/248241.html

The problem is that when umask is set, stat applies it on its result. So it's not chmod that is broken, but stat. Worked around it in the patch (moved the umask call to where it's needed).

@orgads

orgads commented Apr 9, 2021

Copy link
Copy Markdown
Contributor Author

Do you prefer to rename the patch file back to 0001-Support-MSYS.patch, so you can review the differences?

@orgads

orgads commented Apr 9, 2021

Copy link
Copy Markdown
Contributor Author

Looks okish now. Some tests fail, but they fail also on cygwin. See my last comment on https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5969.

@lazka

lazka commented Apr 11, 2021

Copy link
Copy Markdown
Member

I've built brotli and clang with this and all seems fine.

Thanks!

@lazka lazka merged commit cd948ab into msys2:master Apr 11, 2021
@orgads orgads deleted the cmake-simple branch April 11, 2021 11:23
@orgads

orgads commented Apr 11, 2021

Copy link
Copy Markdown
Contributor Author

That was a long journey \o/

Thanks for the careful review.

@lazka

lazka commented Apr 11, 2021

Copy link
Copy Markdown
Member

It hasn't been that careful ;) as my cmake knowledge is limited, but you seem to know your way around and I agree with the patch goal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMake: A suggestion for minimizing the support patch

3 participants