Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions .github/filter-mips/filter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ cd $CWD

# Need to delete submodules actively.
# Done in two passes for speed.
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/psxlua -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -delete || true' --tag-name-filter cat --prune-empty
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/psxlua -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -exec git rm -f {} \; || true' --tag-name-filter cat --prune-empty
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/psxlua -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -and -not -path third_party/xmake-psx -delete || true' --tag-name-filter cat --prune-empty
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/psxlua -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -and -not -path third_party/xmake-psx -exec git rm -f {} \; || true' --tag-name-filter cat --prune-empty
Comment on lines +13 to +14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win

Preserve complete whitelisted subtrees.

Because find runs with -depth, the current predicates preserve only the directory entries for uC-sdk, psxlua, and xmake-psx; their descendants still match and are deleted. The second pass repeats the same faulty filters, so the exported history can lose required dependency sources.

Add /* exclusions for each preserved subtree in both commands, matching the existing EABase/EASTL patterns.

Proposed predicate fix
-find third_party -depth -not -name uC-sdk -and -not -path third_party/psxlua -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -and -not -path third_party/xmake-psx ...
+find third_party -depth -not -name uC-sdk -and -not -path third_party/uC-sdk/\* -and -not -path third_party/psxlua -and -not -path third_party/psxlua/\* -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -and -not -path third_party/xmake-psx -and -not -path third_party/xmake-psx/\* ...
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/filter-mips/filter.sh around lines 13 - 14, Update both git
filter-branch find predicates to exclude descendants of every preserved subtree:
uC-sdk, psxlua, and xmake-psx, matching the existing wildcard exclusions used
for EABase and EASTL. Keep the directory exclusions unchanged and apply the same
complete whitelist to both the -delete and git rm passes.


# Shuffle files around.
git filter-branch -f --tree-filter 'mkdir -p src/mips ; git mv third_party src/mips ; mv .gitmodules src/mips ; mv docker* src/mips || true' --tag-name-filter cat --prune-empty
Expand All @@ -38,6 +38,9 @@ git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\
git filter-branch -f --tree-filter "find . -name Makefile -exec sed 's|\.\./\.\./\.\./third_party/psxlua/|../third_party/psxlua/|' -i {} \;" --tag-name-filter cat --prune-empty
git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\.\./third_party/psxlua/|../third_party/psxlua/|' -i {} \;" --tag-name-filter cat --prune-empty

# Adjust paths for xmake
git filter-branch -f --tree-filter "find . -name xmake.lua -exec sed 's|local root = path.join(os.scriptdir(), \"\.\.\", \"\.\.\"|local root = path.join(os.scriptdir()|' -i {} \;" --tag-name-filter cat --prune-empty

# Delete unwanted files
git filter-branch -f --tree-filter 'find . -name compile_flags.txt -delete || true' --tag-name-filter cat --prune-empty
git filter-branch -f --tree-filter 'find . -name Doxyfile -delete || true' --tag-name-filter cat --prune-empty
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,9 @@ luacov.stats.out
/appimage-build
/AppDir
/*.AppImage
/*.AppImage.zsync
/*.AppImage.zsync

# xmake
.xmake/
build/

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@
[submodule "third_party/psxlua"]
path = third_party/psxlua
url = https://github.com/grumpycoders/psxlua.git
[submodule "third_party/xmake-psx"]
path = third_party/xmake-psx
url = https://codeberg.org/malucart/xmake-psx.git
1 change: 1 addition & 0 deletions src/mips/common/crt0/cxxglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ __attribute__((section(".preinit_array"))) static fptr pi_heap[] = {

// we're not going to care about exit cleanup
__attribute__((weak)) void __cxa_atexit(void (*func)(void*), void* arg, void* dso_handle) {}
__attribute__((weak)) void atexit(void (*func)(void)) {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Mismatch in atexit signature.

The standard C library signature for atexit returns an int (typically returning 0 on success), not void. Declaring it as void can lead to prototype mismatches if <stdlib.h> is included elsewhere, or undefined behavior if a caller attempts to evaluate the return value.

🐛 Proposed fix
-__attribute__((weak)) void atexit(void (*func)(void)) {}
+__attribute__((weak)) int atexit(void (*func)(void)) { return 0; }
📝 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
__attribute__((weak)) void atexit(void (*func)(void)) {}
__attribute__((weak)) int atexit(void (*func)(void)) { return 0; }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/mips/common/crt0/cxxglue.c` at line 164, Update the weak atexit
definition to match the standard int-returning signature, preserving its
existing callback parameter and returning 0 from the stub.


// no, we're not going to have shared libraries
__attribute__((weak)) void* __dso_handle = NULL;
Expand Down
23 changes: 23 additions & 0 deletions src/mips/helloworld/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local root = path.join(os.scriptdir(), "..", "..", "..")
local mips = path.join(os.scriptdir(), "..")

set_allowedmodes("debug", "dev", "release")
includes(path.join(root, "tools", "exe2iso"))
includes(path.join(root, "tools", "ps1-packer"))
includes(mips)

target("helloworld", function()
set_kind("binary")
add_rules("nugget")
add_files("main/**.c")
end)

target("helloworld.ps-exe", function()
add_deps("helloworld")
add_rules("pcsx.ps1-packer.psexe")
end)

target("helloworld.iso", function()
add_deps("helloworld.ps-exe")
add_rules("pcsx.exe2iso.iso")
end)
8 changes: 8 additions & 0 deletions src/mips/psyqo/examples/hello/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local psyqo = path.join(os.scriptdir(), "..", "..")

includes(psyqo)

target("hello", function()
add_rules("psyqo.app")
add_files("*.cpp")
end)
25 changes: 25 additions & 0 deletions src/mips/psyqo/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local root = path.join(os.scriptdir(), "..", "..", "..")
local mips = path.join(os.scriptdir(), "..")
local psyqo = path.join(os.scriptdir())

set_allowedmodes("debug", "dev", "release")
includes(mips)

set_languages("c11", "c++26")

rule("psyqo.app", function ()
add_deps("nugget")
on_load(function(target)
target:add("values", "c++", true)
target:set("kind", "binary")
target:add("files", path.join(psyqo, "src", "*.c"))
target:add("files", path.join(psyqo, "src", "*.cpp"))
target:add("files", path.join(psyqo, "src", "**/*.cpp"))
target:add("files", path.join(mips, "common", "hardware", "flushcache.s"))
target:add("files", path.join(mips, "common", "psxlibc", "ucontext.s"))
target:add("files", path.join(mips, "common", "util", "*.cc"))
target:add("files", path.join(root, "third_party", "EASTL", "source", "*.cpp"))
target:add("includedirs", path.join(root, "third_party", "EASTL", "include"))
target:add("includedirs", path.join(root, "third_party", "EABase", "include", "Common"))
end)
end)
153 changes: 153 additions & 0 deletions src/mips/xmake.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*

MIT License

Copyright (c) 2026 PCSX-Redux authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/

EXTERN(_start)
ENTRY(_start)

RAM_SIZE = DEFINED(RAM_SIZE) ? RAM_SIZE : 2M;
TLOAD_ADDR = DEFINED(TLOAD_ADDR) ? TLOAD_ADDR : 0x80010000;

MEMORY {
ram (rwx) : ORIGIN = TLOAD_ADDR, LENGTH = RAM_SIZE - (TLOAD_ADDR - 0x80000000)
dcache : ORIGIN = 0x1f800000, LENGTH = 0x400
}

__ram_top = ORIGIN(ram) + LENGTH(ram);
__sp = __ram_top - 0x100;

__dcache = ORIGIN(dcache);
__dcache_top = ORIGIN(dcache) + LENGTH(dcache);

__bss_len = (__bss_end - __bss_start);
__ftext_len = (__ftext_end - __ftext_start);
__fdata_len = (__fdata_end - __fdata_start);

__stack_start = ORIGIN(ram) + LENGTH(ram);

SECTIONS {
__ftext_start = ABSOLUTE(.);
.text TLOAD_ADDR : {
*(.start)
*(.init)
KEEP (*(SORT_NONE(.fini)))
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)

. = ALIGN(16);
KEEP(*(.init))
. = ALIGN(16);
KEEP(*(.fini))
} > ram

. = ALIGN(16);
__text_end = .;
__ftext_end = ABSOLUTE(.);

__fdata_start = ABSOLUTE(.);

.rodata : {
*(.rodata .rodata.* .rdata .rdata.* .gnu.linkonce.r.*)
. = ALIGN(16);
__preinit_array_start = .;
KEEP (*(.preinit_array))
__preinit_array_end = .;

. = ALIGN(16);
__init_array_start = .;
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))

. = ALIGN(16);
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*crtend.o(.ctors))
__init_array_end = .;

. = ALIGN(16);
__fini_array_start = .;
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))

KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*crtend.o(.dtors))
__fini_array_end = .;
__build_id = .;
*(.note.gnu.build-id)
__build_id_end = .;
} > ram

.rodata1 : {
*(.rodata1)
} > ram

__data_start = .;
.data : {
KEEP (*(.data .data.* .gnu.linkonce.d.*))
KEEP (*(.data1))
KEEP (*(.sdata .sdata.* .gnu.linkonce.s.*))
KEEP (*(.sdata2 .sdata2.* .gnu.linkonce.s2.*))
KEEP (*(.got.plt))
KEEP (*(.got))
} > ram

__data_end = .;
__fdata_end = .;
__bss_start = .;
.sbss (NOLOAD) : {
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
} > ram

. = ALIGN(4);
__bss_end = .;

__heap_start = __heap_base;

. = ADDR(.text) - 0x800;
__end = .;

/DISCARD/ : { *(.MIPS.abiflags) }

/* Everything is statically linked, so discard PLTs. */
/DISCARD/ : { *(.rel.iplt) *(.rela.iplt) *(.rel.plt) *(.rela.plt) *(.plt) *(.iplt) }

/* Discard things that the standard link script drops, too. */
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }

.scratchpad (NOLOAD) : {
*(.scratchpad)
} > dcache
}
29 changes: 29 additions & 0 deletions src/mips/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local root = path.join(os.scriptdir(), "..", "..")
local mips = path.join(os.scriptdir())

includes(path.join(root, "third_party", "xmake-psx"))

rule("nugget", function()
add_deps("psx")
on_load(function(target)
target:add("includedirs", mips)
target:add("values", "psx.no_crt", true)
target:add("values", "psx.no_ldscript", true)
target:add("values", "psx.nogp", true)
end)
before_config(function (target)
if target:get("kind") == "binary" then
if target:values("c++") then
target:add("files", path.join(mips, "common", "crt0", "crt0cxx.s"))
target:add("files", path.join(mips, "common", "crt0", "cxxglue.c"))
else
target:add("files", path.join(mips, "common", "crt0", "crt0.s"))
end
target:add("files", path.join(mips, "common", "crt0", "memory-c.c"))
target:add("files", path.join(mips, "common", "crt0", "memory-s.s"))
target:add("files", path.join(mips, "common", "syscalls", "printf.s"))
target:add("files", path.join(mips, "xmake.ld"))
target:add("files", path.join(mips, "nooverlay.ld"))
end
end)
end)
4 changes: 3 additions & 1 deletion src/support/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_rules("mode.debug", "mode.release")
add_requires("fmt", "zlib")
set_languages("c++26")

target("pcsx.support")
target("pcsx.support", function()
set_kind("static")

if is_plat("windows") then
Expand All @@ -20,3 +20,5 @@ target("pcsx.support")
)

add_files("*.cc")
remove_files("ffmpeg-audio-file.cc", "uvfile.cc", "version*.cc")
end)
2 changes: 1 addition & 1 deletion src/supportpsx/binloader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool loadELF(IO<File> file, IO<File> dest, BinaryLoader::Info& info, std::map<ui
if (!reader.load(stream)) return false;
if (reader.get_class() != ELFCLASS32) return false;

info.pc = reader.get_entry();
info.pc = static_cast<uint32_t>(reader.get_entry());

Elf_Half sec_num = reader.sections.size();
for (unsigned i = 0; i < sec_num; i++) {
Expand Down
8 changes: 6 additions & 2 deletions src/supportpsx/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ add_requires("fmt", "zlib")
set_languages("c11", "c++26")
includes(path.join(support_root, "src", "support"))

target("pcsx.supportpsx")
target("pcsx.supportpsx", function()
set_kind("static")

add_packages("fmt", "zlib")
Expand All @@ -26,5 +26,9 @@ target("pcsx.supportpsx")

add_files(
path.join(support_root, "third_party", "ucl", "src", "alloc.c"),
path.join(support_root, "third_party", "ucl", "src", "n2e_99.c")
path.join(support_root, "third_party", "ucl", "src", "n2e_99.c"),
path.join(support_root, "third_party", "iec-60908b", "*.c")
)

remove_files("assembler.cc", "*lua.cc")
end)
1 change: 1 addition & 0 deletions third_party/xmake-psx
Submodule xmake-psx added at e68416
14 changes: 14 additions & 0 deletions tools/authoring/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local support_root = path.join(os.scriptdir(), "..", "..")

includes(path.join(support_root, "tools", "xmake"))

common_rules()

target("pcsx.authoring", function ()
common_tool()
add_includedirs(path.join(support_root, "third_party", "ucl", "include"))
end)

rule("pcsx.authoring.iso", function()
generic_conversion("pcsx.authoring", ".iso", "authoring")
end)
11 changes: 11 additions & 0 deletions tools/exe2iso/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
local support_root = path.join(os.scriptdir(), "..", "..")

includes(path.join(support_root, "tools", "xmake"))

common_rules()

target("pcsx.exe2iso", common_tool)

rule("pcsx.exe2iso.iso", function()
generic_conversion("pcsx.exe2iso", ".iso", "iso conversion")
end)
Loading
Loading