Skip to content

rustup: new, 1.28.1 #20989

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

Merged
merged 6 commits into from
Apr 16, 2025
Merged

rustup: new, 1.28.1 #20989

merged 6 commits into from
Apr 16, 2025

Conversation

500-internal-server-error
Copy link
Contributor

Supersedes #20923

Forgot to do the work in a separate branch, updating master on my fork caused merge conflicts :)

@ArchGuyWu
Copy link
Contributor

It seems that symlinking issue will be resolved when this gets merged.

@mati865
Copy link
Collaborator

mati865 commented Aug 4, 2024

I thought so initially but I'm bot sure if all the tools will handle symlinks properly. This largerly depnds on Cygwin and will require manual testing.

@500-internal-server-error
Copy link
Contributor Author

Until then, would hard linking as this package does be an acceptable solution? It still gains the space savings and still avoids the requiring admin perms problem.

@ArchGuyWu
Copy link
Contributor

Until then, would hard linking as this package does be an acceptable solution? It still gains the space savings and still avoids the requiring admin perms problem.

I think you can try to create symlink in post-install, if it fails then create *.sh and *.cmd.

@500-internal-server-error 500-internal-server-error changed the title rustup: new, 1.27.1 rustup: new, 1.28.1 Apr 14, 2025
@ognevny
Copy link
Collaborator

ognevny commented Apr 14, 2025

I see you didn't apply a patch to properly build aws-lc-sys in clang: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-zed/aws-lc-clang-build.patch

@500-internal-server-error
Copy link
Contributor Author

Where should I patch it? I don't see an obvious place, the path used that example does not exist here.

@ognevny
Copy link
Collaborator

ognevny commented Apr 14, 2025

Where should I patch it? I don't see an obvious place, the path used that example does not exist here.

  1. add git to makedepends
  2. vendor aws-lc and aws-lc-rs sources, add this to source
"git+https://github.com/aws/aws-lc-rs.git#tag=aws-lc-sys/v0.27.1"
"git+https://github.com/aws/aws-lc.git"
  1. manage submodules of aws-lc-rs
(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)
  1. apply patch with
if [[ ${CC} == clang ]]; then
  patch -d "${srcdir}/aws-lc-rs/aws-lc-sys/aws-lc" -p1 -i "${srcdir}/aws-lc-clang-build.patch"
fi
  1. patching lockfiles can be hard, better remove your patch and add
cat >> Cargo.toml <<END

[patch.crates-io]
aws-lc-sys = { path = "../aws-lc-rs/aws-lc-sys" }
END

cargo update -p aws-lc-sys -p aws-lc-rs --precise 1.12.6

or... use this PKGBUILD:

PKGBUILD
_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=(
	"${MINGW_PACKAGE_PREFIX}-rust"
	"${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.git#tag=aws-lc-sys/v0.27.1"
	"git+https://github.com/aws/aws-lc.git"
	"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" -p1 -i "${srcdir}/aws-lc-clang-build.patch"
  fi

	cd "${_realname}-${pkgver}"

	cat >> Cargo.toml <<END

[patch.crates-io]
aws-lc-sys = { path = "../aws-lc-rs/aws-lc-sys" }
END

  cargo update -p aws-lc-rs --precise 1.12.6
	cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
	cd "${_realname}-${pkgver}"
	cargo build --release --frozen --features no-self-update --bin rustup-init
}

package() {
	cd "${_realname}-${pkgver}"
	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"
	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"

	install -Dm644 "${srcdir}/rustup-profile.sh" "${pkgdir}/etc/profile.d/rustup.sh"

	# Generate completion files.
	mkdir -p "${pkgdir}/${MINGW_PREFIX}/share/bash-completion/completions"
	"${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions bash > "${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"
}

but, I wanted to see one more thing changed... I'll leave a review

Copy link
Collaborator

@ognevny ognevny left a comment

Choose a reason for hiding this comment

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

is it possible to just copy rustup.exe to _binlinks? e.g.

cp "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/bin/${link}.exe"

it's common practice for our packages, gcc example. yes, it will use much disk space, but this is the only option we can use...

@500-internal-server-error
Copy link
Contributor Author

500-internal-server-error commented Apr 14, 2025

is it possible to just copy rustup.exe to _binlinks? e.g.

cp "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/bin/${link}.exe"

it's common practice for our packages, gcc example. yes, it will use much disk space, but this is the only option we can use...

Hard links have been around for a very long time (CreateHardLink() API since Win2K, CMD mklink support since Vista, PS New-Item support since Win8), can we not use them? It still saves space, and is available by default, unlike symlinks. Anyways, I've replaced the lns with cps.

@ognevny
Copy link
Collaborator

ognevny commented Apr 14, 2025

Hard links have been around for a very long time (CreateHardLink() API since Win2K, CMD mklink support since Vista, PS New-Item support since Win8), can we not use them? It still saves space, and is available by default, unlike symlinks. Anyways, I've replaced the lns with cps.

I thoght a bit more about this, I can try the package with hard links. but is environment variable setting required? (I almost had no experience with changing MSYS env)

@500-internal-server-error
Copy link
Contributor Author

Unfortunately I've changed the links to copies, and it'll be a while before I can revert them. But no, no changes required by the end user, only while building the package (I set it to MSYS=winsymlinks:native for my personal builds).

@ognevny
Copy link
Collaborator

ognevny commented Apr 14, 2025

Unfortunately I've changed the links to copies, and it'll be a while before I can revert them. But no, no changes required by the end user, only while building the package (I set it to MSYS=winsymlinks:native for my personal builds).

I should have rights to edit your branch, so no worries

@ognevny
Copy link
Collaborator

ognevny commented Apr 14, 2025

ahh, fails like before

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\msys64\\tmp\\rustciR9UQD\\symbols.o" "<3 object files omitted>" "-Wl,-Bstatic" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-ldbghelp" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmingwex" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-o" "C:\\msys64\\home\\maksa\\forks\\500ise-MINGW\\mingw-w64-rustup\\src\\rustup-1.28.1\\target\\release\\build\\proc-macro2-06a3aa365bbe001c\\build_script_build-06a3aa365bbe001c.exe" "-Wl,--gc-sections" "-no-pie" "-Wl,--strip-debug" "-nodefaultlibs" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: x86_64-w64-mingw32-gcc: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]␍
          lld: error: unable to find library -lgcc_eh␍
          lld: error: unable to find library -lgcc␍
          x86_64-w64-mingw32-gcc: error: linker command failed with exit code 1 (use -v to see invocation)␍

@ognevny
Copy link
Collaborator

ognevny commented Apr 14, 2025

ahh, fails like before

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\msys64\\tmp\\rustciR9UQD\\symbols.o" "<3 object files omitted>" "-Wl,-Bstatic" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-ldbghelp" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmingwex" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-o" "C:\\msys64\\home\\maksa\\forks\\500ise-MINGW\\mingw-w64-rustup\\src\\rustup-1.28.1\\target\\release\\build\\proc-macro2-06a3aa365bbe001c\\build_script_build-06a3aa365bbe001c.exe" "-Wl,--gc-sections" "-no-pie" "-Wl,--strip-debug" "-nodefaultlibs" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: x86_64-w64-mingw32-gcc: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]␍
          lld: error: unable to find library -lgcc_eh␍
          lld: error: unable to find library -lgcc␍
          x86_64-w64-mingw32-gcc: error: linker command failed with exit code 1 (use -v to see invocation)␍

it seems that having rustup here has no sense...

@ognevny
Copy link
Collaborator

ognevny commented Apr 14, 2025

(I set it to MSYS=winsymlinks:native for my personal builds).

looks like for hard links there is no difference, you don't have to set MSYS=winsymlinks:native

@500-internal-server-error
Copy link
Contributor Author

ahh, fails like before

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\msys64\\tmp\\rustciR9UQD\\symbols.o" "<3 object files omitted>" "-Wl,-Bstatic" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-ldbghelp" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmingwex" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-o" "C:\\msys64\\home\\maksa\\forks\\500ise-MINGW\\mingw-w64-rustup\\src\\rustup-1.28.1\\target\\release\\build\\proc-macro2-06a3aa365bbe001c\\build_script_build-06a3aa365bbe001c.exe" "-Wl,--gc-sections" "-no-pie" "-Wl,--strip-debug" "-nodefaultlibs" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: x86_64-w64-mingw32-gcc: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]␍
          lld: error: unable to find library -lgcc_eh␍
          lld: error: unable to find library -lgcc␍
          x86_64-w64-mingw32-gcc: error: linker command failed with exit code 1 (use -v to see invocation)␍

I can't reproduce this error, seems fine in CI and my local machine, where does it happen?

@ognevny
Copy link
Collaborator

ognevny commented Apr 15, 2025

probably because I added ${MINGW_PFEFIX}/bin to global $PATH. I don't know actually... my config is not clean

edit: I tried to compile rustup itself

@500-internal-server-error
Copy link
Contributor Author

Hmm, CLANGARM64 CI failed instead of skipping. Though, should this package should support it? There seems to be support for arm64 msvc, but not arm64 gnu/gnullvm.

@ognevny
Copy link
Collaborator

ognevny commented Apr 15, 2025

Hmm, CLANGARM64 CI failed instead of skipping. Though, should this package should support it? There seems to be support for arm64 msvc, but not arm64 gnu/gnullvm.

for MSVC target it's better to use official rustup distribution IMO

@500-internal-server-error
Copy link
Contributor Author

Hmm, there a random CLANG32 CI job that still runs which causes the overall job status to fail...

@ognevny
Copy link
Collaborator

ognevny commented Apr 15, 2025

Hmm, there a random CLANG32 CI job that still runs which causes the overall job status to fail...

lol. are you sure you've rebased your branch on master?

@500-internal-server-error
Copy link
Contributor Author

A bit scared since last time I did a rebase it closed my PR... but I did commit to master instead of a branch so maybe that was why.

@mati865
Copy link
Collaborator

mati865 commented Apr 15, 2025

That happens when you make a mistake when rebasing and remove all the new commits. When GitHub sees a PR that brings no changes, it'll close the PR.

@500-internal-server-error
Copy link
Contributor Author

Is there anything else required for this to be merged?

@ognevny
Copy link
Collaborator

ognevny commented Apr 16, 2025

so, let it be an another option to use Rust here. but of course it would be better to use common Rust package instead

@ognevny ognevny merged commit cf3e0ca into msys2:master Apr 16, 2025
5 checks passed
@500-internal-server-error 500-internal-server-error mentioned this pull request Apr 16, 2025
6 tasks
@500-internal-server-error 500-internal-server-error deleted the add-rustup branch April 16, 2025 05:56
@go2null
Copy link

go2null commented Apr 16, 2025

🙏
Thank you everyone!!
Any idea when this will be released?

@ognevny
Copy link
Collaborator

ognevny commented Apr 16, 2025

🙏
Thank you everyone!!
Any idea when this will be released?

it's already in the repo: https://packages.msys2.org/base/mingw-w64-rustup

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.

7 participants