Skip to content

Instantly share code, notes, and snippets.

@loopj
Last active October 12, 2021 20:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loopj/3334caf4bd94d5e15a2950e79041ab52 to your computer and use it in GitHub Desktop.
Save loopj/3334caf4bd94d5e15a2950e79041ab52 to your computer and use it in GitHub Desktop.
devkitPPC rules for building apps with Clang
#---------------------------------------------------------------------------------
# devkitPPC rules for building with Clang
#
# How to use:
# - Copy this file into your DEVKITPPC path:
# cp wii_clang_rules $DEVKITPPC
#
# - Link Clang into your DEVKITPPC path:
# ln -s `which clang` $DEVKITPPC/bin/powerpc-eabi-clang
#
# - Include this file in your Makefile, as the last line
# include $(DEVKITPPC)/wii_clang_rules
#
# Note:
# - If you are using macOS you'll need to install llvm from homebrew, since
# Apple's version doesn't support cross-compiling to the ppc32 target
#---------------------------------------------------------------------------------
# Use Clang instead of GCC (we'll still use GCC/LD to link)
CC := powerpc-eabi-clang --target=ppc32-none-eabi
# Pass compiler flags typically passed by using -mrvl
MACHDEP = -DGEKKO -mcpu=750 \
-D__gamecube__ -DHW_DOL -ffunction-sections -fdata-sections
# Use custom startfile/endfiles
LDFLAGS += -Wl,--gc-sections -nostartfiles\
$(DEVKITPPC)/lib/gcc/powerpc-eabi/*/crtend.o \
$(DEVKITPPC)/lib/gcc/powerpc-eabi/*/ecrtn.o \
$(DEVKITPPC)/lib/gcc/powerpc-eabi/*/ecrti.o \
$(DEVKITPPC)/lib/gcc/powerpc-eabi/*/crtbegin.o \
$(DEVKITPPC)/powerpc-eabi/lib/crtmain.o
# Link with libsysbase.a and libc.a
LDFLAGS += -L$(DEVKITPPC)/powerpc-eabi/lib
LDFLAGS += -Wl,--start-group -lsysbase -lc -Wl,--end-group
# Use the Wii linkscript
LDFLAGS += -Trvl.ld
# Point Clang to the powerpc-eabi stdlibs
CFLAGS += -nostdlibinc -isystem $(DEVKITPPC)/powerpc-eabi/include
@carstene1ns
Copy link

You need to replace -D__gamecube__ -DHW_DOL with -D__wii__ -DHW_RVL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment