Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/macos-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ jobs:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: install dependencies
run: brew install --verbose nikitabobko/tap/brew-install-path
Comment on lines +22 to +23
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Pin the tap commit to avoid supply-chain drift.

Installing the external brew command from a moving tap HEAD can break CI unexpectedly. Pin the tap to a known commit, then install the formula.

-    - name: install dependencies
-      run: brew install --verbose nikitabobko/tap/brew-install-path
+    - name: install brew-install-path (pinned)
+      run: |
+        brew tap nikitabobko/tap https://github.com/nikitabobko/homebrew-tap
+        git -C "$(brew --repo nikitabobko/tap)" checkout <commit-sha>
+        brew install --verbose nikitabobko/tap/brew-install-path
+      shell: bash

Replace with the tested revision.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: install dependencies
run: brew install --verbose nikitabobko/tap/brew-install-path
- name: install brew-install-path (pinned)
run: |
brew tap nikitabobko/tap https://github.com/nikitabobko/homebrew-tap
git -C "$(brew --repo nikitabobko/tap)" checkout <commit-sha>
brew install --verbose nikitabobko/tap/brew-install-path
shell: bash
🤖 Prompt for AI Agents
.github/workflows/macos-toolchain.yml lines 22-23: currently installing an
external brew formula directly from the tap HEAD—pin the tap to a specific
commit to avoid supply-chain drift by (1) tapping the nikitabobko/tap repo, (2)
fetching and checking out the tested <commit-sha> in the tap repository, and
then (3) running the brew install of nikitabobko/tap/brew-install-path; replace
<commit-sha> with the known-good revision and ensure these steps are executed in
the workflow before the installation step.

- name: build mips binutils
run: brew install ./tools/macos-mips/mipsel-none-elf-binutils.rb --debug
run: brew install-path --verbose ./tools/macos-mips/mipsel-none-elf-binutils.rb
- name: build mips gcc
run: brew install ./tools/macos-mips/mipsel-none-elf-gcc.rb --debug
run: brew install-path --verbose ./tools/macos-mips/mipsel-none-elf-gcc.rb
- name: build openbios
run: make -C ./src/mips/openbios
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ You need MacOS Catalina or later with the latest XCode to build, as well as a fe

Compiling OpenBIOS will require a mips compiler, that you can generate using the following commands:
```bash
brew install ./tools/macos-mips/mipsel-none-elf-binutils.rb
brew install ./tools/macos-mips/mipsel-none-elf-gcc.rb
brew install nikitabobko/tap/brew-install-path
brew install-path ./tools/macos-mips/mipsel-none-elf-binutils.rb
brew install-path ./tools/macos-mips/mipsel-none-elf-gcc.rb
```

Then, you can compile OpenBIOS using `make -C ./src/mips/openbios`.
Expand Down
5 changes: 3 additions & 2 deletions src/mips/psyqo/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ trizen -S cross-mipsel-linux-gnu-binutils cross-mipsel-linux-gnu-gcc
Using [Homebrew](https://brew.sh/), you can install the mips toolchain after downloading [these two scripts](https://github.com/grumpycoders/pcsx-redux/tree/main/tools/macos-mips) (or cloning the whole PCSX-Redux repository).

```bash
brew install ./tools/macos-mips/mipsel-none-elf-binutils.rb
brew install ./tools/macos-mips/mipsel-none-elf-gcc.rb
brew install nikitabobko/tap/brew-install-path
brew install-path ./tools/macos-mips/mipsel-none-elf-binutils.rb
brew install-path ./tools/macos-mips/mipsel-none-elf-gcc.rb
```

## Windows
Expand Down
12 changes: 6 additions & 6 deletions tools/linux-mips/spawn-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ set -ex

PREFIX=${PREFIX:-"/usr/local"}

for url in https://ftpmirror.gnu.org/gnu/binutils/binutils-2.43.tar.gz https://mirrors.kernel.org/gnu/binutils/binutils-2.43.tar.gz ; do
for url in https://ftpmirror.gnu.org/gnu/binutils/binutils-2.45.tar.gz https://mirrors.kernel.org/gnu/binutils/binutils-2.45.tar.gz ; do
wget --max-redirect=2 --timeout=60 --continue --trust-server-names $url && break
done
tar xvfz binutils-2.43.tar.gz
cd binutils-2.43
tar xvfz binutils-2.45.tar.gz
cd binutils-2.45
./configure --target=mipsel-none-elf --disable-multilib --disable-nls --disable-werror --prefix=$PREFIX
make
make install-strip
cd ..

for url in https://ftpmirror.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.gz https://mirrors.kernel.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.gz ; do
for url in https://ftpmirror.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.gz https://mirrors.kernel.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.gz ; do
wget --max-redirect=2 --timeout=60 --continue --trust-server-names $url && break
done
tar xvfz gcc-14.2.0.tar.gz
cd gcc-14.2.0
tar xvfz gcc-15.2.0.tar.gz
cd gcc-15.2.0
./contrib/download_prerequisites
mkdir build
cd build
Expand Down
52 changes: 49 additions & 3 deletions tools/macos-mips/mipsel-none-elf-binutils.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
class MipselNoneElfBinutils < Formula
desc "FSF Binutils for mipsel cross development"
homepage "https://www.gnu.org/software/binutils/"
url "https://ftpmirror.gnu.org/gnu/binutils/binutils-2.43.tar.gz"
mirror "https://mirrors.kernel.org/gnu/binutils/binutils-2.43.tar.gz"
sha256 "025c436d15049076ebe511d29651cc4785ee502965a8839936a65518582bdd64"
url "https://ftpmirror.gnu.org/gnu/binutils/binutils-2.45.tar.gz"
mirror "https://mirrors.kernel.org/gnu/binutils/binutils-2.45.tar.gz"
sha256 "8a3eb4b10e7053312790f21ee1a38f7e2bbd6f4096abb590d3429e5119592d96"

depends_on "texinfo" => :build

patch :DATA

def install
system "./configure", "--target=mipsel-none-elf",
"--disable-multilib",
Expand All @@ -20,3 +22,47 @@ def install
assert_match "f()", shell_output("#{bin}/mipsel-none-elf-c++filt _Z1fv")
end
end

__END__
diff --git a/zlib/zutil.h b/zlib/zutil.h
index 0bd2dbcba..bb513cb4b 100644
--- a/zlib/zutil.h
+++ b/zlib/zutil.h
@@ -137,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif

-#if defined(MACOS) || defined(TARGET_OS_MAC)
+#if defined(MACOS)
# define OS_CODE 7
-# ifndef Z_SOLO
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-# endif
#endif

#ifdef __acorn
@@ -170,18 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define OS_CODE 19
#endif

-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
#if defined(__BORLANDC__) && !defined(MSDOS)
#pragma warn -8004
#pragma warn -8008
6 changes: 3 additions & 3 deletions tools/macos-mips/mipsel-none-elf-gcc.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class MipselNoneElfGcc < Formula
desc "The GNU compiler collection for mipsel"
homepage "https://gcc.gnu.org"
url "https://ftpmirror.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
sha256 "a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9"
url "https://ftpmirror.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz"
sha256 "438fd996826b0c82485a29da03a72d71d6e3541a83ec702df4271f6fe025d24e"

depends_on "gmp"
depends_on "mipsel-none-elf-binutils"
Expand Down
6 changes: 3 additions & 3 deletions tools/macos-mips/mipsel-none-elf-gdb.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class MipselNoneElfGdb < Formula
desc "GDB: The GNU Project Debugger compiled for Mips"
homepage "https://sourceware.org/gdb/"
url "https://ftpmirror.gnu.org/gnu/gdb/gdb-15.1.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gdb/gdb-15.1.tar.xz"
sha256 "38254eacd4572134bca9c5a5aa4d4ca564cbbd30c369d881f733fb6b903354f2"
url "https://ftpmirror.gnu.org/gnu/gdb/gdb-16.3.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gdb/gdb-16.3.tar.xz"
sha256 "bcfcd095528a987917acf9fff3f1672181694926cc18d609c99d0042c00224c5"

# inspired by https://github.com/orgs/Homebrew/discussions/1114#discussioncomment-8863715

Expand Down
52 changes: 52 additions & 0 deletions tools/macos-mips/zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
From 4bd9a71f3539b5ce47f0c67ab5e01f3196dc8ef9 Mon Sep 17 00:00:00 2001
From: Mark Adler <[email protected]>
Date: Tue, 12 Dec 2023 22:19:05 -0600
Subject: [PATCH] Remove fdopen #defines in zutil.h.

fdopen() is not used by zlib anymore. The #defines are vestigial.
---
zutil.h | 23 +----------------------
1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/zutil.h b/zutil.h
index 0bd2dbcba..bb513cb4b 100644
--- a/zutil.h
+++ b/zutil.h
@@ -137,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif

-#if defined(MACOS) || defined(TARGET_OS_MAC)
+#if defined(MACOS)
# define OS_CODE 7
Comment on lines +19 to +21
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Retain TARGET_OS_MAC in the condition.

Same rationale as in the embedded patches: avoid changing OS_CODE semantics on Apple hosts.

-#if defined(MACOS)
+#if defined(MACOS) || defined(TARGET_OS_MAC)
🤖 Prompt for AI Agents
In tools/macos-mips/zlib.patch around lines 19 to 21, the preprocessor condition
was changed to drop TARGET_OS_MAC; restore the original combined condition so
Apple-host detection still triggers. Replace the line with a condition that
checks both defined(MACOS) || defined(TARGET_OS_MAC) (i.e., revert to the
original compound #if) so OS_CODE remains unchanged on Apple hosts.

-# ifndef Z_SOLO
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-# endif
#endif

#ifdef __acorn
@@ -170,18 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define OS_CODE 19
#endif

-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
#if defined(__BORLANDC__) && !defined(MSDOS)
#pragma warn -8004
#pragma warn -8008
52 changes: 49 additions & 3 deletions tools/vscode-extension/scripts/mipsel-none-elf-binutils.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
class MipselNoneElfBinutils < Formula
desc "FSF Binutils for mipsel cross development"
homepage "https://www.gnu.org/software/binutils/"
url "https://ftpmirror.gnu.org/gnu/binutils/binutils-2.43.tar.gz"
mirror "https://mirrors.kernel.org/gnu/binutils/binutils-2.43.tar.gz"
sha256 "025c436d15049076ebe511d29651cc4785ee502965a8839936a65518582bdd64"
url "https://ftpmirror.gnu.org/gnu/binutils/binutils-2.45.tar.gz"
mirror "https://mirrors.kernel.org/gnu/binutils/binutils-2.45.tar.gz"
sha256 "8a3eb4b10e7053312790f21ee1a38f7e2bbd6f4096abb590d3429e5119592d96"

depends_on "texinfo" => :build

patch :DATA

def install
system "./configure", "--target=mipsel-none-elf",
"--disable-multilib",
Expand All @@ -20,3 +22,47 @@ def install
assert_match "f()", shell_output("#{bin}/mipsel-none-elf-c++filt _Z1fv")
end
end

__END__
diff --git a/zlib/zutil.h b/zlib/zutil.h
index 0bd2dbcba..bb513cb4b 100644
--- a/zlib/zutil.h
+++ b/zlib/zutil.h
@@ -137,17 +137,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif

-#if defined(MACOS) || defined(TARGET_OS_MAC)
+#if defined(MACOS)
# define OS_CODE 7
-# ifndef Z_SOLO
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-# endif
#endif

#ifdef __acorn
@@ -170,18 +161,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define OS_CODE 19
#endif

-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
#if defined(__BORLANDC__) && !defined(MSDOS)
#pragma warn -8004
#pragma warn -8008
6 changes: 3 additions & 3 deletions tools/vscode-extension/scripts/mipsel-none-elf-gcc.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class MipselNoneElfGcc < Formula
desc "The GNU compiler collection for mipsel"
homepage "https://gcc.gnu.org"
url "https://ftpmirror.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz"
sha256 "a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9"
url "https://ftpmirror.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz"
sha256 "438fd996826b0c82485a29da03a72d71d6e3541a83ec702df4271f6fe025d24e"

depends_on "gmp"
depends_on "mipsel-none-elf-binutils"
Expand Down
6 changes: 3 additions & 3 deletions tools/vscode-extension/scripts/mipsel-none-elf-gdb.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class MipselNoneElfGdb < Formula
desc "GDB: The GNU Project Debugger compiled for Mips"
homepage "https://sourceware.org/gdb/"
url "https://ftpmirror.gnu.org/gnu/gdb/gdb-15.1.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gdb/gdb-15.1.tar.xz"
sha256 "38254eacd4572134bca9c5a5aa4d4ca564cbbd30c369d881f733fb6b903354f2"
url "https://ftpmirror.gnu.org/gnu/gdb/gdb-16.3.tar.xz"
mirror "https://mirrors.kernel.org/gnu/gdb/gdb-16.3.tar.xz"
sha256 "bcfcd095528a987917acf9fff3f1672181694926cc18d609c99d0042c00224c5"

# inspired by https://github.com/orgs/Homebrew/discussions/1114#discussioncomment-8863715

Expand Down
Loading
Loading