diff --git a/mingw-w64-rustup/PKGBUILD b/mingw-w64-rustup/PKGBUILD new file mode 100644 index 0000000000..f7dd562d1c --- /dev/null +++ b/mingw-w64-rustup/PKGBUILD @@ -0,0 +1,100 @@ +_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') +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" # taken 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 + 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 0000000000..d958bb7236 --- /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 0000000000..8e914a5e63 --- /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 0000000000..2554e9ee4e --- /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