Skip to content

Releases: ookiineko-cygport/rust

Test build

05 May 05:34
Compare
Choose a tag to compare

Branch: mingw-host

Supported Targets: x86_64-pc-cygwin (cross), x86_64-pc-windows-gnu (host, only used for building rustc and running build-time build.rs scripts)

It is also possible to make this toolchain link against msys-2.0.dll instead of cygwin1.dll, for how to do this please see this gist

Requires Windows (also support Linux hosts but you need to build from source), MSYS2 and mingw-w64-x86_64-cygwin-gcc package from msys2-cygwin (unofficial)

Host Runtime Dependencies:

Build Dependencies:

NOTE: when using, please add bin/ to PATH

Clone / Configure / Build Commands:

git clone https://github.com/ookiineko-cygport/rust -b mingw-host && cd rust
git submodule update --init --depth=1 --recursive

# IMPORTANT: msys git quirk
export GIT_DIR=/dev/null

MSYS2_ARG_CONV_EXCL="--prefix;--sysconfdir;--localstatedir" \
./configure --prefix=${MINGW_PREFIX}/lib/cygwin-rust \
            --sysconfdir=${MINGW_PREFIX}/lib/cygwin-rust/etc \
            --localstatedir=${MINGW_PREFIX}/lib/cygwin-rust/var/lib \
            --build=x86_64-pc-windows-gnu \
            --host=x86_64-pc-windows-gnu \
            --target="x86_64-pc-cygwin,x86_64-pc-windows-gnu" \
            --release-channel=nightly \
            --enable-ninja --enable-extended --tools="rustfmt,cargo,src" \
            --disable-llvm-static-stdcpp --disable-codegen-tests \
            --disable-docs --disable-compiler-docs \
            --set="llvm.targets=X86" --set="llvm.experimental-targets=" \
            --set="target.x86_64-pc-cygwin.cc=x86_64-pc-cygwin-cc" \
            --set="target.x86_64-pc-cygwin.cxx=x86_64-pc-cygwin-c++" \
            --set="target.x86_64-pc-cygwin.ar=x86_64-pc-cygwin-ar" \
            --set="target.x86_64-pc-cygwin.linker=x86_64-pc-cygwin-cc"

DESTDIR=result python x.py install -i --stage 2

you may want export PKG_CONFIG_x86_64_pc_cygwin=x86_64-pc-cygwin-pkg-config.bat CMAKE_TOOLCHAIN_FILE_x86_64_pc_cygwin=${MINGW_PREFIX}/share/cygwin/toolchain-x86_64-pc-cygwin.cmake to allow rust to pick up cygwin packages provided by msys2-cygwin

make sure to unset certain variables which might break cross-compiling by default: unset PKG_CONFIG_PATH PKG_CONFIG_SYSTEM_INCLUDE_PATH PKG_CONFIG_SYSTEM_LIBRARY_PATH

also put these in your ~/.cargo/config to use some 3rd party crates (required if you want to build Rust STD or the toolchain)

[patch.crates-io]
libc_0_2_135 = { git = 'https://github.com/ookiineko-cygport/libc.git', package = 'libc', branch = '0.2.135' }
libc_0_2_148 = { git = 'https://github.com/ookiineko-cygport/libc.git', package = 'libc', branch = '0.2.148' }
libc_0_2_152 = { git = 'https://github.com/ookiineko-cygport/libc.git', package = 'libc', branch = '0.2.152' }
libc_0_2_153 = { git = 'https://github.com/ookiineko-cygport/libc.git', package = 'libc', branch = '0.2.153' }
cc_1_0_77 = { git = 'https://github.com/ookiineko-cygport/cc-rs.git', package = 'cc', branch = '1.0.77' }
cc_1_0_83 = { git = 'https://github.com/ookiineko-cygport/cc-rs.git', package = 'cc', branch = '1.0.83' }
compiler_builtins = { git = 'https://github.com/ookiineko-cygport/compiler-builtins.git' }
getrandom0_2_0 = { git = 'https://github.com/ookiineko-cygport/getrandom.git', package = 'getrandom', branch = '0.2.0' }
getrandom0_2_10 = { git = 'https://github.com/ookiineko-cygport/getrandom.git', package = 'getrandom', branch = '0.2.10' }
getrandom0_2_12 = { git = 'https://github.com/ookiineko-cygport/getrandom.git', package = 'getrandom', branch = '0.2.12' }
socket2 = { git = 'https://github.com/ookiineko-cygport/socket2.git' }
psm = { git = 'https://github.com/ookiineko-cygport/stacker.git' }
mio = { git = 'https://github.com/ookiineko-cygport/mio.git' }
tokio = { git = 'https://github.com/ookiineko-cygport/tokio.git' }
libloading_0_7_1 = { git = 'https://github.com/ookiineko-cygport/rust_libloading.git', package = 'libloading', branch = '0.7.1' }
libloading_0_7_3 = { git = 'https://github.com/ookiineko-cygport/rust_libloading.git', package = 'libloading', branch = '0.7.3' }
openssl-src = { git = 'https://github.com/ookiineko-cygport/openssl-src-rs.git' }
os_info = { git = 'https://github.com/ookiineko-cygport/os_info.git' }
cmake = { git = 'https://github.com/ookiineko-cygport/cmake-rs.git' }
ctest2 = { git = 'https://github.com/ookiineko-cygport/ctest2.git' }