diff --git a/crt/Makefile b/crt/Makefile index edcaa8e..c8c6ad5 100644 --- a/crt/Makefile +++ b/crt/Makefile @@ -16,20 +16,27 @@ DESTDIR ?= /opt/ps5-payload-sdk -CCS := clang-19 clang-18 clang-17 clang-16 clang-15 clang +CCS := clang-20 clang-19 clang-18 clang-17 clang-16 clang-15 clang CCS := $(foreach CC,$(CCS),$(if $(shell command -v $(CC) 2> /dev/null),$(CC))) CC := $(firstword $(CCS)) ifndef CC $(error No suitable compiler found) endif -LDS := ld.lld-19 ld.lld-18 ld.lld-17 ld.lld-16 ld.lld-15 ld.lld ld +LDS := ld.lld-20 ld.lld-19 ld.lld-18 ld.lld-17 ld.lld-16 ld.lld-15 ld.lld ld LDS := $(foreach LD,$(LDS),$(if $(shell command -v $(LD) 2> /dev/null),$(LD))) LD := $(firstword $(LDS)) ifndef LD $(error No suitable linker found) endif +ARS := llvm-ar-20 llvm-ar-19 llvm-ar-18 llvm-ar-17 llvm-ar-16 llvm-ar-15 llvm-ar ar +ARS := $(foreach AR,$(ARS),$(if $(shell command -v $(AR) 2> /dev/null),$(AR))) +AR := $(firstword $(ARS)) +ifndef AR + $(error No suitable archiver found) +endif + CFLAGS += -ffreestanding -fno-builtin -nostdlib -fPIC CFLAGS += -target x86_64-sie-ps5 -fno-plt -fno-stack-protector CFLAGS += -fvisibility-nodllstorageclass=default -Wall -Werror @@ -41,7 +48,25 @@ OBJ := crt.o syscall.o klog.o nid.o kernel.o rtld.o rtld_so.o rtld_sprx.o \ .PHONY: all clean install -all: crt1.o +all: crt1.o crti.o crtn.o crtbegin.o crtend.o crtbeginS.o crtendS.o + +crtbeginS.o: + $(AR) -rsc $@ + +crtendS.o: + $(AR) -rsc $@ + +crtbegin.o: + $(AR) -rsc $@ + +crtend.o: + $(AR) -rsc $@ + +crti.o: + $(AR) -rsc $@ + +crtn.o: + $(AR) -rsc $@ crt1.o: $(OBJ) $(LD) -m elf_x86_64 -r -o $@ $^ @@ -52,6 +77,6 @@ crt1.o: $(OBJ) clean: rm -f *.o *.a -install: crt1.o +install: crt1.o crti.o crtn.o crtbegin.o crtend.o crtbeginS.o crtendS.o install -d $(DESTDIR)/target/lib install $^ $(DESTDIR)/target/lib diff --git a/host/Makefile b/host/Makefile index ce1c14f..3cc6149 100644 --- a/host/Makefile +++ b/host/Makefile @@ -51,6 +51,9 @@ install: install-tools install-symlinks install-ldscripts install-toolchains install-ldscripts: $(LDSCRIPTS) install -d $(DESTDIR)/ldscripts install $^ $(DESTDIR)/ldscripts + install -d $(DESTDIR)/target/lib + ln -sf ../../ldscripts/elf_x86_64.x $(DESTDIR)/target/lib/main.script + ln -sf ../../ldscripts/elf_x86_64.x $(DESTDIR)/target/lib/prx.script install-toolchains: $(TOOLCHAINS) install -d $(DESTDIR)/toolchain diff --git a/host/bin/llvm-config b/host/bin/llvm-config index 0b00245..0783284 100755 --- a/host/bin/llvm-config +++ b/host/bin/llvm-config @@ -19,7 +19,8 @@ if [ -x "$(command -v "${LLVM_CONFIG}")" ]; then exec "${LLVM_CONFIG}" fi -CANDIDATES=("llvm-config-19" +CANDIDATES=("llvm-config-20" + "llvm-config-19" "llvm-config-18" "llvm-config-17" "llvm-config-16" diff --git a/host/bin/prospero-clang b/host/bin/prospero-clang index ae6df87..ae8bd97 100755 --- a/host/bin/prospero-clang +++ b/host/bin/prospero-clang @@ -56,6 +56,13 @@ if [[ "${TU}" == "" ]]; then LIBS_KERN="" fi + +# clang-20 started appending crt objects when linking +if [[ $($SCRIPT_DIR/llvm-config --version | cut -d. -f1) -ge 20 ]]; then + export SCE_PROSPERO_SDK_DIR="${PS5_PAYLOAD_SDK}" + LIBS_CRT="" +fi + # ensure clang knows where prospero-lld is at export PATH="${SCRIPT_DIR}:${PATH}" diff --git a/host/bin/prospero-clang++ b/host/bin/prospero-clang++ index 350f920..f843919 100755 --- a/host/bin/prospero-clang++ +++ b/host/bin/prospero-clang++ @@ -62,6 +62,12 @@ if [[ "${TU}" == "" ]]; then LIBS_KERN="" fi +# clang++-20 started appending crt objects when linking +if [[ $($SCRIPT_DIR/llvm-config --version | cut -d. -f1) -ge 20 ]]; then + export SCE_PROSPERO_SDK_DIR="${PS5_PAYLOAD_SDK}/" + LIBS_CRT="" +fi + # ensure clang++ knows where prospero-lld is at export PATH="${SCRIPT_DIR}:${PATH}" diff --git a/libc/Makefile b/libc/Makefile index 6343be2..6a49d20 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -16,14 +16,14 @@ DESTDIR ?= /opt/ps5-payload-sdk -CCS := clang-19 clang-18 clang-17 clang-16 clang-15 clang +CCS := clang-20 clang-19 clang-18 clang-17 clang-16 clang-15 clang CCS := $(foreach CC,$(CCS),$(if $(shell command -v $(CC) 2> /dev/null),$(CC))) CC := $(firstword $(CCS)) ifndef CC $(error No suitable compiler found) endif -ARS := llvm-ar-19 llvm-ar-18 llvm-ar-17 llvm-ar-16 llvm-ar-15 llvm-ar ar +ARS := llvm-ar-20 llvm-ar-19 llvm-ar-18 llvm-ar-17 llvm-ar-16 llvm-ar-15 llvm-ar ar ARS := $(foreach AR,$(ARS),$(if $(shell command -v $(AR) 2> /dev/null),$(AR))) AR := $(firstword $(ARS)) ifndef AR @@ -53,4 +53,3 @@ clean: install: $(ARCHIVE) install -d $(DESTDIR)/target/lib install $^ $(DESTDIR)/target/lib - diff --git a/sce_stubs/Makefile b/sce_stubs/Makefile index e05427b..e7b78a8 100644 --- a/sce_stubs/Makefile +++ b/sce_stubs/Makefile @@ -17,14 +17,14 @@ PYTHON ?= python3 DESTDIR ?= /opt/ps5-payload-sdk -CCS := clang-19 clang-18 clang-17 clang-16 clang-15 clang +CCS := clang-20 clang-19 clang-18 clang-17 clang-16 clang-15 clang CCS := $(foreach CC,$(CCS),$(if $(shell command -v $(CC) 2> /dev/null),$(CC))) CC := $(firstword $(CCS)) ifndef CC $(error No suitable compiler found) endif -LDS := ld.lld-19 ld.lld-18 ld.lld-17 ld.lld-16 ld.lld-15 ld.lld +LDS := ld.lld-20 ld.lld-19 ld.lld-18 ld.lld-17 ld.lld-16 ld.lld-15 ld.lld ld LDS := $(foreach LD,$(LDS),$(if $(shell command -v $(LD) 2> /dev/null),$(LD))) LD := $(firstword $(LDS)) ifndef LD @@ -77,3 +77,5 @@ clean: install: $(SHARED) install -d $(DESTDIR)/target/lib install $(SHARED) $(DESTDIR)/target/lib + ln -sf libkernel_web.so $(DESTDIR)/target/lib/libkernel_stub_weak.so + ln -sf libSceLibcInternal.so $(DESTDIR)/target/lib/libc_stub_weak.so