From 1070d19d25b456bcae538c3e872cf3b37c9a2542 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Thu, 16 May 2024 13:31:13 +0700 Subject: [PATCH 1/6] rustup: new package, 1.28.1 --- mingw-w64-rustup/PKGBUILD | 101 ++++++++++++++++++++++ mingw-w64-rustup/aws-lc-clang-build.patch | 46 ++++++++++ mingw-w64-rustup/post.install | 8 ++ mingw-w64-rustup/rustup-profile.sh | 7 ++ 4 files changed, 162 insertions(+) create mode 100644 mingw-w64-rustup/PKGBUILD create mode 100644 mingw-w64-rustup/aws-lc-clang-build.patch create mode 100644 mingw-w64-rustup/post.install create mode 100644 mingw-w64-rustup/rustup-profile.sh diff --git a/mingw-w64-rustup/PKGBUILD b/mingw-w64-rustup/PKGBUILD new file mode 100644 index 0000000000000..879a016bbf9bb --- /dev/null +++ b/mingw-w64-rustup/PKGBUILD @@ -0,0 +1,101 @@ +_realname=rustup +pkgbase=mingw-w64-${_realname} +pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") +pkgver=1.28.1 +pkgrel=1 +pkgdesc="The Rust toolchain installer (mingw-w64)" +arch=('x86_64') +mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') +url="https://github.com/rust-lang/rustup" +license=('spdx:Apache-2.0 AND MIT') +msys2_references=( + 'archlinux: rustup' +) +depends=( + "${MINGW_PACKAGE_PREFIX}-curl" + "${MINGW_PACKAGE_PREFIX}-xz" + "${MINGW_PACKAGE_PREFIX}-zstd" +) +makedepends=( + "git" + "${MINGW_PACKAGE_PREFIX}-rust" + "${MINGW_PACKAGE_PREFIX}-rust-bindgen" + "${MINGW_PACKAGE_PREFIX}-cmake" + "${MINGW_PACKAGE_PREFIX}-nasm" +) +optdepends=( + "${MINGW_PACKAGE_PREFIX}-gdb: rust-gdb script" + "${MINGW_PACKAGE_PREFIX}-lldb: rust-lldb script" +) +provides=("${MINGW_PACKAGE_PREFIX}-rust") +conflicts=("${MINGW_PACKAGE_PREFIX}-rust") +install='post.install' +options=("!lto") +source=( + "rustup-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz" + "git+https://github.com/aws/aws-lc-rs#tag=aws-lc-sys/v0.27.1" + "git+https://github.com/aws/aws-lc.git" + "aws-lc-clang-build.patch" # stolen from https://github.com/msys2/MINGW-packages/blob/911c06155de002672b27b3c8bbe893615250b6bf/mingw-w64-zed/aws-lc-clang-build.patch + "rustup-profile.sh" +) +sha256sums=('2def2f9a0a4a21c80f862c0797c2d76e765e0e7237e1e41f28324722ab912bac' + '5f564de6fb744db858d50ca3a1f0ce737f3d505fea7023c12d3cea3f61eaa20b' + 'SKIP' + '2e3d7ef6fdb3ef8a2ec11207e8120ea34553888116ea8a032cb425a8a6261c39' + 'dec8fd8b2838e7e5866a0bfbae2be89647c7c70a46c0ada1406accf4017322e9') +_binlinks=('cargo' 'rustc' 'rustdoc' 'rust-gdb' 'rust-lldb' 'rustfmt' 'cargo-fmt' 'cargo-clippy' 'clippy-driver' 'cargo-miri') + +prepare() { + (cd aws-lc-rs + git config submodule."aws-lc-sys/aws-lc".url "${srcdir}/aws-lc" + git config submodule."aws-lc-fips-sys/aws-lc".url "${srcdir}/aws-lc" + git -c protocol.file.allow=always submodule update --init --recursive) + + if [[ "${CC}" == 'clang' ]]; then + #true + patch -d "${srcdir}/aws-lc-rs/aws-lc-sys/aws-lc" -Np1 -i "${srcdir}/aws-lc-clang-build.patch" + fi + + cd "${_realname}-${pkgver}" + + cat >> Cargo.toml < "${pkgdir}/${MINGW_PREFIX}/share/bash-completion/completions/rustup" + "${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions bash cargo > "${pkgdir}/${MINGW_PREFIX}/share/bash-completion/completions/cargo" + mkdir -p "${pkgdir}/${MINGW_PREFIX}/share/fish/vendor_completions.d" + "${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions fish > "${pkgdir}/${MINGW_PREFIX}/share/fish/vendor_completions.d/rustup.fish" + mkdir -p "${pkgdir}/${MINGW_PREFIX}/share/zsh/site-functions" + "${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions zsh > "${pkgdir}/${MINGW_PREFIX}/share/zsh/site-functions/_rustup" + "${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions zsh cargo > "${pkgdir}/${MINGW_PREFIX}/share/zsh/site-functions/_cargo" + + install -Dm644 LICENSE-MIT "${pkgdir}/${MINGW_PREFIX}/share/licenses/${pkgname}/LICENSE-MIT" + install -Dm644 LICENSE-APACHE "${pkgdir}/${MINGW_PREFIX}/share/licenses/${pkgname}/LICENSE-APACHE" +} diff --git a/mingw-w64-rustup/aws-lc-clang-build.patch b/mingw-w64-rustup/aws-lc-clang-build.patch new file mode 100644 index 0000000000000..d958bb72366c8 --- /dev/null +++ b/mingw-w64-rustup/aws-lc-clang-build.patch @@ -0,0 +1,46 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fcb8c928e..d283a6ed4 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -399,7 +399,7 @@ if(GCC OR CLANG) + set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-deprecated-declarations") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra") +- set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common") ++ set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common -fms-extensions") + set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wno-newline-eof") + endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow") +diff --git a/crypto/internal.h b/crypto/internal.h +index 4e42bb5b5..cb74fac23 100644 +--- a/crypto/internal.h ++++ b/crypto/internal.h +@@ -141,7 +141,7 @@ + #endif + + #if defined(OPENSSL_THREADS) && \ +- (!defined(OPENSSL_WINDOWS) || defined(__MINGW32__)) ++ (!defined(OPENSSL_WINDOWS) || defined(__MINGW32__) && !defined(__clang__)) + #include + #define OPENSSL_PTHREADS + #endif +diff --git a/crypto/thread_win.c b/crypto/thread_win.c +index 9a1f8045e..0606e6db0 100644 +--- a/crypto/thread_win.c ++++ b/crypto/thread_win.c +@@ -146,6 +146,7 @@ static void NTAPI thread_local_destructor(PVOID module, DWORD reason, + // optimization from discarding the variable. + // + // Note, in the prefixed build, |p_thread_callback_boringssl| may be a macro. ++#ifdef _MSC_VER + #define STRINGIFY(x) #x + #define EXPAND_AND_STRINGIFY(x) STRINGIFY(x) + #ifdef _WIN64 +@@ -157,6 +158,7 @@ __pragma(comment(linker, "/INCLUDE:__tls_used")) + __pragma(comment( + linker, "/INCLUDE:_" EXPAND_AND_STRINGIFY(p_thread_callback_boringssl))) + #endif ++#endif + + // .CRT$XLA to .CRT$XLZ is an array of PIMAGE_TLS_CALLBACK pointers that are + // called automatically by the OS loader code (not the CRT) when the module is diff --git a/mingw-w64-rustup/post.install b/mingw-w64-rustup/post.install new file mode 100644 index 0000000000000..8e914a5e63923 --- /dev/null +++ b/mingw-w64-rustup/post.install @@ -0,0 +1,8 @@ +post_install() { + echo "You may need to run 'rustup update stable'" + echo "and possibly also 'rustup self upgrade-data'" +} + +post_upgrade() { + echo "You may need to run 'rustup self upgrade-data'" +} diff --git a/mingw-w64-rustup/rustup-profile.sh b/mingw-w64-rustup/rustup-profile.sh new file mode 100644 index 0000000000000..2554e9ee4e275 --- /dev/null +++ b/mingw-w64-rustup/rustup-profile.sh @@ -0,0 +1,7 @@ +case ":$PATH" in + *:"${MINGW_PREFIX}/lib/rustup/bin":*) + ;; + *) + PATH="${PATH:+$PATH:}${MINGW_PREFIX}/lib/rustup/bin" +esac +export PATH From e49a077c2211f8674cd0704fd3ec32a7e122cf90 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Tue, 15 Apr 2025 08:15:41 +0700 Subject: [PATCH 2/6] rustup: move profile script to environment /etc --- mingw-w64-rustup/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-rustup/PKGBUILD b/mingw-w64-rustup/PKGBUILD index 879a016bbf9bb..e69585c64070a 100644 --- a/mingw-w64-rustup/PKGBUILD +++ b/mingw-w64-rustup/PKGBUILD @@ -84,7 +84,7 @@ package() { # Special treatment to allow for rust-analyzer to still allow the separate package version to be used. ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin/rust-analyzer.exe" - install -Dm644 "${srcdir}/rustup-profile.sh" "${pkgdir}/etc/profile.d/rustup.sh" + install -Dm644 "${srcdir}/rustup-profile.sh" "${pkgdir}/${MINGW_PREFIX}/etc/profile.d/rustup.sh" # Generate completion files. mkdir -p "${pkgdir}/${MINGW_PREFIX}/share/bash-completion/completions" From 88b80c04951261ff07396e9452361bb65449b3a2 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Tue, 15 Apr 2025 08:16:50 +0700 Subject: [PATCH 3/6] rustup: change copies to hardlinks --- mingw-w64-rustup/PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mingw-w64-rustup/PKGBUILD b/mingw-w64-rustup/PKGBUILD index e69585c64070a..38563f2a3d914 100644 --- a/mingw-w64-rustup/PKGBUILD +++ b/mingw-w64-rustup/PKGBUILD @@ -78,11 +78,11 @@ package() { install -d "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin" install -Dm755 "target/release/rustup-init" "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" for link in "${_binlinks[@]}"; do - ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/bin/${link}.exe" + MSYS=winsymlinks:native ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/bin/${link}.exe" done # Special treatment to allow for rust-analyzer to still allow the separate package version to be used. - ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin/rust-analyzer.exe" + MSYS=winsymlinks:native ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin/rust-analyzer.exe" install -Dm644 "${srcdir}/rustup-profile.sh" "${pkgdir}/${MINGW_PREFIX}/etc/profile.d/rustup.sh" From f5a7477d0a563697bd203dc88528bb8114f4fcbe Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Tue, 15 Apr 2025 19:09:10 +0700 Subject: [PATCH 4/6] rustup: simplify ln call MSYS=winsymlinks:native not needed for hard links --- mingw-w64-rustup/PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mingw-w64-rustup/PKGBUILD b/mingw-w64-rustup/PKGBUILD index 38563f2a3d914..e69585c64070a 100644 --- a/mingw-w64-rustup/PKGBUILD +++ b/mingw-w64-rustup/PKGBUILD @@ -78,11 +78,11 @@ package() { install -d "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin" install -Dm755 "target/release/rustup-init" "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" for link in "${_binlinks[@]}"; do - MSYS=winsymlinks:native ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/bin/${link}.exe" + ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/bin/${link}.exe" done # Special treatment to allow for rust-analyzer to still allow the separate package version to be used. - MSYS=winsymlinks:native ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin/rust-analyzer.exe" + ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin/rust-analyzer.exe" install -Dm644 "${srcdir}/rustup-profile.sh" "${pkgdir}/${MINGW_PREFIX}/etc/profile.d/rustup.sh" From c948530396bcf01cded62e74e2ee79bd6134d54f Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Tue, 15 Apr 2025 19:37:04 +0700 Subject: [PATCH 5/6] rustup: remove clangarm64 support rustup/rustc only supports arm64 msvc anyway, but not arm64 gnu/gnullvm --- mingw-w64-rustup/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mingw-w64-rustup/PKGBUILD b/mingw-w64-rustup/PKGBUILD index e69585c64070a..ccacd2a28e66e 100644 --- a/mingw-w64-rustup/PKGBUILD +++ b/mingw-w64-rustup/PKGBUILD @@ -5,7 +5,7 @@ pkgver=1.28.1 pkgrel=1 pkgdesc="The Rust toolchain installer (mingw-w64)" arch=('x86_64') -mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') +mingw_arch=('mingw64' 'ucrt64' 'clang64') url="https://github.com/rust-lang/rustup" license=('spdx:Apache-2.0 AND MIT') msys2_references=( From 5bc7d1d284f912edca75b169363f151e46a33da2 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Wed, 16 Apr 2025 11:42:13 +0700 Subject: [PATCH 6/6] rustup: cleanup comments --- mingw-w64-rustup/PKGBUILD | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mingw-w64-rustup/PKGBUILD b/mingw-w64-rustup/PKGBUILD index ccacd2a28e66e..f7dd562d1c493 100644 --- a/mingw-w64-rustup/PKGBUILD +++ b/mingw-w64-rustup/PKGBUILD @@ -35,7 +35,7 @@ source=( "rustup-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz" "git+https://github.com/aws/aws-lc-rs#tag=aws-lc-sys/v0.27.1" "git+https://github.com/aws/aws-lc.git" - "aws-lc-clang-build.patch" # stolen from https://github.com/msys2/MINGW-packages/blob/911c06155de002672b27b3c8bbe893615250b6bf/mingw-w64-zed/aws-lc-clang-build.patch + "aws-lc-clang-build.patch" # taken from https://github.com/msys2/MINGW-packages/blob/911c06155de002672b27b3c8bbe893615250b6bf/mingw-w64-zed/aws-lc-clang-build.patch "rustup-profile.sh" ) sha256sums=('2def2f9a0a4a21c80f862c0797c2d76e765e0e7237e1e41f28324722ab912bac' @@ -52,7 +52,6 @@ prepare() { git -c protocol.file.allow=always submodule update --init --recursive) if [[ "${CC}" == 'clang' ]]; then - #true patch -d "${srcdir}/aws-lc-rs/aws-lc-sys/aws-lc" -Np1 -i "${srcdir}/aws-lc-clang-build.patch" fi