Skip to content

Conversation

@hughbe
Copy link
Contributor

@hughbe hughbe commented Dec 19, 2016

Introduce swift_create_post_build_symlink and a batch script to delete an existing symlink and create a new one.

The reason I need a batch script is because CMake's if(EXISTS) doesn't work for symlinks, CMakes create_symlink doesn't work on Windows, and mklink throws errors when creating a symlink when a symlink already exists.

I can't use swift_create_post_build_symlink in stdlib/public/SwiftShims/CMakeLists.txt because this is a target, not a command

@compnerd @jrose-apple

@compnerd
Copy link
Member

CC @llvm-beanz

I think that Chris had some fixes for the llvm macros and we should try to reuse those.

@hughbe
Copy link
Contributor Author

hughbe commented Dec 19, 2016

I think that Chris had some fixes for the llvm macros and we should try to reuse those.

I thought these were for executables? Not .py and .dylib files

Copy link
Contributor

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

I put inline comments below. In general I think it is best to avoid using symlinks on Windows.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this even needed for Windows? This is really a hack to workaround a library being renamed. I'm not even sure we actually need to create this symlink at all anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jrose-apple I think you added this back in 2015. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

In LLVM our normal approach is to replace "create_symlink" with "copy" on non-unix systems. I think that is way simpler, and a better approach. Especially because calling mklink on Windows requires elevated privileges, and I think it would be unfortunate if building Swift required elevated privileges. That would specifically hamper the ability of students to checkout and build Swift on University-owned machines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, have an account with elevated privileges. I've noticed that I get privilege errors using mklink Without any arguments. They seem to go away when I add /H or /J.

That said, i can change to be a basic copy_if_different/copy if you'd like.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had to do some research to understand the difference between /H, /J, and /D. Turns out /H and /J introduce other complications that are possibly undesirable in some contexts. Specifically they cannot be used to point across volume boundaries. With that context I definitely think it is better to use copy_if_different or copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aye aye, will do - thanks

@hughbe
Copy link
Contributor Author

hughbe commented Dec 20, 2016

Thanks @llvm-beanz - I've updated the PR to use copying instead of symlinking on Windows. In the second commit I removed the demangle symlinking as you suggested

Copy link
Contributor

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

One comment, otherwise LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than lots of named parameters, why not use cmake_parse_arguments with named parameters? That is much easier to read.

I'm fine with the source, dest, and target being named parameters, but is_directory should be a flag, and working_directory and comment should be single option parameters (potentially even optional).

@hughbe
Copy link
Contributor Author

hughbe commented Dec 22, 2016

@llvm-beanz I've addressed your comments, looks nicer now

@llvm-beanz
Copy link
Contributor

@hughbe LGTM! Thanks!

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@slavapestov slavapestov self-assigned this Jan 9, 2017
@slavapestov slavapestov merged commit dfebf20 into swiftlang:master Jan 9, 2017
@hughbe hughbe deleted the symlink-win32 branch January 9, 2017 21:00
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.

4 participants