facebook / proxygen

A collection of C++ HTTP libraries including an easy to use HTTP server.
Other
8.12k stars 1.49k forks source link

getdeps.sh fails on windows when applying patch to boost #510

Open fmoo opened 3 weeks ago

fmoo commented 3 weeks ago

When running getdeps.sh on Windows (via git/mingw bash), I get the following error when it tries to patch boost:

Building on {distro=None, distro_vers=10, fb=off, fbsource=off, os=windows, shared_libs=off, test=on}
Assessing gperf...
Assessing libsodium...
Assessing boost...
Building boost...
Patching boost with boost_comparator_operator_fix.patch in Z:\extracted\boost-boost_1_83_0.zip\boost_1_83_0
error: corrupt patch at line 11
Traceback (most recent call last):
  File "C:\source\proxygen\build\fbcode_builder\getdeps\builder.py", line 138, in _apply_patchfile
    subprocess.check_call(patchcmd + [patchfile])
  File "C:\Tools\Python310\Lib\subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'apply', '--ignore-space-change', 'C:\\source\\proxygen\\build\\fbcode_builder\\patches\\boost_comparator_operator_fix.patch']' returned non-zero exit status 128.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\source\proxygen\build\fbcode_builder\getdeps.py", line 1422, in <module>
    sys.exit(main())
  File "C:\source\proxygen\build\fbcode_builder\getdeps.py", line 1405, in main
    return args.func(args)
  File "C:\source\proxygen\build\fbcode_builder\getdeps.py", line 108, in run
    self.run_project_cmd(args, loader, manifest)
  File "C:\source\proxygen\build\fbcode_builder\getdeps.py", line 671, in run_project_cmd
    builder.build(reconfigure=reconfigure)
  File "C:\source\proxygen\build\fbcode_builder\getdeps\builder.py", line 163, in build
    self._apply_patchfile()
  File "C:\source\proxygen\build\fbcode_builder\getdeps\builder.py", line 140, in _apply_patchfile
    raise ValueError(f"Failed to apply patch to {self.manifest.name}")
ValueError: Failed to apply patch to boost
fmoo commented 3 weeks ago

Updating the second to last line of the patch to include a single whitespace seems to fix it locally for me:

diff --git a/build/fbcode_builder/patches/boost_comparator_operator_fix.patch b/build/fbcode_builder/patches/boost_comparator_operator_fix.patch
index 3771f2fff..45ee266b0 100644
--- a/build/fbcode_builder/patches/boost_comparator_operator_fix.patch
+++ b/build/fbcode_builder/patches/boost_comparator_operator_fix.patch
@@ -8,4 +8,4 @@ diff --git a/boost/serialization/strong_typedef.hpp b/boost/serialization/strong
 +    bool operator==(const T& lhs) const {return t == lhs;}                                                       \
      bool operator<(const D& rhs) const {return t < rhs.t;}                                                       \
  };
-
+ 
fmoo commented 3 weeks ago

Zlib needed four similarly:

diff --git a/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch b/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch
index 2ef115714..134191551 100644
--- a/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch
+++ b/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch
@@ -4,7 +4,7 @@ diff -Naur ../zlib-1.3.1/CMakeLists.txt ./CMakeLists.txt
 @@ -149,10 +149,8 @@
      set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
  endif(MINGW)
-
+ 
 -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
 +add_library(zlib ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
@@ -12,9 +12,9 @@ diff -Naur ../zlib-1.3.1/CMakeLists.txt ./CMakeLists.txt
 -target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
  set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
  set_target_properties(zlib PROPERTIES SOVERSION 1)
-
+ 
 @@ -169,7 +167,7 @@
-
+ 
  if(UNIX)
      # On unix-like platforms the library is almost always called libz
 -   set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
@@ -24,7 +24,7 @@ diff -Naur ../zlib-1.3.1/CMakeLists.txt ./CMakeLists.txt
     endif()
 @@ -179,7 +177,7 @@
  endif()
-
+ 
  if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
 -    install(TARGETS zlib zlibstatic
 +    install(TARGETS zlib
fmoo commented 3 weeks ago

Zlib needed four similarly:

diff --git a/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch b/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch
index 2ef115714..134191551 100644
--- a/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch
+++ b/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch
@@ -4,7 +4,7 @@ diff -Naur ../zlib-1.3.1/CMakeLists.txt ./CMakeLists.txt
 @@ -149,10 +149,8 @@
      set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
  endif(MINGW)
-
+ 
 -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
 +add_library(zlib ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
  target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
@@ -12,9 +12,9 @@ diff -Naur ../zlib-1.3.1/CMakeLists.txt ./CMakeLists.txt
 -target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
  set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
  set_target_properties(zlib PROPERTIES SOVERSION 1)
-
+ 
 @@ -169,7 +167,7 @@
-
+ 
  if(UNIX)
      # On unix-like platforms the library is almost always called libz
 -   set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
@@ -24,7 +24,7 @@ diff -Naur ../zlib-1.3.1/CMakeLists.txt ./CMakeLists.txt
     endif()
 @@ -179,7 +177,7 @@
  endif()
-
+ 
  if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
 -    install(TARGETS zlib zlibstatic
 +    install(TARGETS zlib
fmoo commented 3 weeks ago

After this, I got all the way up to folly, which failed with:

CMake Error at C:/source/proxygen/_build/boost-Ct8ZMk_J_pyqyHLfrydelwvlfzw-NfC_5D8VmaRrOvw/lib/cmake/Boost-1.83.0/BoostConfig.cmake:141 (find_package):
  Found package configuration file:

    C:/source/proxygen/_build/boost-Ct8ZMk_J_pyqyHLfrydelwvlfzw-NfC_5D8VmaRrOvw/lib/cmake/boost_context-1.83.0/boost_context-config.cmake

  but it set boost_context_FOUND to FALSE so package "boost_context" is
  considered to be NOT FOUND.  Reason given by package:

  No suitable build variant has been found.

  The following variants have been tried and rejected:

  * boost_context-vc143-mt-x64-1_83.lib (vc143, detected vc141, set
  Boost_COMPILER to override)

  * libboost_context-vc143-mt-x64-1_83.lib (vc143, detected vc141, set
  Boost_COMPILER to override)

Call Stack (most recent call first):
  C:/source/proxygen/_build/boost-Ct8ZMk_J_pyqyHLfrydelwvlfzw-NfC_5D8VmaRrOvw/lib/cmake/Boost-1.83.0/BoostConfig.cmake:262 (boost_find_component)
  C:/source/proxygen/_build/cmake-EFTozGEkm4tQR_57fvLQiFbFunALgAvRSIBuLcqKKpc/share/cmake-3.20/Modules/FindBoost.cmake:594 (find_package)
  CMake/folly-deps.cmake:38 (find_package)
  CMakeLists.txt:133 (include)

-- Configuring incomplete, errors occurred!
See also "Z:/build/folly/CMakeFiles/CMakeOutput.log".
See also "Z:/build/folly/CMakeFiles/CMakeError.log".
Command '['Z:\\build\\folly\\succeed.bat', '&&', 'C:/source/proxygen/_build/cmake-EFTozGEkm4tQR_57fvLQiFbFunALgAvRSIBuLcqKKpc\\bin\\cmake.exe', 'Z:\\repos\\github.com-facebook-folly.git', '-DCMAKE_INSTALL_PREFIX=C:/source/proxygen/_build/folly', '-DBUILD_SHARED_LIBS=OFF', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DBOOST_LINK_STATIC=ON', '-DBUILD_TESTS=OFF', '-DBUILD_BENCHMARKS=OFF', '-G', 'Ninja']' returned non-zero exit status 1.
!! Failed

CMakeError.log CMakeOutput.log

lmk if I should open a separate issue for that or what.