Skip to content

Commit

Permalink
Fix INCLUDE_IMG and INCLUDE_PAL on modern GCC (#1143)
Browse files Browse the repository at this point in the history
* fix INCLUDE_IMG and INCLUDE_PAL on modern GCC

* use .pushsection/.popsection

* use pushsection/popsection on modern compiler only

* add gcc-mips-linux-gnu to debian deps

* remove rogue )

* move -DMODERN_COMPILER to cflags_modern
  • Loading branch information
bates64 authored Jan 9, 2024
1 parent 070a548 commit 029de58
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions include/include_asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
#define ASTRINGIFY_(x) #x
#define ASTRINGIFY(x) ASTRINGIFY_(x)

#ifdef MODERN_COMPILER
# define PUSHSECTION(SECTION) ".pushsection " SECTION "\n"
# define POPSECTION ".popsection\n"
#else
# define PUSHSECTION(SECTION) SECTION "\n"
# define POPSECTION
#endif

#define _INCLUDE_IMG(FILENAME, SYMBOLNAME) \
extern unsigned char SYMBOLNAME[]; \
__asm__( \
".globl " #SYMBOLNAME"\n" \
".data\n" \
PUSHSECTION(".data") \
".align 2\n" \
".type " #SYMBOLNAME", @object\n" \
#SYMBOLNAME":\n" \
".incbin \"ver/"ASTRINGIFY(VERSION)"/build/" FILENAME ".bin\"\n" \
POPSECTION \
)

// two macros are needed for N() usage
Expand All @@ -22,11 +31,12 @@
extern unsigned short SYMBOLNAME[]; \
__asm__( \
".globl " #SYMBOLNAME"\n" \
".data\n" \
PUSHSECTION(".data") \
".align 2\n" \
".type " #SYMBOLNAME", @object\n" \
#SYMBOLNAME":\n" \
".incbin \"ver/"ASTRINGIFY(VERSION)"/build/" FILENAME ".bin\"\n" \
POPSECTION \
)

#endif // _H_INCLUDE_ASSET
2 changes: 1 addition & 1 deletion install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if cat /etc/os-release | grep -E 'ID=debian|ID_LIKE=(.*)debian' &> /dev/null; th

echo "Installing packages for Debian or derivative (apt)"

${SUDO} apt install -y curl git python3 python3-pip python3-setuptools build-essential binutils-mips-linux-gnu zlib1g-dev libyaml-dev ninja-build cpp-mips-linux-gnu || exit 1
${SUDO} apt install -y curl git python3 python3-pip python3-setuptools build-essential binutils-mips-linux-gnu zlib1g-dev libyaml-dev ninja-build cpp-mips-linux-gnu gcc-mips-linux-gnu || exit 1
python3 -m pip install -U -r requirements.txt
cp tools/precommit_check_no_assets.sh "$(git rev-parse --git-path hooks)/pre-commit" || exit 1

Expand Down
2 changes: 1 addition & 1 deletion tools/build/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def write_ninja_rules(

cflags = f"-c -G0 -O2 -gdwarf-2 -x c -B {BUILD_TOOLS}/cc/gcc/ {extra_cflags}"

cflags_modern = f"-c -G0 -O2 -gdwarf-2 -fdiagnostics-color=always -fno-builtin-bcopy -fno-tree-loop-distribute-patterns -funsigned-char -mgp32 -mfp32 -mabi=32 -mfix4300 -march=vr4300 -mno-gpopt -fno-toplevel-reorder -mno-abicalls -fno-pic -fno-exceptions -fno-stack-protector -fno-zero-initialized-in-bss -Wno-builtin-declaration-mismatch -x c {extra_cflags}"
cflags_modern = f"-c -G0 -O2 -gdwarf-2 -fdiagnostics-color=always -fno-builtin-bcopy -fno-tree-loop-distribute-patterns -funsigned-char -mgp32 -mfp32 -mabi=32 -mfix4300 -march=vr4300 -mno-gpopt -fno-toplevel-reorder -mno-abicalls -fno-pic -fno-exceptions -fno-stack-protector -fno-zero-initialized-in-bss -Wno-builtin-declaration-mismatch -DMODERN_COMPILER -x c {extra_cflags}"

cflags_272 = f"-c -G0 -mgp32 -mfp32 -mips3 {extra_cflags}"
cflags_272 = cflags_272.replace("-ggdb3", "-g1")
Expand Down

0 comments on commit 029de58

Please sign in to comment.