Msys2 add binutils install instructions (#112)

* Update instructions

* Delete get_bin.sh
This commit is contained in:
MegaMech 2021-12-24 23:43:42 -07:00 committed by GitHub
parent 1b40669f0d
commit 8ca68747db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 94 deletions

View File

@ -1,13 +1,11 @@
### These instructions are a WIP and may be missing steps
## Compiling mk64 Decomp In Windows ## Compiling mk64 Decomp In Windows
The extraneous and convoluted process to building mk64 decomp on Windows begins with disabling your anti-virus program or adding an exception to the mk64 decomp folder and/or the msys2 installation folder. The extraneous and convoluted process to building mk64 decomp on Windows begins with disabling your anti-virus program or adding an exception to the mk64 decomp folder and the msys2 installation folder.
Please note that this action may impact the security of your system. Prior to proceeding, make sure to understand the increased security risks that may result from this step. Nobody except you, is responsible and liable for your system and its security. Please note that this action may impact the security of your system. Prior to proceeding, make sure to understand the increased security risks that may result from this step. Nobody except you, is responsible and liable for your system and its security.
### Preamble ### Preamble
Any misteps may require a complete uninstall of `MSYS2 MinGW x64` and restarting from the very beginning. Any misteps may require a complete uninstall of `MSYS2 MinGW x64` and restarting from the very beginning.
It is unknown if `MSYS MinGW x32` works. It is unknown if `MSYS MinGW x32` is supported (most likely not).
### Step 1: Download MSYS2 MinGW x64 ### Step 1: Download MSYS2 MinGW x64
@ -16,10 +14,11 @@ https://www.msys2.org/
Follow the initial instructions to update the base packages. Ignore installing any extra packages in-case they conflict with the below steps. Follow the initial instructions to update the base packages. Ignore installing any extra packages in-case they conflict with the below steps.
MinGW is a separate program from Msys2. However, it must be wrapped right into msys2. MinGW is a separate program from Msys2. However, it must be wrapped right into msys2.
Compiling recomp requires steps using `MSYS2 MSYS` *and* `MSYS2 MinGW x64`. The instructions will clearly differentiate which program to launch and run in the section titles. Compiling recomp requires steps using<br>`MSYS2 MSYS` *and* `MSYS2 MinGW x64`. The instructions will clearly differentiate which terminal program to launch and run in the section titles.
##### Why flip-flop between both? ##### *Why flip-flop between both?*
Compiling the recomp executable that generates the source files for compiling the compiler requires capstone. A disassembly, analysis, and reverse-engineering framework. Capstone is only available on `MSYS2 MinGW x64`. It is not available on `MSYS2 MSYS`. However, compiling the compiler itself requires `MSYS2 MSYS` because it contains an equivallent dependency for `mman`. A memory mapping library. `MSYS2 MinGW x64` does not contain an equivallent dependancy. Compiling the recomp executable that generates the source files for compiling the compiler requires capstone. A disassembly, analysis, and reverse-engineering framework. Capstone is only available on `MSYS2 MinGW x64`. It is not available on `MSYS2 MSYS`. However, compiling the compiler itself requires
`MSYS2 MSYS` because it contains an equivallent dependency for `mman`. A memory mapping library. `MSYS2 MinGW x64` does not contain an equivallent dependancy.
### Step 2: Install Dependancies in MSYS2 MinGW x64 ### Step 2: Install Dependancies in MSYS2 MinGW x64
@ -32,8 +31,11 @@ pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-capstone pkgconf make python3 gi
pacman -S gcc pacman -S gcc
``` ```
### Step 4: Compile Binutils For mips and Install ### Step 4: Get Binutils
Download and run: [get_bin.sh](get_bin.sh) Download and install the mips64 tool chain:
https://github.com/N64-tools/mips64-gcc-toolchain
Merge the inner folders (bin, share, etc.) with the respective folders in `C:\msys64\mingw64\`
### Step 5: Compiling recomp.exe in `MSYS2 MinGW x64` ### Step 5: Compiling recomp.exe in `MSYS2 MinGW x64`
In `MSYS2 MinGW x64` run in `mk64/tools/ido5.3_recomp/`: In `MSYS2 MinGW x64` run in `mk64/tools/ido5.3_recomp/`:
@ -46,12 +48,11 @@ In `MSYS2 MSYS` run:
``` ```
make -C tools make -C tools
``` ```
If the make file is broken then manually compile each executable. If the make file is broken then manually generate each source file in `mk64/tools/ido5.3_recomp/`:
Generate C file in `mk64/tools/ido5.3_recomp/`:
``` ```
./recomp ~/ido7.1_compiler/usr/lib/as1 > as1_c.c ./recomp ~/ido7.1_compiler/usr/lib/as1 > as1_c.c
``` ```
Compile generated C file: Next, compile the generated C files:
``` ```
gcc libc_impl.c as1_c.c -o as1 -g -fno-strict-aliasing -lm -no-pie -DIDO53 -O2 gcc libc_impl.c as1_c.c -o as1 -g -fno-strict-aliasing -lm -no-pie -DIDO53 -O2
``` ```
@ -63,4 +64,4 @@ In `/mk64/` run:
``` ```
make -j# make -j#
``` ```
Replace # with your number of CPU cores for qucker compilation. Replace # with your number of CPU cores for quicker compilation.

View File

@ -1,81 +0,0 @@
#!/bin/bash
# --- Useful Variables --- #
# This is the specific binutils version that will be downloaded
binutils=binutils-2.36
# Where the built files will end up.
# If this directory doesn't already exist it will be created automatically.
destFolder=./tools/binutils
# The temporary folder name to work from.
tempFolder=build_temp
# The prefix appended to the start of the built files.
prefix=mips64-elf-
# Folder names within the binutils directory.
binFolder=binutils
ldFolder=ld
gasFolder=gas
# How many threads to use with make (All of them)
threadCount=$(nproc --all)
# --- Useful Macros --- #
PRINT_STEP () {
echo "($1) ==== $2 ==== "
}
INSTALL_FILE() {
cp ./$tempFolder/$binutils/$2/$1 $destFolder/$prefix$1
echo "Installed mips64-elf-$1"
}
RENAME_AND_INSTALL_FILE() {
cp ./$tempFolder/$binutils/$2/$1 $destFolder/$prefix$3
echo "Installed mips64-elf-$3"
}
# --- Script --- #
# Make the destintation folder if it already doesn't exist.
mkdir -p $destFolder
# Having a temp folder makes things easy to cleanup
#rm -Rf $tempFolder # This will remove the temp folder if it exists for some reason.
mkdir $tempFolder
cd $tempFolder
PRINT_STEP 1 "DOWNLOADING BINUTILS FROM GNU.ORG"
wget ftp://ftp.gnu.org/gnu/binutils/$binutils.tar.xz
PRINT_STEP 2 "EXTRACTING TAR FILE"
tar -xf $binutils.tar.xz
PRINT_STEP 3 "CONFIGURING THE MAKEFILE"
cd $binutils
# Credit goes to queueRAM for letting me know what the correct arguments are.
./configure --target=mips64-elf --prefix=/usr --with-sysroot=/usr/mips64-elf --with-gnu-as --with-gnu-ld --enable-64-bit-bfd --enable-multilib --enable-plugins --disable-gold --disable-nls --disable-shared --disable-werror
PRINT_STEP 4 "MAKING BINUTILS"
make -j$threadCount
cd ../..
PRINT_STEP 5 "INSTALLING BUILT FILES"
# Add or remove programs here.
INSTALL_FILE ar $binFolder
INSTALL_FILE objcopy $binFolder
INSTALL_FILE objdump $binFolder
RENAME_AND_INSTALL_FILE as-new $gasFolder as
RENAME_AND_INSTALL_FILE ld-new $ldFolder ld
PRINT_STEP 6 "CLEANING UP"
#rm -Rf $tempFolder
PRINT_STEP - "DONE!"