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

build: Improve build by cmake for Cygwin #2085

Merged
merged 4 commits into from
Jan 19, 2023

Conversation

erw7
Copy link
Contributor

@erw7 erw7 commented Nov 21, 2018

  • Fix issue that can't build on Cygwin.
  • Add installation targets to Windows.
  • Fix an issue that can't be compiled with MSVC in specific language environment.
  • Fix file name of static library.
  • Change to be able to select whether to build static library or shared library.
  • Fix problem where building on Windows fails if BUILD_TESTING is set.

@justinmk
Copy link

cc @bradking

@erw7
Copy link
Contributor Author

erw7 commented Nov 23, 2018

#1850 (comment) problem is not solved. So I changed test of shared library to not compile on Windows. The cause of the build failure is that the required function(make_program_args, quote_cmd_arg, make_program_env) has not been exported to dll. I think that it can be fixed by the following method.

  • Add src/win/process.c masked with #undef to uv_test_sources.
  • Export those functions to dll.

Should we fix it in either way?

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@justinmk
Copy link

Anything blocking this from inclusion?

CMakeLists.txt Outdated Show resolved Hide resolved
@blueyed
Copy link
Contributor

blueyed commented Jul 10, 2019

@erw7
Can you rebase this to fix conflicts?

(I came across a fix for the static library name also just yet (which is included here already): #2374)

CMakeLists.txt Outdated Show resolved Hide resolved
@justinmk
Copy link

justinmk commented Sep 6, 2019

Needs rebase (conflict).

@saghul
Copy link
Member

saghul commented Oct 21, 2019

Heads up: this one will conflict heavily with #2504

I believe that landing #2504 first is a good idea here, since it targets our build more broadly than just making it work on Cygwin. Then this one would need to be rebased.

@stale
Copy link

stale bot commented Jan 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 13, 2020
@justinmk
Copy link

Waiting on #2504

@stale stale bot removed the stale label Jan 13, 2020
@stale
Copy link

stale bot commented Feb 16, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Feb 16, 2020
@justinmk
Copy link

@erw7 looks like #2504 was merged, is this PR still relevant?

@erw7
Copy link
Contributor Author

erw7 commented Feb 17, 2020

looks like #2504 was merged, is this PR still relevant?

I fixed it to match the change in #2504.

@saghul
Copy link
Member

saghul commented Feb 18, 2020

@slurps-mad-rips Issabella, any chance you could take a look at this?

Copy link
Contributor

@bruxisma bruxisma left a comment

Choose a reason for hiding this comment

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

@saghul I left a few comments. I've got some personal choices I disagree with, but that's because I haven't had time to finish cleaning up the entire file itself. 😛
That said, we still haven't merged my unit test changes, which affects this PR to a degree as well. I'll ping on that commit when I have a moment (it's late here in my timezone so I'll have to wait until the day star is back in the sky 🙂)

That said, I know I can't have any authority on this, but I'm vehemently against renaming the "logical target" names for uv and uv_a until I have time to make sure that exporting targets works correctly. Right now if we change the CMake name for any of these targets, anyone including it directly within their build via add_subdirectory (which my changes in #2504 allow for), their builds will break. It's possible to fix this, but I'd need to sit down and outline a plan as it's more than just a simple name change with some property settings.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@vtjnash
Copy link
Member

vtjnash commented Oct 3, 2021

still needs a rebase

- Fix issue that can't build on Cygwin.
- Fix file name of static library.
@erw7
Copy link
Contributor Author

erw7 commented Oct 4, 2021

still needs a rebase

I rebased and squashed.

@vtjnash
Copy link
Member

vtjnash commented Oct 4, 2021

@vtjnash vtjnash dismissed their stale review October 4, 2021 20:12

CI no longer fails, as per #2085 (comment)

@stale
Copy link

stale bot commented Nov 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Nov 25, 2021
@stale stale bot removed the stale label Jan 18, 2023
@vtjnash
Copy link
Member

vtjnash commented Jan 19, 2023

@vtjnash Since the main focus of this PR is to rename the static library, your suggestion is not acceptable.

I don't understand why such a basic explanation is needed, but the following assertion in #2374 (comment) is wrong.

I have learned a lot more about CMake in the last couple years, starting from zero. I can now understand why that assertion was wrong. Furthermore:

The fact that there is already a user for uv_a is a problem, but we should stop installing static libraries with names that deviate from common practice. If you still can't accept the above explanation, you can close this.

Actually, it turns out that we already have numerous tests for this in CI, showing that luv should be perfectly happy with this change too. Had to rebase (merge conflicts with LIBUV_BUILD_SHARED) and then will plan to merge once CI finishes.

@vtjnash vtjnash merged commit 17ea56e into libuv:v1.x Jan 19, 2023
@sl1200mk2
Copy link

Hi,
these changes have broken my windows build:
17ea56e

especially the if(CYGWIN OR MSYS)

I'm using msys2 which is up to date and cmake to build libUV. my cmake line is :
cmake -G "MSYS Makefiles" .. -DCMAKE_C_COMPILER=gcc -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/local -DCMAKE_INSTALL_PREFIX=/opt/local -DCMAKE_C_FLAGS="-O2" -DLIBUV_BUILD_TESTS:BOOL=OFF

@erw7 erw7 deleted the improve-build-by-cmake branch April 22, 2023 12:41
squeek502 added a commit to squeek502/luv that referenced this pull request May 20, 2023
squeek502 added a commit to squeek502/luv that referenced this pull request May 20, 2023
zhaozg pushed a commit to zhaozg/luv that referenced this pull request May 20, 2023
zhaozg pushed a commit to luvit/luv that referenced this pull request May 20, 2023
@@ -8,5 +8,5 @@ Version: @PACKAGE_VERSION@
Description: multi-platform support library with a focus on asynchronous I/O.
URL: http://libuv.org/

Libs: -L${libdir} -luv_a @LIBS@
Libs: -L${libdir} -l:libuv.a @LIBS@

Choose a reason for hiding this comment

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

Why is there a colon? It breaks the build for me:

[133/228] : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -fPIC -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  wpinet/CMakeFiles/wpinet_dsclient.dir/examples/dsclient/dsclient.cpp.o -o bin/wpinet_dsclient  lib/libwpinetd.a  lib/libwpiutild.a  /Users/leanderSchulten/git_projekte/vcpkg/vcpkg_installed/arm64-osx/debug/lib/libfmtd.a  -l:libuv.a  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib/libpthread.tbd && :
FAILED: bin/wpinet_dsclient 
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -fPIC -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  wpinet/CMakeFiles/wpinet_dsclient.dir/examples/dsclient/dsclient.cpp.o -o bin/wpinet_dsclient  lib/libwpinetd.a  lib/libwpiutild.a  /Users/leanderSchulten/git_projekte/vcpkg/vcpkg_installed/arm64-osx/debug/lib/libfmtd.a  -l:libuv.a  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib/libpthread.tbd && :
ld: library not found for -l:libuv.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)

and removing it resolved this error.

Copy link
Member

Choose a reason for hiding this comment

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

-l: is a different flag from -l and specifies a full file name (instead of just the soname)

Choose a reason for hiding this comment

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

Is this a gcc thing? Because I have a libuv.a on my library search patch, but as written in the error message it is not found.

Choose a reason for hiding this comment

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

Seems that this is only supported by the gcc linker and not the llvm linker.

Copy link
Member

Choose a reason for hiding this comment

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

It sounds like an ld.lld emulation bug in LLVM in that case

Choose a reason for hiding this comment

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

But nearly all *.pc files I have seen are wrong in this respect.

Copy link
Member

Choose a reason for hiding this comment

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

True, I don't really know why *.pc files seem to use -L${libdir}, when the logical thing would be ${libdir}/libuv.a

Copy link
Member

Choose a reason for hiding this comment

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

Ah, apparently it is because those particular flags have special meaning to pkg-config beyond their use in ld (c.f. PKG_CONFIG_SYSROOT_DIR)

Choose a reason for hiding this comment

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

Hm ok. But this would mean that I use a pkg-config file from a lib of my host system to use a lib on my target system instead of using the pkg-config file of the lib for the target system directly (via PKG_CONFIG_PATH).

Choose a reason for hiding this comment

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

I probably patch the lib that uses libuv via pkgconfig to use cmake config files ... :D

@mizvekov
Copy link
Contributor

Part of this MR is causing issues building on windows with Ninja generator.

See #4139

@bnoordhuis
Copy link
Member

As commit 17ea56e is apparently causing regressions, should it be reverted? It reverts cleanly.

@vtjnash
Copy link
Member

vtjnash commented Sep 26, 2023

There is a part of that commit that is supposed to add the lib prefix when not gcc, which presumably fixes that already. But it only supports msvc

@mizvekov
Copy link
Contributor

The only parts of the MR that needs to be reverted are the lines which change the OUTPUT_NAME.

  • set_target_properties(uv_a PROPERTIES OUTPUT_NAME "uv")
  • set_target_properties(uv_a PROPERTIES OUTPUT_NAME "uv")
  • The changes to the package config template.

I don't think this part fixes anything, even in MSVC, as that repro I posted on the issue is testing exactly that configuration.

if(MSVC)
  set_target_properties(uv_a PROPERTIES PREFIX "lib")
endif()

That also imposing an unixism on windows. On windows, libs don't use a lib prefix and cmake takes well care that this is modelled correctly.

bnoordhuis added a commit to bnoordhuis/libuv that referenced this pull request Oct 1, 2023
vtjnash added a commit that referenced this pull request Oct 27, 2023
This makes cmake more consistent about how to name this file, otherwise
sometimes it names it uv.lib and sometimes libuv.a depending on which
compiler is selected or if ./configure is used.

Refs: #2085 (comment)
vtjnash added a commit that referenced this pull request Oct 29, 2023
This makes cmake more consistent about how to name this file, otherwise
sometimes it names it uv.lib and sometimes libuv.a depending on which
compiler is selected or if ./configure is used.

Refs: #2085 (comment)
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.