Skip to content

Commit

Permalink
Updates for patch files and minor build script tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchcapper committed Nov 27, 2024
1 parent 81dcf97 commit 2eba319
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 448 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/do_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ env:

jobs:
build:
name: ${{ inputs.BuildPkg == 'script' && 'Run Script' || 'Build Package' }}
name: ${{ inputs.BuildPkg == 'script' && 'Run Script' || 'Build Package' }} - ${{matrix.Configuration}}
runs-on: windows-2022
environment: main
outputs:
Expand All @@ -45,7 +45,7 @@ jobs:
#BuildPkg: [grep]
# BuildPkg: [which,patch,zstd,pcre2,gzip,tar,zlib,findutils,libpsl,coreutils,grep]
BaseImage: [windows-latest]
Configuration: [Debug]
Configuration: [Debug, Release] #right now the deps downloader always downloads release versions, we could use our debug libs for debug builds
Arch: [x64]
#BaseImage: [windows-latest, ubuntu-latest]
#Configuration: [Debug, Release]
Expand All @@ -63,6 +63,7 @@ jobs:
env:
BUILD_PKG: ${{inputs.BuildPkg}}
SCRIPT: ${{inputs.Script}}
Configuration: ${{matrix.Configuration}}
steps:
- uses: actions/[email protected]
with:
Expand All @@ -73,6 +74,9 @@ jobs:
$dir=$dir.replace("\","/")
echo "WLB_SCRIPT_FOLDER=$dir" >> $env:GITHUB_ENV
mkdir $env:WLB_BASE_FOLDER
if ($env:Configuration -eq "Debug"){
echo "BLD_CONFIG_BUILD_DEBUG=1" >> $env:GITHUB_ENV
}
# - uses: actions/[email protected]
# with:
Expand Down Expand Up @@ -139,7 +143,7 @@ jobs:
if: ${{ inputs.BuildPkg != 'script' }}
shell: powershell
working-directory: ${{env.WLB_BASE_FOLDER}}
run: ${{env.WLB_SCRIPT_FOLDER}}/vs_msys_shell_launch.ps1 "${{env.WLB_SCRIPT_FOLDER}}/build/f_$($env:BUILD_PKG)_build.sh"
run: ${{env.WLB_SCRIPT_FOLDER}}/vs_msys_shell_launch.ps1 "${{env.WLB_SCRIPT_FOLDER}}/build/f_$($env:BUILD_PKG)_build.sh" log_raw_build #raw build gets us a .bat file for compiling, without msys but runs make -j 1 so is much slower than without

- name: Run Script
id: script_step
Expand All @@ -155,6 +159,6 @@ jobs:
- uses: actions/[email protected]
if: ${{ inputs.BuildPkg != 'script' }}
with:
name: WLB-${{env.BUILD_PKG}}
name: WLB-${{env.BUILD_PKG}}${{matrix.Configuration=='Debug' && '-Debug' || ''}}
path: ${{env.WLB_BASE_FOLDER}}/${{env.BUILD_PKG}}/final
if-no-files-found: error
16 changes: 16 additions & 0 deletions WIN64LinuxBuild.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.associations": {
"*.json": "jsonc",
"config.h": "c",
"vmsdir.h": "c",
"*.pc": "c",
"types.h": "c"
}
}
}
81 changes: 81 additions & 0 deletions build/f_rsync_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

OUR_PATH="$(readlink -f "$0")";
CALL_CMD="$1"

SCRIPT_FOLDER="$(dirname "${OUR_PATH}")"
if [[ ! -z "$WLB_SCRIPT_FOLDER" ]]; then
SCRIPT_FOLDER="${WLB_SCRIPT_FOLDER}"
fi
. "$SCRIPT_FOLDER/helpers.sh" "${CALL_CMD}" "${OUR_PATH}"

PreInitialize;
#BLD_CONFIG_LOG_ON_AT_INIT=0


BLD_CONFIG_BUILD_NAME="rsync";
BLD_CONFIG_CONFIG_CMD_ADDL="--enable-lz4 --disable-md2man" #--disable-nls --enable-static
BLD_CONFIG_ADD_WIN_ARGV_LIB=0
#BLD_CONFIG_GNU_LIBS_USED=0
#BLD_CONFIG_GNU_LIBS_BUILD_AUX_ONLY_USED=1
#BLD_CONFIG_LOG_FILE_AUTOTAIL=0

#BLD_CONFIG_LOG_EXPAND_VARS=1
BLD_CONFIG_GNU_LIBS_ADDL=( "getsockopt" "strcase" "strerror" "getaddrinfo" "setsockopt" "sleep" "getsockname" "getpeername" "ioctl" "alloca" "alloca-opt" "socket" "bind" "symlink" "unistd" "fsync" "gettimeofday" "sys_socket" "lock" "flock" "signal-h" "sys_ioctl" "symlink" "symlinkat" "unlinkat" "netinet_in" "arpa_inet" "dirent" "sys_stat" "sys_types" "sys_file" "stdbool" "stat-time" "dirname" "attribute" "dirfd" "dup2" "readlink" "stat-macros" "lstat" "stat-size" "stat-time" "open" "openat" "stdopen" "fcntl" "fcntl-h" "errno" )

# Set DO_EXPAND_OF_LOGGED_VARS=1 # set this to expand vars in log - so this works well but this is the only way I found to properly log the current command in a reproducible form. It is exceptionally slow.
# after including this script have:
function ourmain() {
startcommon;
#CFLAGS="-I ./lib/"
add_lib_pkg_config "zstd"
add_vcpkg_pkg_config "openssl" "xxhash" "lz4"
pkg_config_manual_add "libzstd" "openssl" "libxxhash" "liblz4"

if test 5 -gt 100; then
echo "Just move the fi down as you want to skip steps"
#fi

git clone --recurse-submodules https://github.com/WayneD/rsync.git .

git clone --recurse-submodules https://github.com/coreutils/gnulib
cp gnulib/build-aux/bootstrap .
cp gnulib/build-aux/bootstrap.conf .
#it doesn't use extras so we can just ad ours, they use paxutils to gnulib everyhting
echo "gnulib_tool_option_extras=\" --without-tests --symlink\"" >> bootstrap.conf
gnulib_switch_to_master_and_patch;
fi
gnulib_add_addl_modules_to_bootstrap;

setup_gnulibtool_py_autoconfwrapper #needed for generated .mk/.ac files but if just stock then the below line likely works
#gnulib_tool_py_remove_nmd_makefiles;
./bootstrap --no-bootstrap-sync --no-git --gnulib-srcdir=gnulib --skip-po --force

add_items_to_gitignore;

cd $BLD_CONFIG_SRC_FOLDER
vcpkg_install_package "openssl" "xxhash" "lz4"
# pkg_config_manual_add "libzstd" "openssl" "libxxhash" "liblz4"
#fi

#not sure why we have to do this somethinng isnnt autogening right or nwe need lib moved up in the make order
cp c:/software/gnulib/build-aux/compile "${BLD_CONFIG_BUILD_AUX_FOLDER}/"
#sometimes runnning make requires re-running make
#

cd $BLD_CONFIG_SRC_FOLDER
#fi
configure_fixes;
configure_run || (./config.status --recheck && configure_run);


setup_build_env;
cd $BLD_CONFIG_SRC_FOLDER/lib && (make || make)
cd $BLD_CONFIG_SRC_FOLDER
make
make install

finalcommon;
}
ourmain;

3 changes: 2 additions & 1 deletion build/f_wget2_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ fi
fi
BZIP_INCL=`pkg-config -cflags-only-I bzip2`
BZIP_LIB=`pkg-config --libs-only-L bzip2`
export CFLAGS="-DLIBWGET_STATIC -DOPENSSL_EXTRA -DHSTS_STATIC -DLZMA_API_STATIC -DKEEP_OUR_CERT -DHAVE_SSIZE_T -D_WIN64 ${BZIP_INCL} $CFLAGS"
# MSVC_INVALID_PARAMETER_HANDLING value of 1 is hairy handling
export CFLAGS="-DLIBWGET_STATIC -DOPENSSL_EXTRA -DHSTS_STATIC -DLZMA_API_STATIC -DMSVC_INVALID_PARAMETER_HANDLING=1 -DKEEP_OUR_CERT -DHAVE_SSIZE_T -D_WIN64 ${BZIP_INCL} $CFLAGS"
export LDFLAGS="${BZIP_LIB} $LDFLAGS"

cd $BLD_CONFIG_SRC_FOLDER
Expand Down
4 changes: 2 additions & 2 deletions patches/patches_GNULIB_BUILD_AUX_HANDLE_DOT_A_LIBS.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/build-aux/ar-lib b/build-aux/ar-lib
index 17de55e79c..33f0b676ef 100755
index 17de55e79c..33f0b676ef 100644
--- a/build-aux/ar-lib
+++ b/build-aux/ar-lib
@@ -1,6 +1,11 @@
Expand Down Expand Up @@ -104,7 +104,7 @@ index 17de55e79c..33f0b676ef 100755
+ func_ar_run -LIST ${COLOR_MAJOR}"$archive"${COLOR_NONE}
fi
diff --git a/build-aux/compile b/build-aux/compile
index ba883b54aa..4e9157a535 100755
index ba883b54aa..4e9157a535 100644
--- a/build-aux/compile
+++ b/build-aux/compile
@@ -1,5 +1,10 @@
Expand Down
4 changes: 2 additions & 2 deletions patches/patches_GNULIB_FTS_MINOR_FIXES.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/lib/fts.c b/lib/fts.c
index 875fe05793..8ef8ed8347 100644
index faeb4b20a5..f2bb85552a 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -123,6 +123,9 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
Expand All @@ -12,7 +12,7 @@ index 875fe05793..8ef8ed8347 100644

enum
{
@@ -1867,7 +1870,7 @@ fts_sort (FTS *sp, FTSENT *head, register size_t nitems)
@@ -1864,7 +1867,7 @@ fts_sort (FTS *sp, FTSENT *head, register size_t nitems)
FTSENT *dummy;
int (*compare) (void const *, void const *) =
((sizeof &dummy == sizeof (void *)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/gnulib-tool b/gnulib-tool
index ae1b17f4dd..7b38761978 100755
index ae1b17f4dd..7b38761978 100644
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -1793,7 +1793,7 @@ func_lookup_file ()
Expand Down
12 changes: 12 additions & 0 deletions patches/patches_GNULIB_MSVC_PARAMETER_HANDLER_M4_MACRO_FIX.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/m4/printf.m4 b/m4/printf.m4
index 8b8f01067f..198e3363b7 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -908,6 +908,7 @@ int main ()
{
int count = -1;
#ifdef _MSC_VER
+ _set_error_mode(1); #1 being _OUT_TO_STDERR, disable abort/retry/ignore popup in debug mode
_set_invalid_parameter_handler (invalid_parameter_handler);
#endif
/* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
2 changes: 1 addition & 1 deletion patches/patches_GNULIB_PHYSMEM_TEST_MAIN_RENAME.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/lib/physmem.c b/lib/physmem.c
index f450587141..1039786f55 100644
index 398f99b727..15a3f0898e 100644
--- a/lib/physmem.c
+++ b/lib/physmem.c
@@ -313,7 +313,7 @@ physmem_available (void)
Expand Down
93 changes: 93 additions & 0 deletions patches/patches_GNULIB_WIN32_POLL_FIXES.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
diff --git a/lib/poll.c b/lib/poll.c
index ec8d2c2b55..80a68aff03 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -364,6 +364,11 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds)
}
#endif /* !MinGW */

+#ifdef _WIN32
+#define THREAD_LOCAL static __declspec( thread )
+#else
+#define THREAD_LOCAL static thread_local
+#endif
int
poll (struct pollfd *pfd, nfds_t nfd, int timeout)
{
@@ -463,11 +468,13 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
return rc;
#else
static struct timeval tv0;
- static HANDLE hEvent;
+ THREAD_LOCAL HANDLE hEvent; //note if you don't want to use thread local and this could be called from multiple threads you should make this a standard local var and use CloseHandle before any returns
WSANETWORKEVENTS ev;
HANDLE h, handle_array[FD_SETSIZE + 2];
DWORD ret, wait_timeout, nhandles;
fd_set rfds, wfds, xfds;
+ fd_set orig_rfds, orig_wfds, orig_xfds;
+
BOOL poll_again;
MSG msg;
int rc = 0;
@@ -539,6 +546,9 @@ restart:
timeout = 0;
}
}
+ orig_rfds = rfds;
+ orig_wfds = wfds;
+ orig_xfds = xfds;

if (select (0, &rfds, &wfds, &xfds, &tv0) > 0)
{
@@ -575,8 +585,13 @@ restart:
break;
}

- if (poll_again)
- select (0, &rfds, &wfds, &xfds, &tv0);
+ if (poll_again) {
+ rfds = orig_rfds;
+ wfds = orig_wfds;
+ xfds = orig_xfds;
+ if (select(0, &rfds, &wfds, &xfds, &tv0) == SOCKET_ERROR)
+ return -1;
+ }

/* Place a sentinel at the end of the array. */
handle_array[nhandles] = NULL;
@@ -632,3 +647,21 @@ restart:
return rc;
#endif
}
+#define MIN_TIMEOUT_FIX_MS 50
+int poll_retry(struct pollfd* pfd, nfds_t nfd, int timeout, int max_retries) {
+ DWORD startTime;
+ BOOL retryTrack = timeout > 0 && timeout != INFTIM && timeout > MIN_TIMEOUT_FIX_MS;
+ if (retryTrack)
+ startTime = GetTickCount();
+ int rc = 0;
+ for (int x = 0; x < max_retries; x++) {
+ rc = poll(pfd, nfd, timeout);
+ if (rc != 0 || !retryTrack)
+ return rc;
+ int msElapsed = GetTickCount() - startTime;
+ if (msElapsed < 0 || (timeout - MIN_TIMEOUT_FIX_MS) < msElapsed)//if it got the timing within MIN_TIMEOUT_FIX_MS of the timer consider us good
+ return rc;
+ SleepEx(1, TRUE);
+ }
+ return rc;
+}
\ No newline at end of file
diff --git a/lib/poll.in.h b/lib/poll.in.h
index 75ca21f4cc..2d57f3ffdb 100644
--- a/lib/poll.in.h
+++ b/lib/poll.in.h
@@ -124,7 +124,7 @@ _GL_WARN_ON_USE (poll, "poll is unportable - "
"use gnulib module poll for portability");
# endif
#endif
-
+int poll_retry(struct pollfd* pfd, nfds_t nfd, int timeout, int max_retries);

#endif /* _@GUARD_PREFIX@_POLL_H */
#endif /* _@GUARD_PREFIX@_POLL_H */
6 changes: 3 additions & 3 deletions patches/patches_GNULIB_WINDOWS_SYMLINK_SUPPORT.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ index 372965ef5f..84f2e92044 100644

/* Likewise, if there is no native 'lstat', then the gnulib
diff --git a/lib/fts.c b/lib/fts.c
index 875fe05793..3646ec3e88 100644
index faeb4b20a5..c2f51b2062 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -117,9 +117,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
Expand All @@ -80,7 +80,7 @@ index 875fe05793..3646ec3e88 100644
#ifndef S_IFSOCK
# define S_IFSOCK 0
#endif
@@ -1823,6 +1821,8 @@ fts_stat(FTS *sp, register FTSENT *p, bool follow)
@@ -1820,6 +1818,8 @@ fts_stat(FTS *sp, register FTSENT *p, bool follow)
return FTS_NS;
}

Expand All @@ -89,7 +89,7 @@ index 875fe05793..3646ec3e88 100644
if (S_ISDIR(sbp->st_mode)) {
if (ISDOT(p->fts_name)) {
/* Command-line "." and ".." are real directories. */
@@ -1831,8 +1831,7 @@ fts_stat(FTS *sp, register FTSENT *p, bool follow)
@@ -1828,8 +1828,7 @@ fts_stat(FTS *sp, register FTSENT *p, bool follow)

return (FTS_D);
}
Expand Down
8 changes: 4 additions & 4 deletions patches/patches_GNULIB_WINDOW_PATH_FIXES.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ index 372965ef5f..d5d11accac 100644
errno = ENOTDIR;
return -1;
diff --git a/lib/fts.c b/lib/fts.c
index 875fe05793..e7183ef05e 100644
index faeb4b20a5..526be1600f 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -67,7 +67,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
Expand Down Expand Up @@ -1562,7 +1562,7 @@ index 875fe05793..e7183ef05e 100644
? p->fts_pathlen - 1 : p->fts_pathlen)

FTSENT *
@@ -1007,7 +1007,7 @@ next: tmp = p;
@@ -1006,7 +1006,7 @@ next: tmp = p;
}

name: t = sp->fts_path + NAPPEND(p->fts_parent);
Expand All @@ -1571,7 +1571,7 @@ index 875fe05793..e7183ef05e 100644
memmove(t, p->fts_name, p->fts_namelen + 1);
check_for_dir:
sp->fts_cur = p;
@@ -1163,7 +1163,7 @@ fts_children (register FTS *sp, int instr)
@@ -1159,7 +1159,7 @@ fts_children (register FTS *sp, int instr)
* directory is, so we can't get back so that the upcoming chdir by
* fts_read will work.
*/
Expand All @@ -1580,7 +1580,7 @@ index 875fe05793..e7183ef05e 100644
ISSET(FTS_NOCHDIR))
return (sp->fts_child = fts_build(sp, instr));

@@ -1426,7 +1426,7 @@ fts_build (register FTS *sp, int type)
@@ -1423,7 +1423,7 @@ fts_build (register FTS *sp, int type)
len = NAPPEND(cur);
if (ISSET(FTS_NOCHDIR)) {
cp = sp->fts_path + len;
Expand Down
Loading

0 comments on commit 2eba319

Please sign in to comment.