From ee3bb10df4f00374de607ef54bd57ab3aef69e80 Mon Sep 17 00:00:00 2001 From: fincs Date: Wed, 23 Jan 2019 19:30:07 +0100 Subject: [PATCH 01/18] First pass at adopting a devkitPro-style build system, see details: - Added wut_rules and wut/rpx/rpl.specs to share/ - Replaced wut's CMake-based buildsystem with a standard Makefile - Conflated all wut libraries into a single libwut.a library - wut's old buildsystems (CMake & plain make) are broken as a result, this will be fixed in the future - Docs, tests and samples are not buildable either at the moment - wutcrt/wutnewlib: - RPX start function is __rpx_start, while RPL is __rpl_start - __init/fini_wut_* functions are no longer weak - __init_wut/__fini_wut are instead weak - Removed _exit implementation - exit syscall now points to _Exit instead of pointing to itself - wutstdc++: - Renamed .cc files to .cpp - Temporarily disabled, due to an issue that will be addressed shortly - wutdevoptab: - Fixed uninitialized variable warnings in __wut_fs_read/write --- .gitignore | 3 + .gitmodules | 0 CMakeLists.txt | 38 ---- Makefile | 164 ++++++++++++++++++ cafe/CMakeLists.txt | 87 ---------- libraries/CMakeLists.txt | 18 -- libraries/libgfd/CMakeLists.txt | 15 -- libraries/libwhb/CMakeLists.txt | 42 ----- libraries/nn_swkbd/CMakeLists.txt | 14 -- libraries/wutcrt/CMakeLists.txt | 16 -- libraries/wutcrt/crt0_rpl.s | 4 +- libraries/wutcrt/crt0_rpx.s | 4 +- libraries/wutcrt/wut_crt.c | 53 ++---- libraries/wutdevoptab/CMakeLists.txt | 34 ---- libraries/wutdevoptab/devoptab_fs_read.c | 2 +- libraries/wutdevoptab/devoptab_fs_write.c | 2 +- libraries/wutmalloc/CMakeLists.txt | 9 - libraries/wutmalloc/wut_malloc.c | 2 +- libraries/wutnewlib/CMakeLists.txt | 15 -- libraries/wutnewlib/wut_newlib.c | 5 +- libraries/wutstdc++/CMakeLists.txt | 24 --- .../{wut_gthread.cc => wut_gthread.cpp} | 0 ...t_gthread_cond.cc => wut_gthread_cond.cpp} | 0 ...t_gthread_keys.cc => wut_gthread_keys.cpp} | 0 ...gthread_mutex.cc => wut_gthread_mutex.cpp} | 0 ...t_gthread_once.cc => wut_gthread_once.cpp} | 0 ...tex.cc => wut_gthread_recursive_mutex.cpp} | 0 ...hread_thread.cc => wut_gthread_thread.cpp} | 0 .../{wut_stdcpp.cc => wut_stdcpp.cpp} | 0 share/rpl.specs | 2 + share/rpx.specs | 2 + share/wut.specs | 4 + share/wut_rules | 52 ++++++ 33 files changed, 252 insertions(+), 359 deletions(-) delete mode 100644 .gitmodules delete mode 100644 CMakeLists.txt create mode 100644 Makefile delete mode 100644 cafe/CMakeLists.txt delete mode 100644 libraries/CMakeLists.txt delete mode 100644 libraries/libgfd/CMakeLists.txt delete mode 100644 libraries/libwhb/CMakeLists.txt delete mode 100644 libraries/nn_swkbd/CMakeLists.txt delete mode 100644 libraries/wutcrt/CMakeLists.txt delete mode 100644 libraries/wutdevoptab/CMakeLists.txt delete mode 100644 libraries/wutmalloc/CMakeLists.txt delete mode 100644 libraries/wutnewlib/CMakeLists.txt delete mode 100644 libraries/wutstdc++/CMakeLists.txt rename libraries/wutstdc++/{wut_gthread.cc => wut_gthread.cpp} (100%) rename libraries/wutstdc++/{wut_gthread_cond.cc => wut_gthread_cond.cpp} (100%) rename libraries/wutstdc++/{wut_gthread_keys.cc => wut_gthread_keys.cpp} (100%) rename libraries/wutstdc++/{wut_gthread_mutex.cc => wut_gthread_mutex.cpp} (100%) rename libraries/wutstdc++/{wut_gthread_once.cc => wut_gthread_once.cpp} (100%) rename libraries/wutstdc++/{wut_gthread_recursive_mutex.cc => wut_gthread_recursive_mutex.cpp} (100%) rename libraries/wutstdc++/{wut_gthread_thread.cc => wut_gthread_thread.cpp} (100%) rename libraries/wutstdc++/{wut_stdcpp.cc => wut_stdcpp.cpp} (100%) create mode 100644 share/rpl.specs create mode 100644 share/rpx.specs create mode 100644 share/wut.specs create mode 100644 share/wut_rules diff --git a/.gitignore b/.gitignore index b1d6780..a6f793c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ build/ +release/ +debug/ lib/ *.a *.o *.d *.elf +*.bz2 docs/html/ .vs/ CMakeSettings.json diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 27b298d..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -set(WUT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") -set(ENV{WUT_ROOT} "${WUT_ROOT}") -set(CMAKE_TOOLCHAIN_FILE "${WUT_ROOT}/share/wut.toolchain.cmake") - -project(wut) -option(WUT_BUILD_DOCS "Build documentation" OFF) - -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib") - -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib") - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin") - -if(WUT_BUILD_DOCS) - add_subdirectory(docs) -endif() - -find_program(WUT_RPLIMPORTGEN NAMES rplimportgen PATHS "${DEVKITPRO}/tools/bin") -if(NOT WUT_RPLIMPORTGEN) - message(FATAL_ERROR "Could not find rplimportgen.") -endif() - -add_subdirectory(cafe) -add_subdirectory(libraries) - -install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") - -install(DIRECTORY "${CMAKE_SOURCE_DIR}/share/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share") diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..144a239 --- /dev/null +++ b/Makefile @@ -0,0 +1,164 @@ + +TOPDIR ?= $(CURDIR) +include $(TOPDIR)/share/wut_rules + +export WUT_MAJOR := 1 +export WUT_MINOR := 0 +export WUT_PATCH := 0 + +VERSION := $(WUT_MAJOR).$(WUT_MINOR).$(WUT_PATCH) + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#--------------------------------------------------------------------------------- +TARGET := wut +#BUILD := build +SOURCES := cafe \ + libraries/wutcrt \ + libraries/wutnewlib \ + libraries/wutstdc++ \ + libraries/wutmalloc \ + libraries/wutdevoptab \ + libraries/libwhb/src \ + libraries/libgfd/src \ + libraries/nn_swkbd +DATA := data +INCLUDES := include \ + libraries/libwhb/include \ + libraries/libgfd/include \ + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +CFLAGS := -g -Wall -Werror -save-temps \ + -ffunction-sections -fdata-sections \ + $(MACHDEP) \ + $(BUILD_CFLAGS) + +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ + +CXXFLAGS := $(CFLAGS) -std=gnu++17 + +ASFLAGS := -g $(MACHDEP) + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I. + +.PHONY: all dist-bin dist-src dist install clean + +#--------------------------------------------------------------------------------- +all: lib/libwut.a lib/libwutd.a + +dist-bin: all + @tar --exclude=*~ -cjf wut-$(VERSION).tar.bz2 include lib share -C libraries/libwhb include -C ../libgfd include + +dist-src: + @tar --exclude=*~ -cjf wut-src-$(VERSION).tar.bz2 cafe include libraries share Makefile + +dist: dist-src dist-bin + +install: dist-bin + mkdir -p $(DESTDIR)$(DEVKITPRO)/wut + bzip2 -cd wut-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wut + +lib: + @[ -d $@ ] || mkdir -p $@ + +release: + @[ -d $@ ] || mkdir -p $@ + +debug: + @[ -d $@ ] || mkdir -p $@ + +lib/libwut.a : lib release $(SOURCES) $(INCLUDES) + @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DNDEBUG=1 -O2" \ + DEPSDIR=$(CURDIR)/release \ + --no-print-directory -C release \ + -f $(CURDIR)/Makefile + +lib/libwutd.a : lib debug $(SOURCES) $(INCLUDES) + @$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DDEBUG=1 -Og" \ + DEPSDIR=$(CURDIR)/debug \ + --no-print-directory -C debug \ + -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -rf release debug lib + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT) : $(OFILES) + +$(OFILES_SRC) : $(HFILES) + +#--------------------------------------------------------------------------------- +%_bin.h %.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- + diff --git a/cafe/CMakeLists.txt b/cafe/CMakeLists.txt deleted file mode 100644 index bf4b0bf..0000000 --- a/cafe/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -# Load up the in-tree toolchain -set(WUT_ROOT "{CMAKE_CURRENT_SOURCE_DIR}/.." CACHE STRING "") -set(WUT_RPLIMPORTGEN "" CACHE STRING "") -set(ENV{WUT_ROOT} ${WUT_ROOT}) -set(CMAKE_TOOLCHAIN_FILE $ENV{WUT_ROOT}/share/wut.toolchain.cmake) - -project(cafe C CXX) -enable_language(ASM) - -macro(add_cafe_library target) - add_custom_command( - OUTPUT ${target}.s - COMMAND ${WUT_RPLIMPORTGEN} ${CMAKE_CURRENT_SOURCE_DIR}/${target}.def ${target}.s - DEPENDS ${target}.def) - - add_library(${target} STATIC ${target}.s) - install(TARGETS ${target} ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -endmacro() - -add_cafe_library(avm) -add_cafe_library(camera) -add_cafe_library(coreinit) -add_cafe_library(dc) -add_cafe_library(dmae) -add_cafe_library(drmapp) -add_cafe_library(erreula) -add_cafe_library(gx2) -add_cafe_library(h264) -add_cafe_library(lzma920) -add_cafe_library(mic) -add_cafe_library(nfc) -add_cafe_library(nio_prof) -add_cafe_library(nlibcurl) -add_cafe_library(nlibnss) -add_cafe_library(nlibnss2) -add_cafe_library(nn_ac) -add_cafe_library(nn_acp) -add_cafe_library(nn_act) -add_cafe_library(nn_aoc) -add_cafe_library(nn_boss) -add_cafe_library(nn_ccr) -add_cafe_library(nn_cmpt) -add_cafe_library(nn_dlp) -add_cafe_library(nn_ec) -add_cafe_library(nn_fp) -add_cafe_library(nn_hai) -add_cafe_library(nn_hpad) -add_cafe_library(nn_idbe) -add_cafe_library(nn_ndm) -add_cafe_library(nn_nets2) -add_cafe_library(nn_nfp) -add_cafe_library(nn_nim) -add_cafe_library(nn_olv) -add_cafe_library(nn_pdm) -add_cafe_library(nn_save) -add_cafe_library(nn_sl) -add_cafe_library(nn_spm) -add_cafe_library(nn_temp) -add_cafe_library(nn_uds) -add_cafe_library(nn_vctl) -add_cafe_library(nsysccr) -add_cafe_library(nsyshid) -add_cafe_library(nsyskbd) -add_cafe_library(nsysnet) -add_cafe_library(nsysuhs) -add_cafe_library(nsysuvd) -add_cafe_library(ntag) -add_cafe_library(padscore) -add_cafe_library(proc_ui) -add_cafe_library(snd_core) -add_cafe_library(snd_user) -add_cafe_library(sndcore2) -add_cafe_library(snduser2) -add_cafe_library(swkbd) -add_cafe_library(sysapp) -add_cafe_library(tcl) -add_cafe_library(tve) -add_cafe_library(uac) -add_cafe_library(uac_rpl) -add_cafe_library(usb_mic) -add_cafe_library(uvc) -add_cafe_library(uvd) -add_cafe_library(vpad) -add_cafe_library(vpadbase) -add_cafe_library(zlib125) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt deleted file mode 100644 index 4e7c66f..0000000 --- a/libraries/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -# Load up the in-tree toolchain -set(WUT_ROOT "{CMAKE_CURRENT_SOURCE_DIR}/.." CACHE STRING "") -set(ENV{WUT_ROOT} ${WUT_ROOT}) -set(CMAKE_TOOLCHAIN_FILE $ENV{WUT_ROOT}/share/wut.toolchain.cmake) - -project(libraries C) - -add_definitions(-Wall -Werror) -add_subdirectory(libgfd) -add_subdirectory(libwhb) -add_subdirectory(nn_swkbd) -add_subdirectory(wutcrt) -add_subdirectory(wutdevoptab) -add_subdirectory(wutmalloc) -add_subdirectory(wutnewlib) -add_subdirectory(wutstdc++) diff --git a/libraries/libgfd/CMakeLists.txt b/libraries/libgfd/CMakeLists.txt deleted file mode 100644 index d031a82..0000000 --- a/libraries/libgfd/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(libgfd) - -add_library(gfd STATIC - src/gfd.c - include/gfd.h) - -target_include_directories(gfd PRIVATE "../../include") -target_include_directories(gfd PUBLIC "include") - -install(TARGETS gfd - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") diff --git a/libraries/libwhb/CMakeLists.txt b/libraries/libwhb/CMakeLists.txt deleted file mode 100644 index 31d8543..0000000 --- a/libraries/libwhb/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(libwhb) - -add_library(whb STATIC - src/commandserver.c - src/console.c - src/crash.c - src/file.c - src/gfx.c - src/gfx_heap.c - src/gfx_heap.h - src/gfx_shader.c - src/gfx_texture.c - src/libmanager.c - src/log.c - src/log_cafe.c - src/log_udp.c - src/proc.c - src/sdcard.c - include/whb/align.h - include/whb/commandserver.h - include/whb/crash.h - include/whb/file.h - include/whb/gfx.h - include/whb/libmanager.h - include/whb/log_cafe.h - include/whb/log_console.h - include/whb/log.h - include/whb/log_udp.h - include/whb/proc.h - include/whb/sdcard.h) - -target_include_directories(whb PRIVATE "../../include") -target_include_directories(whb PRIVATE "../libgfd/include") -target_include_directories(whb PUBLIC "include") - -install(TARGETS whb - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") - diff --git a/libraries/nn_swkbd/CMakeLists.txt b/libraries/nn_swkbd/CMakeLists.txt deleted file mode 100644 index 702c4de..0000000 --- a/libraries/nn_swkbd/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(nn_swkbd CXX) - -add_library(nn_swkbd - nn_swkbd.cpp) - -target_include_directories(nn_swkbd - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${WUT_ROOT}/include") - -install(TARGETS nn_swkbd - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") diff --git a/libraries/wutcrt/CMakeLists.txt b/libraries/wutcrt/CMakeLists.txt deleted file mode 100644 index b293b82..0000000 --- a/libraries/wutcrt/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutcrt C ASM) - -add_library(wutcrt - crt0_rpx.s - wut_crt.c) - -add_library(wutcrtrpl - crt0_rpl.s - wut_crt.c) - -target_include_directories(wutcrt PRIVATE "${WUT_ROOT}/include") -target_include_directories(wutcrtrpl PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutcrt wutcrtrpl - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutcrt/crt0_rpl.s b/libraries/wutcrt/crt0_rpl.s index 82ac12e..1ed6d91 100644 --- a/libraries/wutcrt/crt0_rpl.s +++ b/libraries/wutcrt/crt0_rpl.s @@ -3,8 +3,8 @@ .extern __init_wut .extern __fini_wut -.global _start -_start: +.global __rpl_start +__rpl_start: stwu 1, -0x14(1) mflr 0 stw 0, 0x18(1) diff --git a/libraries/wutcrt/crt0_rpx.s b/libraries/wutcrt/crt0_rpx.s index 319bfde..c80c669 100644 --- a/libraries/wutcrt/crt0_rpx.s +++ b/libraries/wutcrt/crt0_rpx.s @@ -3,8 +3,8 @@ .extern __init_wut .extern __fini_wut -.global _start -_start: +.global __rpx_start +__rpx_start: stwu 1, -0x14(1) mflr 0 stw 0, 0x18(1) diff --git a/libraries/wutcrt/wut_crt.c b/libraries/wutcrt/wut_crt.c index 80d8097..7eecbbf 100644 --- a/libraries/wutcrt/wut_crt.c +++ b/libraries/wutcrt/wut_crt.c @@ -1,48 +1,23 @@ -extern void __init_wut_newlib() __attribute__((weak)); -extern void __init_wut_devoptab() __attribute__((weak)); -extern void __init_wut_stdcpp() __attribute__((weak)); +void __init_wut_newlib(); +void __init_wut_stdcpp(); +void __init_wut_devoptab(); -extern void __fini_wut_devoptab() __attribute__((weak)); -extern void __fini_wut_newlib() __attribute__((weak)); -extern void __fini_wut_stdcpp() __attribute__((weak)); +void __fini_wut_newlib(); +void __fini_wut_stdcpp(); +void __fini_wut_devoptab(); -void +void __attribute__((weak)) __init_wut() { - if (__init_wut_newlib) { - __init_wut_newlib(); - } - - if (__init_wut_devoptab) { - __init_wut_devoptab(); - } - - if (__init_wut_stdcpp) { - __init_wut_stdcpp(); - } + __init_wut_newlib(); + //__init_wut_stdcpp(); + __init_wut_devoptab(); } -void +void __attribute__((weak)) __fini_wut() { - if (__fini_wut_stdcpp) { - __fini_wut_stdcpp(); - } - - if (__fini_wut_devoptab) { - __fini_wut_devoptab(); - } - - if (__fini_wut_newlib) { - __fini_wut_newlib(); - } -} - -// Forward newlib _exit to the coreinit.rpl _Exit -extern void _Exit(int status); - -void -_exit(int status) -{ - _Exit(status); + __fini_wut_devoptab(); + //__fini_wut_stdcpp(); + __fini_wut_newlib(); } diff --git a/libraries/wutdevoptab/CMakeLists.txt b/libraries/wutdevoptab/CMakeLists.txt deleted file mode 100644 index cdd1f3b..0000000 --- a/libraries/wutdevoptab/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutdevoptab C) - -add_library(wutdevoptab - devoptab_fs.c - devoptab_fs_chdir.c - devoptab_fs_chmod.c - devoptab_fs_close.c - devoptab_fs_dirclose.c - devoptab_fs_dirnext.c - devoptab_fs_diropen.c - devoptab_fs_dirreset.c - devoptab_fs_fchmod.c - devoptab_fs_fstat.c - devoptab_fs_fsync.c - devoptab_fs_getmtime.c - devoptab_fs_link.c - devoptab_fs_mkdir.c - devoptab_fs_open.c - devoptab_fs_read.c - devoptab_fs_rename.c - devoptab_fs_rmdir.c - devoptab_fs_seek.c - devoptab_fs_stat.c - devoptab_fs_statvfs.c - devoptab_fs_truncate.c - devoptab_fs_unlink.c - devoptab_fs_utils.c - devoptab_fs_write.c) - -target_include_directories(wutdevoptab PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutdevoptab - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutdevoptab/devoptab_fs_read.c b/libraries/wutdevoptab/devoptab_fs_read.c index 33df4ea..52e1e58 100644 --- a/libraries/wutdevoptab/devoptab_fs_read.c +++ b/libraries/wutdevoptab/devoptab_fs_read.c @@ -6,7 +6,7 @@ __wut_fs_read(struct _reent *r, char *ptr, size_t len) { - FSStatus status; + FSStatus status = 0; FSCmdBlock cmd; uint8_t *alignedReadBuffer; uint32_t bytes, bytesRead; diff --git a/libraries/wutdevoptab/devoptab_fs_write.c b/libraries/wutdevoptab/devoptab_fs_write.c index cffdb16..93b8ef2 100644 --- a/libraries/wutdevoptab/devoptab_fs_write.c +++ b/libraries/wutdevoptab/devoptab_fs_write.c @@ -6,7 +6,7 @@ __wut_fs_write(struct _reent *r, const char *ptr, size_t len) { - FSStatus status; + FSStatus status = 0; FSCmdBlock cmd; uint8_t *alignedWriteBuffer; uint32_t bytes, bytesWritten; diff --git a/libraries/wutmalloc/CMakeLists.txt b/libraries/wutmalloc/CMakeLists.txt deleted file mode 100644 index 80ff196..0000000 --- a/libraries/wutmalloc/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutmalloc C) - -add_library(wutmalloc - wut_malloc.c) -target_include_directories(wutmalloc PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutmalloc - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutmalloc/wut_malloc.c b/libraries/wutmalloc/wut_malloc.c index a929006..0663219 100644 --- a/libraries/wutmalloc/wut_malloc.c +++ b/libraries/wutmalloc/wut_malloc.c @@ -5,7 +5,7 @@ #include // Limit sbrk heap to 128kb -uint32_t __attribute__((weak)) __wut_heap_max_size = 128 * 1024; +uint32_t __wut_heap_max_size = 128 * 1024; void * _malloc_r(struct _reent *r, size_t size) diff --git a/libraries/wutnewlib/CMakeLists.txt b/libraries/wutnewlib/CMakeLists.txt deleted file mode 100644 index 9b011d9..0000000 --- a/libraries/wutnewlib/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutnewlib C) - -add_library(wutnewlib - wut_clock.c - wut_gettod_r.c - wut_lock.c - wut_malloc_lock.c - wut_nanosleep.c - wut_newlib.c - wut_sbrk.c) -target_include_directories(wutnewlib PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutnewlib - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutnewlib/wut_newlib.c b/libraries/wutnewlib/wut_newlib.c index 70fd641..d4af598 100644 --- a/libraries/wutnewlib/wut_newlib.c +++ b/libraries/wutnewlib/wut_newlib.c @@ -1,6 +1,9 @@ #include "wut_newlib.h" #include +// Forward newlib _exit to the coreinit.rpl _Exit +extern void _Exit(int status); + static void __init_wut_syscall_array() { @@ -11,7 +14,7 @@ __init_wut_syscall_array() __syscalls.lock_release = __wut_lock_release; __syscalls.malloc_lock = __wut_malloc_lock; __syscalls.malloc_unlock = __wut_malloc_unlock; - __syscalls.exit = exit; + __syscalls.exit = _Exit; __syscalls.gettod_r = __wut_gettod_r; __syscalls.clock_gettime = __wut_clock_gettime; __syscalls.clock_settime = __wut_clock_settime; diff --git a/libraries/wutstdc++/CMakeLists.txt b/libraries/wutstdc++/CMakeLists.txt deleted file mode 100644 index 7d16c48..0000000 --- a/libraries/wutstdc++/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutstdc++ CXX) - -add_library(wutstdc++ - wut_gthread.cc - wut_gthread_cond.cc - wut_gthread_keys.cc - wut_gthread_mutex.cc - wut_gthread_once.cc - wut_gthread_recursive_mutex.cc - wut_gthread_thread.cc - wut_stdcpp.cc) - -target_compile_definitions(wutstdc++ - PRIVATE _GLIBCXX_HAS_GTHREADS) - -target_include_directories(wutstdc++ - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${WUT_ROOT}/include") - -install(TARGETS wutstdc++ - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") diff --git a/libraries/wutstdc++/wut_gthread.cc b/libraries/wutstdc++/wut_gthread.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread.cc rename to libraries/wutstdc++/wut_gthread.cpp diff --git a/libraries/wutstdc++/wut_gthread_cond.cc b/libraries/wutstdc++/wut_gthread_cond.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_cond.cc rename to libraries/wutstdc++/wut_gthread_cond.cpp diff --git a/libraries/wutstdc++/wut_gthread_keys.cc b/libraries/wutstdc++/wut_gthread_keys.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_keys.cc rename to libraries/wutstdc++/wut_gthread_keys.cpp diff --git a/libraries/wutstdc++/wut_gthread_mutex.cc b/libraries/wutstdc++/wut_gthread_mutex.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_mutex.cc rename to libraries/wutstdc++/wut_gthread_mutex.cpp diff --git a/libraries/wutstdc++/wut_gthread_once.cc b/libraries/wutstdc++/wut_gthread_once.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_once.cc rename to libraries/wutstdc++/wut_gthread_once.cpp diff --git a/libraries/wutstdc++/wut_gthread_recursive_mutex.cc b/libraries/wutstdc++/wut_gthread_recursive_mutex.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_recursive_mutex.cc rename to libraries/wutstdc++/wut_gthread_recursive_mutex.cpp diff --git a/libraries/wutstdc++/wut_gthread_thread.cc b/libraries/wutstdc++/wut_gthread_thread.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_thread.cc rename to libraries/wutstdc++/wut_gthread_thread.cpp diff --git a/libraries/wutstdc++/wut_stdcpp.cc b/libraries/wutstdc++/wut_stdcpp.cpp similarity index 100% rename from libraries/wutstdc++/wut_stdcpp.cc rename to libraries/wutstdc++/wut_stdcpp.cpp diff --git a/share/rpl.specs b/share/rpl.specs new file mode 100644 index 0000000..8d211a5 --- /dev/null +++ b/share/rpl.specs @@ -0,0 +1,2 @@ +*wut_entry: +--entry=__rpl_start diff --git a/share/rpx.specs b/share/rpx.specs new file mode 100644 index 0000000..9d2a1ad --- /dev/null +++ b/share/rpx.specs @@ -0,0 +1,2 @@ +*wut_entry: +--entry=__rpx_start diff --git a/share/wut.specs b/share/wut.specs new file mode 100644 index 0000000..75905bc --- /dev/null +++ b/share/wut.specs @@ -0,0 +1,4 @@ +%rename link old_link + +*link: +%(old_link) -T %:getenv(DEVKITPRO /wut/share/wut.ld) --gc-sections --emit-relocs -z nocopyreloc %(wut_entry) diff --git a/share/wut_rules b/share/wut_rules new file mode 100644 index 0000000..6e3aa48 --- /dev/null +++ b/share/wut_rules @@ -0,0 +1,52 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitPro") +endif + +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=/devkitPro/devkitPPC") +endif + +include $(DEVKITPPC)/base_rules + +PORTLIBS := $(PORTLIBS_PATH)/wiiu $(PORTLIBS_PATH)/ppc + +export PATH := $(PORTLIBS_PATH)/wiiu/bin:$(PORTLIBS_PATH)/ppc/bin:$(PATH) + +WUT_ROOT ?= $(DEVKITPRO)/wut + +RPXSPECS := -specs=$(WUT_ROOT)/share/wut.specs -specs=$(WUT_ROOT)/share/rpx.specs +RPLSPECS := -specs=$(WUT_ROOT)/share/wut.specs -specs=$(WUT_ROOT)/share/rpl.specs + +MACHDEP = -DESPRESSO -mcpu=750 -meabi -mhard-float + +#--------------------------------------------------------------------------------- +%.rpx: %.elf + @cp $< $*.strip.elf + @$(STRIP) -g $*.strip.elf + @elf2rpl $*.strip.elf $@ + @rm $*.strip.elf + @echo built ... $(notdir $@) + +#--------------------------------------------------------------------------------- +%.rpl: %.elf + @cp $< $*.strip.elf + @$(STRIP) -g $*.strip.elf + @elf2rpl --rpl $*.strip.elf $@ + @rm $*.strip.elf + @echo built ... $(notdir $@) + +#--------------------------------------------------------------------------------- +%.elf: + @echo linking ... $(notdir $@) + @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ + @$(NM) -CSn $@ > $(notdir $*.lst) + +#--------------------------------------------------------------------------------- +%.o: %.def + @echo $(notdir $<) + @rplimportgen $< $*.s + $(CC) -x assembler-with-cpp $(ASFLAGS) -c $*.s -o $@ $(ERROR_FILTER) From 26ac7b3ff2940745fb21cce3c1721b2b6ebdeb1c Mon Sep 17 00:00:00 2001 From: fincs Date: Wed, 23 Jan 2019 19:43:05 +0100 Subject: [PATCH 02/18] wutmalloc: Bugfixes, see details: - Added (dummy) __init/fini_wut_malloc stubs called by wutcrt in order to ensure that wutmalloc gets linked in - malloc/realloc/calloc now properly set errno to ENOMEM during failure - realloc no longer fails if ptr==NULL (in this case it works like a regular malloc) - realloc no longer does an out of bounds copy if the new size is smaller than the old size - free(NULL) is now supported as per the C standard - Disabled sbrk/malloc-lock support code in wutnewlib because newlib's malloc is replaced with wutmalloc --- libraries/wutcrt/wut_crt.c | 4 ++++ libraries/wutmalloc/wut_malloc.c | 41 +++++++++++++++++++++++++------- libraries/wutnewlib/wut_newlib.c | 12 +++++----- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/libraries/wutcrt/wut_crt.c b/libraries/wutcrt/wut_crt.c index 7eecbbf..076957e 100644 --- a/libraries/wutcrt/wut_crt.c +++ b/libraries/wutcrt/wut_crt.c @@ -1,7 +1,9 @@ +void __init_wut_malloc(); void __init_wut_newlib(); void __init_wut_stdcpp(); void __init_wut_devoptab(); +void __fini_wut_malloc(); void __fini_wut_newlib(); void __fini_wut_stdcpp(); void __fini_wut_devoptab(); @@ -9,6 +11,7 @@ void __fini_wut_devoptab(); void __attribute__((weak)) __init_wut() { + __init_wut_malloc(); __init_wut_newlib(); //__init_wut_stdcpp(); __init_wut_devoptab(); @@ -20,4 +23,5 @@ __fini_wut() __fini_wut_devoptab(); //__fini_wut_stdcpp(); __fini_wut_newlib(); + __fini_wut_malloc(); } diff --git a/libraries/wutmalloc/wut_malloc.c b/libraries/wutmalloc/wut_malloc.c index 0663219..c485721 100644 --- a/libraries/wutmalloc/wut_malloc.c +++ b/libraries/wutmalloc/wut_malloc.c @@ -3,41 +3,64 @@ #include #include #include +#include // Limit sbrk heap to 128kb uint32_t __wut_heap_max_size = 128 * 1024; +void +__init_wut_malloc(void) +{ +} + +void +__fini_wut_malloc(void) +{ +} + void * _malloc_r(struct _reent *r, size_t size) { - return MEMAllocFromDefaultHeap(size); + void *ptr = MEMAllocFromDefaultHeap(size); + if (!ptr) { + r->_errno = ENOMEM; + } + return ptr; } void _free_r(struct _reent *r, void *ptr) { - MEMFreeToDefaultHeap(ptr); + if (ptr) { + MEMFreeToDefaultHeap(ptr); + } } void * _realloc_r(struct _reent *r, void *ptr, size_t size) { - void *new_ptr = _malloc_r(r, size); - if (!ptr || !new_ptr) { + void *new_ptr = MEMAllocFromDefaultHeap(size); + if (!new_ptr) { + r->_errno = ENOMEM; return new_ptr; } - memcpy(new_ptr, ptr, MEMGetSizeForMBlockExpHeap(ptr)); - _free_r(r, ptr); + if (ptr) { + size_t old_size = MEMGetSizeForMBlockExpHeap(ptr); + memcpy(new_ptr, ptr, old_size <= size ? old_size : size); + MEMFreeToDefaultHeap(ptr); + } return new_ptr; } void * _calloc_r(struct _reent *r, size_t num, size_t size) { - void *ptr = _malloc_r(r, num * size); + void *ptr = MEMAllocFromDefaultHeap(num * size); if (ptr) { memset(ptr, 0, num * size); + } else { + r->_errno = ENOMEM; } return ptr; @@ -75,13 +98,13 @@ _malloc_usable_size_r(struct _reent *r, void *ptr) void * _valloc_r(struct _reent *r, size_t size) { - return _memalign_r(r, OS_PAGE_SIZE, size); + return MEMAllocFromDefaultHeapEx(size, OS_PAGE_SIZE); } void * _pvalloc_r(struct _reent *r, size_t size) { - return _memalign_r(r, OS_PAGE_SIZE, (size + (OS_PAGE_SIZE - 1)) & ~(OS_PAGE_SIZE - 1)); + return MEMAllocFromDefaultHeapEx((size + (OS_PAGE_SIZE - 1)) & ~(OS_PAGE_SIZE - 1), OS_PAGE_SIZE); } int diff --git a/libraries/wutnewlib/wut_newlib.c b/libraries/wutnewlib/wut_newlib.c index d4af598..4eda7d0 100644 --- a/libraries/wutnewlib/wut_newlib.c +++ b/libraries/wutnewlib/wut_newlib.c @@ -7,13 +7,13 @@ extern void _Exit(int status); static void __init_wut_syscall_array() { - __syscalls.sbrk_r = __wut_sbrk_r; + //__syscalls.sbrk_r = __wut_sbrk_r; __syscalls.lock_init = __wut_lock_init; __syscalls.lock_close = __wut_lock_close; __syscalls.lock_acquire = __wut_lock_acquire; __syscalls.lock_release = __wut_lock_release; - __syscalls.malloc_lock = __wut_malloc_lock; - __syscalls.malloc_unlock = __wut_malloc_unlock; + //__syscalls.malloc_lock = __wut_malloc_lock; + //__syscalls.malloc_unlock = __wut_malloc_unlock; __syscalls.exit = _Exit; __syscalls.gettod_r = __wut_gettod_r; __syscalls.clock_gettime = __wut_clock_gettime; @@ -25,13 +25,13 @@ __init_wut_syscall_array() void __init_wut_newlib() { - __init_wut_sbrk_heap(); - __init_wut_malloc_lock(); + //__init_wut_sbrk_heap(); + //__init_wut_malloc_lock(); __init_wut_syscall_array(); } void __fini_wut_newlib() { - __fini_wut_sbrk_heap(); + //__fini_wut_sbrk_heap(); } From 3e179891e9c1b1ad6211a33c13bc06aa480fa48a Mon Sep 17 00:00:00 2001 From: fincs Date: Thu, 24 Jan 2019 22:56:48 +0100 Subject: [PATCH 03/18] Make sure .fexports/.dexports sections don't get garbage collected --- share/wut.ld | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/wut.ld b/share/wut.ld index e666586..775e7c6 100644 --- a/share/wut.ld +++ b/share/wut.ld @@ -143,8 +143,8 @@ SECTIONS } > relmem . = ORIGIN(loadmem); - .fexports ALIGN(32) : { *(.fexports) } > loadmem - .dexports ALIGN(32) : { *(.dexports) } > loadmem + .fexports ALIGN(32) : { KEEP( *(.fexports) ) } > loadmem + .dexports ALIGN(32) : { KEEP( *(.dexports) ) } > loadmem .fimport_avm ALIGN(16) : { *(.fimport_avm) } > loadmem .fimport_camera ALIGN(16) : { *(.fimport_camera) } > loadmem From 0b920cf9b9eef766f982faac2300f75a235d2507 Mon Sep 17 00:00:00 2001 From: fincs Date: Thu, 24 Jan 2019 22:59:02 +0100 Subject: [PATCH 04/18] Automatically link wutstdc++ when C++ is used --- libraries/wutcrt/wut_crt.c | 12 ++++++++---- libraries/wutstdc++/wut_stdcpp.cpp | 11 +++++++++++ share/wut.specs | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libraries/wutcrt/wut_crt.c b/libraries/wutcrt/wut_crt.c index 076957e..fa15cdb 100644 --- a/libraries/wutcrt/wut_crt.c +++ b/libraries/wutcrt/wut_crt.c @@ -1,11 +1,11 @@ void __init_wut_malloc(); void __init_wut_newlib(); -void __init_wut_stdcpp(); +extern void __init_wut_stdcpp() __attribute__((weak)); void __init_wut_devoptab(); void __fini_wut_malloc(); void __fini_wut_newlib(); -void __fini_wut_stdcpp(); +extern void __fini_wut_stdcpp() __attribute__((weak)); void __fini_wut_devoptab(); void __attribute__((weak)) @@ -13,7 +13,9 @@ __init_wut() { __init_wut_malloc(); __init_wut_newlib(); - //__init_wut_stdcpp(); + if (__init_wut_stdcpp) { + __init_wut_stdcpp(); + } __init_wut_devoptab(); } @@ -21,7 +23,9 @@ void __attribute__((weak)) __fini_wut() { __fini_wut_devoptab(); - //__fini_wut_stdcpp(); + if (__fini_wut_stdcpp) { + __fini_wut_stdcpp(); + } __fini_wut_newlib(); __fini_wut_malloc(); } diff --git a/libraries/wutstdc++/wut_stdcpp.cpp b/libraries/wutstdc++/wut_stdcpp.cpp index f15f6df..530e950 100644 --- a/libraries/wutstdc++/wut_stdcpp.cpp +++ b/libraries/wutstdc++/wut_stdcpp.cpp @@ -1,5 +1,16 @@ #include "wut_gthread.h" +__asm__ __volatile__( + "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n" + "\t.align\t2\n" + "\t.globl\t__wrap___gxx_personality_v0\n" + "\t.type\t__wrap___gxx_personality_v0, @function\n" + "__wrap___gxx_personality_v0:\n" + "\t.cfi_startproc\n" + "\tb\t__real___gxx_personality_v0\n" + "\t.cfi_endproc" +); + extern "C" void __init_wut_stdcpp() { diff --git a/share/wut.specs b/share/wut.specs index 75905bc..6b44cfd 100644 --- a/share/wut.specs +++ b/share/wut.specs @@ -1,4 +1,4 @@ %rename link old_link *link: -%(old_link) -T %:getenv(DEVKITPRO /wut/share/wut.ld) --gc-sections --emit-relocs -z nocopyreloc %(wut_entry) +%(old_link) -T %:getenv(DEVKITPRO /wut/share/wut.ld) --gc-sections --emit-relocs -z nocopyreloc -wrap __gxx_personality_v0 %(wut_entry) From 370eeb28e94ccfcff981842bc55a16258fec252c Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 16:44:42 +1000 Subject: [PATCH 05/18] wutstdc++: Move __gxx_personality to dedicated Assembly file I was getting issues with __volatile__ for unknown reason, so moving this to a dedicated file sidesteps the issue entirely and passes this straight to GAS. --- libraries/wutstdc++/wut_stdcpp.cpp | 11 ----------- libraries/wutstdc++/wut_stdcpp_personality.s | 10 ++++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 libraries/wutstdc++/wut_stdcpp_personality.s diff --git a/libraries/wutstdc++/wut_stdcpp.cpp b/libraries/wutstdc++/wut_stdcpp.cpp index 530e950..f15f6df 100644 --- a/libraries/wutstdc++/wut_stdcpp.cpp +++ b/libraries/wutstdc++/wut_stdcpp.cpp @@ -1,16 +1,5 @@ #include "wut_gthread.h" -__asm__ __volatile__( - "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n" - "\t.align\t2\n" - "\t.globl\t__wrap___gxx_personality_v0\n" - "\t.type\t__wrap___gxx_personality_v0, @function\n" - "__wrap___gxx_personality_v0:\n" - "\t.cfi_startproc\n" - "\tb\t__real___gxx_personality_v0\n" - "\t.cfi_endproc" -); - extern "C" void __init_wut_stdcpp() { diff --git a/libraries/wutstdc++/wut_stdcpp_personality.s b/libraries/wutstdc++/wut_stdcpp_personality.s new file mode 100644 index 0000000..13b9e7f --- /dev/null +++ b/libraries/wutstdc++/wut_stdcpp_personality.s @@ -0,0 +1,10 @@ +.section .text.__wrap___gxx_personality_v0,"ax",@progbits +.align 2 + +.globl __wrap___gxx_personality_v0 +.type __wrap___gxx_personality_v0, @function + +__wrap___gxx_personality_v0: + .cfi_startproc + b __real___gxx_personality_v0 + .cfi_endproc From 5f1da6432ca40334e10219cb65e38fe90ff3f09c Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 18:39:03 +1000 Subject: [PATCH 06/18] samples: Move all into cmake directory, WUT_ROOT->DEVKITPRO/wut --- samples/{ => cmake}/CMakeLists.txt | 4 ++-- samples/{ => cmake}/content/README.txt | 0 samples/{ => cmake}/content/pos_col_shader.gsh | Bin samples/{ => cmake}/content/pos_col_shader.psh | 0 samples/{ => cmake}/content/pos_col_shader.vsh | 0 samples/{ => cmake}/curl/CMakeLists.txt | 2 +- samples/{ => cmake}/curl/main.c | 0 .../{ => cmake}/custom_default_heap/CMakeLists.txt | 2 +- samples/{ => cmake}/custom_default_heap/exports.def | 0 samples/{ => cmake}/custom_default_heap/main.c | 0 samples/{ => cmake}/gx2_triangle/CMakeLists.txt | 2 +- samples/{ => cmake}/gx2_triangle/main.c | 0 samples/{ => cmake}/helloworld/CMakeLists.txt | 2 +- samples/{ => cmake}/helloworld/main.c | 0 samples/{ => cmake}/helloworld_cpp/CMakeLists.txt | 2 +- samples/{ => cmake}/helloworld_cpp/main.cpp | 0 samples/{ => cmake}/my_first_rpl/CMakeLists.txt | 2 +- samples/{ => cmake}/my_first_rpl/exports.def | 0 samples/{ => cmake}/my_first_rpl/my_first_rpl.c | 0 samples/{ => cmake}/swkbd/CMakeLists.txt | 2 +- samples/{ => cmake}/swkbd/main.cpp | 0 21 files changed, 9 insertions(+), 9 deletions(-) rename samples/{ => cmake}/CMakeLists.txt (74%) rename samples/{ => cmake}/content/README.txt (100%) rename samples/{ => cmake}/content/pos_col_shader.gsh (100%) rename samples/{ => cmake}/content/pos_col_shader.psh (100%) rename samples/{ => cmake}/content/pos_col_shader.vsh (100%) rename samples/{ => cmake}/curl/CMakeLists.txt (85%) rename samples/{ => cmake}/curl/main.c (100%) rename samples/{ => cmake}/custom_default_heap/CMakeLists.txt (89%) rename samples/{ => cmake}/custom_default_heap/exports.def (100%) rename samples/{ => cmake}/custom_default_heap/main.c (100%) rename samples/{ => cmake}/gx2_triangle/CMakeLists.txt (86%) rename samples/{ => cmake}/gx2_triangle/main.c (100%) rename samples/{ => cmake}/helloworld/CMakeLists.txt (85%) rename samples/{ => cmake}/helloworld/main.c (100%) rename samples/{ => cmake}/helloworld_cpp/CMakeLists.txt (90%) rename samples/{ => cmake}/helloworld_cpp/main.cpp (100%) rename samples/{ => cmake}/my_first_rpl/CMakeLists.txt (85%) rename samples/{ => cmake}/my_first_rpl/exports.def (100%) rename samples/{ => cmake}/my_first_rpl/my_first_rpl.c (100%) rename samples/{ => cmake}/swkbd/CMakeLists.txt (88%) rename samples/{ => cmake}/swkbd/main.cpp (100%) diff --git a/samples/CMakeLists.txt b/samples/cmake/CMakeLists.txt similarity index 74% rename from samples/CMakeLists.txt rename to samples/cmake/CMakeLists.txt index 1f6f3a9..aefae08 100644 --- a/samples/CMakeLists.txt +++ b/samples/cmake/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.2) -set(CMAKE_TOOLCHAIN_FILE $ENV{WUT_ROOT}/share/wut.toolchain.cmake) +set(CMAKE_TOOLCHAIN_FILE $ENV{DEVKITPRO}/wut/share/wut.toolchain.cmake) project(samples) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_subdirectory(curl) add_subdirectory(custom_default_heap) diff --git a/samples/content/README.txt b/samples/cmake/content/README.txt similarity index 100% rename from samples/content/README.txt rename to samples/cmake/content/README.txt diff --git a/samples/content/pos_col_shader.gsh b/samples/cmake/content/pos_col_shader.gsh similarity index 100% rename from samples/content/pos_col_shader.gsh rename to samples/cmake/content/pos_col_shader.gsh diff --git a/samples/content/pos_col_shader.psh b/samples/cmake/content/pos_col_shader.psh similarity index 100% rename from samples/content/pos_col_shader.psh rename to samples/cmake/content/pos_col_shader.psh diff --git a/samples/content/pos_col_shader.vsh b/samples/cmake/content/pos_col_shader.vsh similarity index 100% rename from samples/content/pos_col_shader.vsh rename to samples/cmake/content/pos_col_shader.vsh diff --git a/samples/curl/CMakeLists.txt b/samples/cmake/curl/CMakeLists.txt similarity index 85% rename from samples/curl/CMakeLists.txt rename to samples/cmake/curl/CMakeLists.txt index e4dd5bd..2d3b5e4 100644 --- a/samples/curl/CMakeLists.txt +++ b/samples/cmake/curl/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(curl C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(curl main.c) diff --git a/samples/curl/main.c b/samples/cmake/curl/main.c similarity index 100% rename from samples/curl/main.c rename to samples/cmake/curl/main.c diff --git a/samples/custom_default_heap/CMakeLists.txt b/samples/cmake/custom_default_heap/CMakeLists.txt similarity index 89% rename from samples/custom_default_heap/CMakeLists.txt rename to samples/cmake/custom_default_heap/CMakeLists.txt index a3de174..bf1f6bd 100644 --- a/samples/custom_default_heap/CMakeLists.txt +++ b/samples/cmake/custom_default_heap/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(custom_default_heap C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(custom_default_heap main.c) diff --git a/samples/custom_default_heap/exports.def b/samples/cmake/custom_default_heap/exports.def similarity index 100% rename from samples/custom_default_heap/exports.def rename to samples/cmake/custom_default_heap/exports.def diff --git a/samples/custom_default_heap/main.c b/samples/cmake/custom_default_heap/main.c similarity index 100% rename from samples/custom_default_heap/main.c rename to samples/cmake/custom_default_heap/main.c diff --git a/samples/gx2_triangle/CMakeLists.txt b/samples/cmake/gx2_triangle/CMakeLists.txt similarity index 86% rename from samples/gx2_triangle/CMakeLists.txt rename to samples/cmake/gx2_triangle/CMakeLists.txt index 231f3d5..fcd4114 100644 --- a/samples/gx2_triangle/CMakeLists.txt +++ b/samples/cmake/gx2_triangle/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(gx2_triangle C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(gx2_triangle main.c) diff --git a/samples/gx2_triangle/main.c b/samples/cmake/gx2_triangle/main.c similarity index 100% rename from samples/gx2_triangle/main.c rename to samples/cmake/gx2_triangle/main.c diff --git a/samples/helloworld/CMakeLists.txt b/samples/cmake/helloworld/CMakeLists.txt similarity index 85% rename from samples/helloworld/CMakeLists.txt rename to samples/cmake/helloworld/CMakeLists.txt index 7fe9844..e5a5d20 100644 --- a/samples/helloworld/CMakeLists.txt +++ b/samples/cmake/helloworld/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(helloworld C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(helloworld main.c) diff --git a/samples/helloworld/main.c b/samples/cmake/helloworld/main.c similarity index 100% rename from samples/helloworld/main.c rename to samples/cmake/helloworld/main.c diff --git a/samples/helloworld_cpp/CMakeLists.txt b/samples/cmake/helloworld_cpp/CMakeLists.txt similarity index 90% rename from samples/helloworld_cpp/CMakeLists.txt rename to samples/cmake/helloworld_cpp/CMakeLists.txt index 5c8496a..7bac5e2 100644 --- a/samples/helloworld_cpp/CMakeLists.txt +++ b/samples/cmake/helloworld_cpp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(helloworld_cpp CXX) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(helloworld_cpp main.cpp) diff --git a/samples/helloworld_cpp/main.cpp b/samples/cmake/helloworld_cpp/main.cpp similarity index 100% rename from samples/helloworld_cpp/main.cpp rename to samples/cmake/helloworld_cpp/main.cpp diff --git a/samples/my_first_rpl/CMakeLists.txt b/samples/cmake/my_first_rpl/CMakeLists.txt similarity index 85% rename from samples/my_first_rpl/CMakeLists.txt rename to samples/cmake/my_first_rpl/CMakeLists.txt index dd8e047..afcebab 100644 --- a/samples/my_first_rpl/CMakeLists.txt +++ b/samples/cmake/my_first_rpl/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(my_first_rpl C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(my_first_rpl my_first_rpl.c) diff --git a/samples/my_first_rpl/exports.def b/samples/cmake/my_first_rpl/exports.def similarity index 100% rename from samples/my_first_rpl/exports.def rename to samples/cmake/my_first_rpl/exports.def diff --git a/samples/my_first_rpl/my_first_rpl.c b/samples/cmake/my_first_rpl/my_first_rpl.c similarity index 100% rename from samples/my_first_rpl/my_first_rpl.c rename to samples/cmake/my_first_rpl/my_first_rpl.c diff --git a/samples/swkbd/CMakeLists.txt b/samples/cmake/swkbd/CMakeLists.txt similarity index 88% rename from samples/swkbd/CMakeLists.txt rename to samples/cmake/swkbd/CMakeLists.txt index 44ad754..e64457c 100644 --- a/samples/swkbd/CMakeLists.txt +++ b/samples/cmake/swkbd/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(swkbd CXX) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(swkbd main.cpp) diff --git a/samples/swkbd/main.cpp b/samples/cmake/swkbd/main.cpp similarity index 100% rename from samples/swkbd/main.cpp rename to samples/cmake/swkbd/main.cpp From 37afdf9095a3fa5a171f04b60e1d3ae3dde76640 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 19:01:33 +1000 Subject: [PATCH 07/18] samples: port helloworld to make --- .gitignore | 1 + samples/make/Makefile | 9 ++ samples/make/helloworld/Makefile | 138 ++++++++++++++++++++++++++ samples/make/helloworld/source/main.c | 39 ++++++++ 4 files changed, 187 insertions(+) create mode 100644 samples/make/Makefile create mode 100644 samples/make/helloworld/Makefile create mode 100644 samples/make/helloworld/source/main.c diff --git a/.gitignore b/.gitignore index a6f793c..49e2a46 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ lib/ *.o *.d *.elf +*.rpx *.bz2 docs/html/ .vs/ diff --git a/samples/make/Makefile b/samples/make/Makefile new file mode 100644 index 0000000..6b9495e --- /dev/null +++ b/samples/make/Makefile @@ -0,0 +1,9 @@ +MAKEFILES := $(shell find . -mindepth 2 -name Makefile) + +DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d) + +all: + @for i in $(MAKEFILES); do $(MAKE) -C `dirname $$i` || exit 1; done; + +clean: + @for i in $(MAKEFILES); do $(MAKE) -C `dirname $$i` clean || exit 1; done; diff --git a/samples/make/helloworld/Makefile b/samples/make/helloworld/Makefile new file mode 100644 index 0000000..17aab4c --- /dev/null +++ b/samples/make/helloworld/Makefile @@ -0,0 +1,138 @@ +#------------------------------------------------------------------------------- +.SUFFIXES: +#------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +endif + +TOPDIR ?= $(CURDIR) + +ifeq ($(strip $(WUT_ROOT)),) +include $(DEVKITPRO)/wut/share/wut_rules +else +include $(WUT_ROOT)/share/wut_rules +endif + +#------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source +DATA := data +INCLUDES := include + +#------------------------------------------------------------------------------- +# options for code generation +#------------------------------------------------------------------------------- +CFLAGS := -g -Wall -O2 -ffunction-sections \ + $(MACHDEP) + +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ + +CXXFLAGS := $(CFLAGS) + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) + +LIBS := -lwut + +#------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level +# containing include and lib +#------------------------------------------------------------------------------- +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) + + +#------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#------------------------------------------------------------------------------- + export LD := $(CC) +#------------------------------------------------------------------------------- +else +#------------------------------------------------------------------------------- + export LD := $(CXX) +#------------------------------------------------------------------------------- +endif +#------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean all + +#------------------------------------------------------------------------------- +all: $(BUILD) + +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).rpx + +#------------------------------------------------------------------------------- +else +.PHONY: all + +DEPENDS := $(OFILES:.o=.d) + +#------------------------------------------------------------------------------- +# main targets +#------------------------------------------------------------------------------- +all : $(OUTPUT).rpx + +$(OUTPUT).rpx : $(OFILES) + +$(OFILES_SRC) : $(HFILES_BIN) + +#------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +-include $(DEPENDS) + +#------------------------------------------------------------------------------- +endif +#------------------------------------------------------------------------------- diff --git a/samples/make/helloworld/source/main.c b/samples/make/helloworld/source/main.c new file mode 100644 index 0000000..489fc47 --- /dev/null +++ b/samples/make/helloworld/source/main.c @@ -0,0 +1,39 @@ +#include +#include + +#include +#include +#include + +int +main(int argc, char **argv) +{ + int last_tm_sec = -1; + OSCalendarTime tm; + + WHBProcInit(); + WHBLogConsoleInit(); + WHBLogPrintf("Hello World!"); + + while(WHBProcIsRunning()) { + OSTicksToCalendarTime(OSGetTime(), &tm); + + if (tm.tm_sec != last_tm_sec) { + WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.", + tm.tm_mday, tm.tm_mon, tm.tm_year, + tm.tm_hour, tm.tm_min, tm.tm_sec); + last_tm_sec = tm.tm_sec; + } + + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(100)); + } + + WHBLogPrintf("Exiting... good bye."); + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(1000)); + + WHBLogConsoleFree(); + WHBProcShutdown(); + return 0; +} From aa122e0366bfecc47e2f30977146140b9a99ecf5 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 19:17:52 +1000 Subject: [PATCH 08/18] travis: Fixups for new build system --- .travis.yml | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3253c23..6456db8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,13 @@ matrix: - os: linux dist: xenial sudo: required - env: DEPLOY_FILE=wut.7z + env: DEPLOY_FILE=wut-*.tar.bz2 addons: apt: sources: - ubuntu-toolchain-r-test - sourceline: 'ppa:cginternals/backports-ppa' - packages: - - p7zip-full cache: directories: @@ -33,26 +31,20 @@ install: script: - cd "$TRAVIS_BUILD_DIR" # Build wut - - mkdir build && cd build - - cmake -DCMAKE_INSTALL_PREFIX=wut_install ../ - - make -j4 install + - make -j4 install DESTDIR=wut_install - export WUT_ROOT=$PWD/wut_install - cd ../ # Build tests - - cd tests - - mkdir build && cd build - - cmake ../ - - make -j4 VERBOSE=TRUE - - cd ../../ + - echo Tests disabled for now +# - cd tests +# - mkdir build && cd build +# - cmake ../ +# - make -j4 VERBOSE=TRUE +# - cd ../../ # Build samples - - cd samples - - mkdir build && cd build - - cmake -DCMAKE_INSTALL_PREFIX=$WUT_ROOT/samples ../ - - make -j4 VERBOSE=TRUE install + - cd samples/make + - make -j4 - cd ../../ - # Create deploy zips - - cd $WUT_ROOT - - 7z a $DEPLOY_FILE . deploy: provider: releases From 592110eeb3449ab15f57c4ad595981b32eaefa1b Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 19:21:17 +1000 Subject: [PATCH 09/18] travis: remove spurious cd --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6456db8..e2d321a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,6 @@ script: # Build wut - make -j4 install DESTDIR=wut_install - export WUT_ROOT=$PWD/wut_install - - cd ../ # Build tests - echo Tests disabled for now # - cd tests From b7a12a04a791499ed6500d8d92e1be68f45dfe77 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 19:25:27 +1000 Subject: [PATCH 10/18] travis: Update WUT_ROOT temporary location --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e2d321a..6e766c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ script: - cd "$TRAVIS_BUILD_DIR" # Build wut - make -j4 install DESTDIR=wut_install - - export WUT_ROOT=$PWD/wut_install + - export WUT_ROOT=$PWD/wut_install/opt/devkitpro/wut # Build tests - echo Tests disabled for now # - cd tests From 81285c71f66088997c9558c0e148dde4b3b501f7 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 19:28:27 +1000 Subject: [PATCH 11/18] samples: port helloworld_cpp to make --- samples/make/helloworld_cpp/Makefile | 138 ++++++++++++++++++++ samples/make/helloworld_cpp/source/main.cpp | 70 ++++++++++ 2 files changed, 208 insertions(+) create mode 100644 samples/make/helloworld_cpp/Makefile create mode 100644 samples/make/helloworld_cpp/source/main.cpp diff --git a/samples/make/helloworld_cpp/Makefile b/samples/make/helloworld_cpp/Makefile new file mode 100644 index 0000000..17aab4c --- /dev/null +++ b/samples/make/helloworld_cpp/Makefile @@ -0,0 +1,138 @@ +#------------------------------------------------------------------------------- +.SUFFIXES: +#------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +endif + +TOPDIR ?= $(CURDIR) + +ifeq ($(strip $(WUT_ROOT)),) +include $(DEVKITPRO)/wut/share/wut_rules +else +include $(WUT_ROOT)/share/wut_rules +endif + +#------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source +DATA := data +INCLUDES := include + +#------------------------------------------------------------------------------- +# options for code generation +#------------------------------------------------------------------------------- +CFLAGS := -g -Wall -O2 -ffunction-sections \ + $(MACHDEP) + +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ + +CXXFLAGS := $(CFLAGS) + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) + +LIBS := -lwut + +#------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level +# containing include and lib +#------------------------------------------------------------------------------- +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) + + +#------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#------------------------------------------------------------------------------- + +export OUTPUT := $(CURDIR)/$(TARGET) +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#------------------------------------------------------------------------------- + export LD := $(CC) +#------------------------------------------------------------------------------- +else +#------------------------------------------------------------------------------- + export LD := $(CXX) +#------------------------------------------------------------------------------- +endif +#------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean all + +#------------------------------------------------------------------------------- +all: $(BUILD) + +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).rpx + +#------------------------------------------------------------------------------- +else +.PHONY: all + +DEPENDS := $(OFILES:.o=.d) + +#------------------------------------------------------------------------------- +# main targets +#------------------------------------------------------------------------------- +all : $(OUTPUT).rpx + +$(OUTPUT).rpx : $(OFILES) + +$(OFILES_SRC) : $(HFILES_BIN) + +#------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +-include $(DEPENDS) + +#------------------------------------------------------------------------------- +endif +#------------------------------------------------------------------------------- diff --git a/samples/make/helloworld_cpp/source/main.cpp b/samples/make/helloworld_cpp/source/main.cpp new file mode 100644 index 0000000..9938773 --- /dev/null +++ b/samples/make/helloworld_cpp/source/main.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include + +int +hello_thread() +{ + int last_tm_sec = -1; + uint32_t ip = 0; + WHBLogPrintf("Hello World from a std::thread!"); + + if (!nn::ac::GetAssignedAddress(&ip)) { + WHBLogPrintf("GetAssignedAddress failed!"); + } + + WHBLogPrintf("My IP is: %u.%u.%u.%u", + (ip >> 24) & 0xFF, + (ip >> 16) & 0xFF, + (ip >> 8) & 0xFF, + (ip >> 0) & 0xFF); + + while(WHBProcIsRunning()) { + OSCalendarTime tm; + OSTicksToCalendarTime(OSGetTime(), &tm); + + if (tm.tm_sec != last_tm_sec) { + WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.", + tm.tm_mday, tm.tm_mon, tm.tm_year, + tm.tm_hour, tm.tm_min, tm.tm_sec); + last_tm_sec = tm.tm_sec; + } + + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(100)); + } + + WHBLogPrintf("Exiting... good bye."); + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(1000)); + return 0; +} + +int +main(int argc, char **argv) +{ + nn::ac::ConfigIdNum configId; + + nn::ac::Initialize(); + nn::ac::GetStartupId(&configId); + nn::ac::Connect(configId); + + WHBProcInit(); + WHBLogConsoleInit(); + + std::thread t(hello_thread); + t.join(); + + WHBLogConsoleFree(); + WHBProcShutdown(); + + nn::ac::Finalize(); + return 0; +} From 869fe709ea0f2ddee28cc9f8a9e3e1dd9bfb37b2 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 20:26:35 +1000 Subject: [PATCH 12/18] Revert "wutstdc++: Move __gxx_personality to dedicated Assembly file" This reverts commit 370eeb28e94ccfcff981842bc55a16258fec252c. I didn't know what this did, sorry. --- libraries/wutstdc++/wut_stdcpp.cpp | 11 +++++++++++ libraries/wutstdc++/wut_stdcpp_personality.s | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 libraries/wutstdc++/wut_stdcpp_personality.s diff --git a/libraries/wutstdc++/wut_stdcpp.cpp b/libraries/wutstdc++/wut_stdcpp.cpp index f15f6df..530e950 100644 --- a/libraries/wutstdc++/wut_stdcpp.cpp +++ b/libraries/wutstdc++/wut_stdcpp.cpp @@ -1,5 +1,16 @@ #include "wut_gthread.h" +__asm__ __volatile__( + "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n" + "\t.align\t2\n" + "\t.globl\t__wrap___gxx_personality_v0\n" + "\t.type\t__wrap___gxx_personality_v0, @function\n" + "__wrap___gxx_personality_v0:\n" + "\t.cfi_startproc\n" + "\tb\t__real___gxx_personality_v0\n" + "\t.cfi_endproc" +); + extern "C" void __init_wut_stdcpp() { diff --git a/libraries/wutstdc++/wut_stdcpp_personality.s b/libraries/wutstdc++/wut_stdcpp_personality.s deleted file mode 100644 index 13b9e7f..0000000 --- a/libraries/wutstdc++/wut_stdcpp_personality.s +++ /dev/null @@ -1,10 +0,0 @@ -.section .text.__wrap___gxx_personality_v0,"ax",@progbits -.align 2 - -.globl __wrap___gxx_personality_v0 -.type __wrap___gxx_personality_v0, @function - -__wrap___gxx_personality_v0: - .cfi_startproc - b __real___gxx_personality_v0 - .cfi_endproc From fb9b7ab3fb82ed28d04589efed9f665ac0312747 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 20:41:45 +1000 Subject: [PATCH 13/18] wutstdc++: remove volatile keyword Who knows? not me. Seems to work okay without it wut_stdcpp.cpp /home/ash/src/wut/libraries/wutstdc++/wut_stdcpp.cpp:3:9: error: expected '(' before '__volatile__' __asm__ __volatile__( ^~~~~~~~~~~~ ( /home/ash/src/wut/libraries/wutstdc++/wut_stdcpp.cpp:4:4: error: expected unqualified-id before string constant "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/ash/src/wut/libraries/wutstdc++/wut_stdcpp.cpp:3:22: error: expected ')' before string constant __asm__ __volatile__( ~^ ) "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[1]: *** [/opt/devkitpro/devkitPPC/base_rules:13: wut_stdcpp.o] Error 1 --- libraries/wutstdc++/wut_stdcpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wutstdc++/wut_stdcpp.cpp b/libraries/wutstdc++/wut_stdcpp.cpp index 530e950..c6dc737 100644 --- a/libraries/wutstdc++/wut_stdcpp.cpp +++ b/libraries/wutstdc++/wut_stdcpp.cpp @@ -1,6 +1,6 @@ #include "wut_gthread.h" -__asm__ __volatile__( +__asm__ ( "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n" "\t.align\t2\n" "\t.globl\t__wrap___gxx_personality_v0\n" From 09c16421d8f8f412bab23d014c630ada8017f83f Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 20:44:54 +1000 Subject: [PATCH 14/18] samples: Add explicit rules for .elf intermediates --- samples/make/helloworld/Makefile | 5 +++-- samples/make/helloworld_cpp/Makefile | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/samples/make/helloworld/Makefile b/samples/make/helloworld/Makefile index 17aab4c..05868da 100644 --- a/samples/make/helloworld/Makefile +++ b/samples/make/helloworld/Makefile @@ -106,7 +106,7 @@ $(BUILD): #------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr $(BUILD) $(TARGET).rpx + @rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf #------------------------------------------------------------------------------- else @@ -119,7 +119,8 @@ DEPENDS := $(OFILES:.o=.d) #------------------------------------------------------------------------------- all : $(OUTPUT).rpx -$(OUTPUT).rpx : $(OFILES) +$(OUTPUT).rpx : $(OUTPUT).elf +$(OUTPUT).elf : $(OFILES) $(OFILES_SRC) : $(HFILES_BIN) diff --git a/samples/make/helloworld_cpp/Makefile b/samples/make/helloworld_cpp/Makefile index 17aab4c..05868da 100644 --- a/samples/make/helloworld_cpp/Makefile +++ b/samples/make/helloworld_cpp/Makefile @@ -106,7 +106,7 @@ $(BUILD): #------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr $(BUILD) $(TARGET).rpx + @rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf #------------------------------------------------------------------------------- else @@ -119,7 +119,8 @@ DEPENDS := $(OFILES:.o=.d) #------------------------------------------------------------------------------- all : $(OUTPUT).rpx -$(OUTPUT).rpx : $(OFILES) +$(OUTPUT).rpx : $(OUTPUT).elf +$(OUTPUT).elf : $(OFILES) $(OFILES_SRC) : $(HFILES_BIN) From 4278819a01aceaf0554e63f1936d4e8dfc13ce43 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Tue, 9 Apr 2019 20:59:32 +1000 Subject: [PATCH 15/18] samples: make WUT_ROOT makefile-local, always rely on DEVKITPRO --- .travis.yml | 4 ++-- samples/make/helloworld/Makefile | 4 ---- samples/make/helloworld_cpp/Makefile | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e766c8..61187e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,8 +31,8 @@ install: script: - cd "$TRAVIS_BUILD_DIR" # Build wut - - make -j4 install DESTDIR=wut_install - - export WUT_ROOT=$PWD/wut_install/opt/devkitpro/wut + - make -j4 + - sudo make install # Build tests - echo Tests disabled for now # - cd tests diff --git a/samples/make/helloworld/Makefile b/samples/make/helloworld/Makefile index 05868da..b9e3777 100644 --- a/samples/make/helloworld/Makefile +++ b/samples/make/helloworld/Makefile @@ -8,11 +8,7 @@ endif TOPDIR ?= $(CURDIR) -ifeq ($(strip $(WUT_ROOT)),) include $(DEVKITPRO)/wut/share/wut_rules -else -include $(WUT_ROOT)/share/wut_rules -endif #------------------------------------------------------------------------------- # TARGET is the name of the output diff --git a/samples/make/helloworld_cpp/Makefile b/samples/make/helloworld_cpp/Makefile index 05868da..b9e3777 100644 --- a/samples/make/helloworld_cpp/Makefile +++ b/samples/make/helloworld_cpp/Makefile @@ -8,11 +8,7 @@ endif TOPDIR ?= $(CURDIR) -ifeq ($(strip $(WUT_ROOT)),) include $(DEVKITPRO)/wut/share/wut_rules -else -include $(WUT_ROOT)/share/wut_rules -endif #------------------------------------------------------------------------------- # TARGET is the name of the output From f92657e8b59517866efb25b3295bc9a31e8cc348 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Mon, 22 Apr 2019 12:43:37 +1000 Subject: [PATCH 16/18] coreinit: Use rplwrap for exit (__rplwrap_exit) --- cafe/coreinit.def | 4 +++- include/coreinit/exit.h | 2 +- include/wut.h | 1 + include/wut_rplwrap.h | 3 +++ libraries/wutnewlib/wut_newlib.c | 6 ++---- 5 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 include/wut_rplwrap.h diff --git a/cafe/coreinit.def b/cafe/coreinit.def index bb3be89..32939ef 100644 --- a/cafe/coreinit.def +++ b/cafe/coreinit.def @@ -1210,7 +1210,6 @@ bspQuery bspRead bspShutdown bspWrite -exit //memclr //memcpy //memmove @@ -1229,6 +1228,9 @@ smdSimpleBufFree smdSimpleBufGetStatistics smdSimpleBufPoolCreate +:TEXT_WRAP +exit + :DATA MEMAllocFromDefaultHeap MEMAllocFromDefaultHeapEx diff --git a/include/coreinit/exit.h b/include/coreinit/exit.h index 51bcb98..5dc0087 100644 --- a/include/coreinit/exit.h +++ b/include/coreinit/exit.h @@ -12,7 +12,7 @@ extern "C" { #endif void -exit(int code); +RPLWRAP(exit)(int code); void _Exit(int code); diff --git a/include/wut.h b/include/wut.h index a704f41..cdbd464 100644 --- a/include/wut.h +++ b/include/wut.h @@ -8,3 +8,4 @@ #include "wut_structsize.h" #include "wut_types.h" +#include "wut_rplwrap.h" diff --git a/include/wut_rplwrap.h b/include/wut_rplwrap.h new file mode 100644 index 0000000..433903a --- /dev/null +++ b/include/wut_rplwrap.h @@ -0,0 +1,3 @@ +#pragma once + +#define RPLWRAP(func) __rplwrap_##func diff --git a/libraries/wutnewlib/wut_newlib.c b/libraries/wutnewlib/wut_newlib.c index 4eda7d0..3623229 100644 --- a/libraries/wutnewlib/wut_newlib.c +++ b/libraries/wutnewlib/wut_newlib.c @@ -1,9 +1,6 @@ #include "wut_newlib.h" #include -// Forward newlib _exit to the coreinit.rpl _Exit -extern void _Exit(int status); - static void __init_wut_syscall_array() { @@ -14,7 +11,8 @@ __init_wut_syscall_array() __syscalls.lock_release = __wut_lock_release; //__syscalls.malloc_lock = __wut_malloc_lock; //__syscalls.malloc_unlock = __wut_malloc_unlock; - __syscalls.exit = _Exit; + //use coreinit's exit function + __syscalls.exit = RPLWRAP(exit); __syscalls.gettod_r = __wut_gettod_r; __syscalls.clock_gettime = __wut_clock_gettime; __syscalls.clock_settime = __wut_clock_settime; From 55007e5ec762ec910a872196f09f089aa006e930 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Mon, 22 Apr 2019 12:43:51 +1000 Subject: [PATCH 17/18] changelog: start writing down what's changed --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4e6c806 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +#### wut 1.0.0-beta9 +###### Breaking changes + - coreinit's `exit` is no longer defined in ``. Please use `` instead, which pulls in newlib's exit. + +###### Deprecations + - `WUT_ROOT` should no longer be defined in the user's environment, and will be set to `$DEVKITPRO/wut` internally. CMake lists and makefiles that use `$WUT_ROOT/share` to find `wut.mk` or `wut.toolchain.cmake` should be changed to `$DEVKITPRO/wut/share`. + +###### Other changes + - Builds refactored: wut now uses Makefiles to build itself, as well as providing a devkitPro-style `wut_rules` file - see the `samples/make` folder. The cmake samples are now in `samples/cmake`. + - A new linking feature, `__rplwrap`, was added to help deal with conflicts between newlib's and Cafe's functions. Because of this, wut 1.0.0-beta9 requires wut-tools 1.1.0 or newer. + - Using rplwrap, newlib's `exit` is now correctly chained with coreinit's - calls like `atexit` should work; whether calling `exit` or just returning from `main`. Applications using coreinit's `_Exit` are encouraged to migrate to a normal `exit` call. + + +#### wut 1.0.0-beta8 From 46d6edd81be0898d76359f0eba105ba6157f7d21 Mon Sep 17 00:00:00 2001 From: Ash Logan Date: Mon, 22 Apr 2019 14:42:46 +1000 Subject: [PATCH 18/18] wut.ld: Concat and garbage-collect rpx import sections --- CHANGELOG.md | 1 + share/wut.ld | 365 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 293 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6c806..65e36e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ #### wut 1.0.0-beta9 ###### Breaking changes - coreinit's `exit` is no longer defined in ``. Please use `` instead, which pulls in newlib's exit. + - RPL import sections (`.fimport_coreinit` etc.) are now garbage-collected when using wut-tools 1.1.0 or above (required). Code relying on weak links to Cafe functions may exhibit different behaviour. ###### Deprecations - `WUT_ROOT` should no longer be defined in the user's environment, and will be set to `$DEVKITPRO/wut` internally. CMake lists and makefiles that use `$WUT_ROOT/share` to find `wut.mk` or `wut.toolchain.cmake` should be changed to `$DEVKITPRO/wut/share`. diff --git a/share/wut.ld b/share/wut.ld index 775e7c6..391335b 100644 --- a/share/wut.ld +++ b/share/wut.ld @@ -146,80 +146,299 @@ SECTIONS .fexports ALIGN(32) : { KEEP( *(.fexports) ) } > loadmem .dexports ALIGN(32) : { KEEP( *(.dexports) ) } > loadmem - .fimport_avm ALIGN(16) : { *(.fimport_avm) } > loadmem - .fimport_camera ALIGN(16) : { *(.fimport_camera) } > loadmem - .fimport_coreinit ALIGN(16) : { *(.fimport_coreinit) } > loadmem - .fimport_dc ALIGN(16) : { *(.fimport_dc) } > loadmem - .fimport_dmae ALIGN(16) : { *(.fimport_dmae) } > loadmem - .fimport_drmapp ALIGN(16) : { *(.fimport_drmapp) } > loadmem - .fimport_erreula ALIGN(16) : { *(.fimport_erreula) } > loadmem - .fimport_gx2 ALIGN(16) : { *(.fimport_gx2) } > loadmem - .fimport_h264 ALIGN(16) : { *(.fimport_h264) } > loadmem - .fimport_lzma920 ALIGN(16) : { *(.fimport_lzma920) } > loadmem - .fimport_mic ALIGN(16) : { *(.fimport_mic) } > loadmem - .fimport_nfc ALIGN(16) : { *(.fimport_nfc) } > loadmem - .fimport_nio_prof ALIGN(16) : { *(.fimport_nio_prof) } > loadmem - .fimport_nlibcurl ALIGN(16) : { *(.fimport_nlibcurl) } > loadmem - .fimport_nlibnss2 ALIGN(16) : { *(.fimport_nlibnss2) } > loadmem - .fimport_nlibnss ALIGN(16) : { *(.fimport_nlibnss) } > loadmem - .fimport_nn_ac ALIGN(16) : { *(.fimport_nn_ac) } > loadmem - .fimport_nn_acp ALIGN(16) : { *(.fimport_nn_acp) } > loadmem - .fimport_nn_act ALIGN(16) : { *(.fimport_nn_act) } > loadmem - .fimport_nn_aoc ALIGN(16) : { *(.fimport_nn_aoc) } > loadmem - .fimport_nn_boss ALIGN(16) : { *(.fimport_nn_boss) } > loadmem - .fimport_nn_ccr ALIGN(16) : { *(.fimport_nn_ccr) } > loadmem - .fimport_nn_cmpt ALIGN(16) : { *(.fimport_nn_cmpt) } > loadmem - .fimport_nn_dlp ALIGN(16) : { *(.fimport_nn_dlp) } > loadmem - .fimport_nn_ec ALIGN(16) : { *(.fimport_nn_ec) } > loadmem - .fimport_nn_fp ALIGN(16) : { *(.fimport_nn_fp) } > loadmem - .fimport_nn_hai ALIGN(16) : { *(.fimport_nn_hai) } > loadmem - .fimport_nn_hpad ALIGN(16) : { *(.fimport_nn_hpad) } > loadmem - .fimport_nn_idbe ALIGN(16) : { *(.fimport_nn_idbe) } > loadmem - .fimport_nn_ndm ALIGN(16) : { *(.fimport_nn_ndm) } > loadmem - .fimport_nn_nets2 ALIGN(16) : { *(.fimport_nn_nets2) } > loadmem - .fimport_nn_nfp ALIGN(16) : { *(.fimport_nn_nfp) } > loadmem - .fimport_nn_nim ALIGN(16) : { *(.fimport_nn_nim) } > loadmem - .fimport_nn_olv ALIGN(16) : { *(.fimport_nn_olv) } > loadmem - .fimport_nn_pdm ALIGN(16) : { *(.fimport_nn_pdm) } > loadmem - .fimport_nn_save ALIGN(16) : { *(.fimport_nn_save) } > loadmem - .fimport_nn_sl ALIGN(16) : { *(.fimport_nn_sl) } > loadmem - .fimport_nn_spm ALIGN(16) : { *(.fimport_nn_spm) } > loadmem - .fimport_nn_temp ALIGN(16) : { *(.fimport_nn_temp) } > loadmem - .fimport_nn_uds ALIGN(16) : { *(.fimport_nn_uds) } > loadmem - .fimport_nn_vctl ALIGN(16) : { *(.fimport_nn_vctl) } > loadmem - .fimport_nsysccr ALIGN(16) : { *(.fimport_nsysccr) } > loadmem - .fimport_nsyshid ALIGN(16) : { *(.fimport_nsyshid) } > loadmem - .fimport_nsyskbd ALIGN(16) : { *(.fimport_nsyskbd) } > loadmem - .fimport_nsysnet ALIGN(16) : { *(.fimport_nsysnet) } > loadmem - .fimport_nsysuhs ALIGN(16) : { *(.fimport_nsysuhs) } > loadmem - .fimport_nsysuvd ALIGN(16) : { *(.fimport_nsysuvd) } > loadmem - .fimport_ntag ALIGN(16) : { *(.fimport_ntag) } > loadmem - .fimport_padscore ALIGN(16) : { *(.fimport_padscore) } > loadmem - .fimport_proc_ui ALIGN(16) : { *(.fimport_proc_ui) } > loadmem - .fimport_sndcore2 ALIGN(16) : { *(.fimport_sndcore2) } > loadmem - .fimport_snd_core ALIGN(16) : { *(.fimport_snd_core) } > loadmem - .fimport_snduser2 ALIGN(16) : { *(.fimport_snduser2) } > loadmem - .fimport_snd_user ALIGN(16) : { *(.fimport_snd_user) } > loadmem - .fimport_swkbd ALIGN(16) : { *(.fimport_swkbd) } > loadmem - .fimport_sysapp ALIGN(16) : { *(.fimport_sysapp) } > loadmem - .fimport_tcl ALIGN(16) : { *(.fimport_tcl) } > loadmem - .fimport_tve ALIGN(16) : { *(.fimport_tve) } > loadmem - .fimport_uac ALIGN(16) : { *(.fimport_uac) } > loadmem - .fimport_uac_rpl ALIGN(16) : { *(.fimport_uac_rpl) } > loadmem - .fimport_usb_mic ALIGN(16) : { *(.fimport_usb_mic) } > loadmem - .fimport_uvc ALIGN(16) : { *(.fimport_uvc) } > loadmem - .fimport_uvd ALIGN(16) : { *(.fimport_uvd) } > loadmem - .fimport_vpadbase ALIGN(16) : { *(.fimport_vpadbase) } > loadmem - .fimport_vpad ALIGN(16) : { *(.fimport_vpad) } > loadmem - .fimport_zlib125 ALIGN(16) : { *(.fimport_zlib125) } > loadmem + .fimport_avm ALIGN(16) : { + KEEP ( *(.fimport_avm) ) + *(.fimport_avm.*) + } > loadmem + .fimport_camera ALIGN(16) : { + KEEP ( *(.fimport_camera) ) + *(.fimport_camera.*) + } > loadmem + .fimport_coreinit ALIGN(16) : { + KEEP ( *(.fimport_coreinit) ) + *(.fimport_coreinit.*) + } > loadmem + .fimport_dc ALIGN(16) : { + KEEP ( *(.fimport_dc) ) + *(.fimport_dc.*) + } > loadmem + .fimport_dmae ALIGN(16) : { + KEEP ( *(.fimport_dmae) ) + *(.fimport_dmae.*) + } > loadmem + .fimport_drmapp ALIGN(16) : { + KEEP ( *(.fimport_drmapp) ) + *(.fimport_drmapp.*) + } > loadmem + .fimport_erreula ALIGN(16) : { + KEEP ( *(.fimport_erreula) ) + *(.fimport_erreula.*) + } > loadmem + .fimport_gx2 ALIGN(16) : { + KEEP ( *(.fimport_gx2) ) + *(.fimport_gx2.*) + } > loadmem + .fimport_h264 ALIGN(16) : { + KEEP ( *(.fimport_h264) ) + *(.fimport_h264.*) + } > loadmem + .fimport_lzma920 ALIGN(16) : { + KEEP ( *(.fimport_lzma920) ) + *(.fimport_lzma920.*) + } > loadmem + .fimport_mic ALIGN(16) : { + KEEP ( *(.fimport_mic) ) + *(.fimport_mic.*) + } > loadmem + .fimport_nfc ALIGN(16) : { + KEEP ( *(.fimport_nfc) ) + *(.fimport_nfc.*) + } > loadmem + .fimport_nio_prof ALIGN(16) : { + KEEP ( *(.fimport_nio_prof) ) + *(.fimport_nio_prof.*) + } > loadmem + .fimport_nlibcurl ALIGN(16) : { + KEEP ( *(.fimport_nlibcurl) ) + *(.fimport_nlibcurl.*) + } > loadmem + .fimport_nlibnss2 ALIGN(16) : { + KEEP ( *(.fimport_nlibnss2) ) + *(.fimport_nlibnss2.*) + } > loadmem + .fimport_nlibnss ALIGN(16) : { + KEEP ( *(.fimport_nlibnss) ) + *(.fimport_nlibnss.*) + } > loadmem + .fimport_nn_ac ALIGN(16) : { + KEEP ( *(.fimport_nn_ac) ) + *(.fimport_nn_ac.*) + } > loadmem + .fimport_nn_acp ALIGN(16) : { + KEEP ( *(.fimport_nn_acp) ) + *(.fimport_nn_acp.*) + } > loadmem + .fimport_nn_act ALIGN(16) : { + KEEP ( *(.fimport_nn_act) ) + *(.fimport_nn_act.*) + } > loadmem + .fimport_nn_aoc ALIGN(16) : { + KEEP ( *(.fimport_nn_aoc) ) + *(.fimport_nn_aoc.*) + } > loadmem + .fimport_nn_boss ALIGN(16) : { + KEEP ( *(.fimport_nn_boss) ) + *(.fimport_nn_boss.*) + } > loadmem + .fimport_nn_ccr ALIGN(16) : { + KEEP ( *(.fimport_nn_ccr) ) + *(.fimport_nn_ccr.*) + } > loadmem + .fimport_nn_cmpt ALIGN(16) : { + KEEP ( *(.fimport_nn_cmpt) ) + *(.fimport_nn_cmpt.*) + } > loadmem + .fimport_nn_dlp ALIGN(16) : { + KEEP ( *(.fimport_nn_dlp) ) + *(.fimport_nn_dlp.*) + } > loadmem + .fimport_nn_ec ALIGN(16) : { + KEEP ( *(.fimport_nn_ec) ) + *(.fimport_nn_ec.*) + } > loadmem + .fimport_nn_fp ALIGN(16) : { + KEEP ( *(.fimport_nn_fp) ) + *(.fimport_nn_fp.*) + } > loadmem + .fimport_nn_hai ALIGN(16) : { + KEEP ( *(.fimport_nn_hai) ) + *(.fimport_nn_hai.*) + } > loadmem + .fimport_nn_hpad ALIGN(16) : { + KEEP ( *(.fimport_nn_hpad) ) + *(.fimport_nn_hpad.*) + } > loadmem + .fimport_nn_idbe ALIGN(16) : { + KEEP ( *(.fimport_nn_idbe) ) + *(.fimport_nn_idbe.*) + } > loadmem + .fimport_nn_ndm ALIGN(16) : { + KEEP ( *(.fimport_nn_ndm) ) + *(.fimport_nn_ndm.*) + } > loadmem + .fimport_nn_nets2 ALIGN(16) : { + KEEP ( *(.fimport_nn_nets2) ) + *(.fimport_nn_nets2.*) + } > loadmem + .fimport_nn_nfp ALIGN(16) : { + KEEP ( *(.fimport_nn_nfp) ) + *(.fimport_nn_nfp.*) + } > loadmem + .fimport_nn_nim ALIGN(16) : { + KEEP ( *(.fimport_nn_nim) ) + *(.fimport_nn_nim.*) + } > loadmem + .fimport_nn_olv ALIGN(16) : { + KEEP ( *(.fimport_nn_olv) ) + *(.fimport_nn_olv.*) + } > loadmem + .fimport_nn_pdm ALIGN(16) : { + KEEP ( *(.fimport_nn_pdm) ) + *(.fimport_nn_pdm.*) + } > loadmem + .fimport_nn_save ALIGN(16) : { + KEEP ( *(.fimport_nn_save) ) + *(.fimport_nn_save.*) + } > loadmem + .fimport_nn_sl ALIGN(16) : { + KEEP ( *(.fimport_nn_sl) ) + *(.fimport_nn_sl.*) + } > loadmem + .fimport_nn_spm ALIGN(16) : { + KEEP ( *(.fimport_nn_spm) ) + *(.fimport_nn_spm.*) + } > loadmem + .fimport_nn_temp ALIGN(16) : { + KEEP ( *(.fimport_nn_temp) ) + *(.fimport_nn_temp.*) + } > loadmem + .fimport_nn_uds ALIGN(16) : { + KEEP ( *(.fimport_nn_uds) ) + *(.fimport_nn_uds.*) + } > loadmem + .fimport_nn_vctl ALIGN(16) : { + KEEP ( *(.fimport_nn_vctl) ) + *(.fimport_nn_vctl.*) + } > loadmem + .fimport_nsysccr ALIGN(16) : { + KEEP ( *(.fimport_nsysccr) ) + *(.fimport_nsysccr.*) + } > loadmem + .fimport_nsyshid ALIGN(16) : { + KEEP ( *(.fimport_nsyshid) ) + *(.fimport_nsyshid.*) + } > loadmem + .fimport_nsyskbd ALIGN(16) : { + KEEP ( *(.fimport_nsyskbd) ) + *(.fimport_nsyskbd.*) + } > loadmem + .fimport_nsysnet ALIGN(16) : { + KEEP ( *(.fimport_nsysnet) ) + *(.fimport_nsysnet.*) + } > loadmem + .fimport_nsysuhs ALIGN(16) : { + KEEP ( *(.fimport_nsysuhs) ) + *(.fimport_nsysuhs.*) + } > loadmem + .fimport_nsysuvd ALIGN(16) : { + KEEP ( *(.fimport_nsysuvd) ) + *(.fimport_nsysuvd.*) + } > loadmem + .fimport_ntag ALIGN(16) : { + KEEP ( *(.fimport_ntag) ) + *(.fimport_ntag.*) + } > loadmem + .fimport_padscore ALIGN(16) : { + KEEP ( *(.fimport_padscore) ) + *(.fimport_padscore.*) + } > loadmem + .fimport_proc_ui ALIGN(16) : { + KEEP ( *(.fimport_proc_ui) ) + *(.fimport_proc_ui.*) + } > loadmem + .fimport_sndcore2 ALIGN(16) : { + KEEP ( *(.fimport_sndcore2) ) + *(.fimport_sndcore2.*) + } > loadmem + .fimport_snd_core ALIGN(16) : { + KEEP ( *(.fimport_snd_core) ) + *(.fimport_snd_core.*) + } > loadmem + .fimport_snduser2 ALIGN(16) : { + KEEP ( *(.fimport_snduser2) ) + *(.fimport_snduser2.*) + } > loadmem + .fimport_snd_user ALIGN(16) : { + KEEP ( *(.fimport_snd_user) ) + *(.fimport_snd_user.*) + } > loadmem + .fimport_swkbd ALIGN(16) : { + KEEP ( *(.fimport_swkbd) ) + *(.fimport_swkbd.*) + } > loadmem + .fimport_sysapp ALIGN(16) : { + KEEP ( *(.fimport_sysapp) ) + *(.fimport_sysapp.*) + } > loadmem + .fimport_tcl ALIGN(16) : { + KEEP ( *(.fimport_tcl) ) + *(.fimport_tcl.*) + } > loadmem + .fimport_tve ALIGN(16) : { + KEEP ( *(.fimport_tve) ) + *(.fimport_tve.*) + } > loadmem + .fimport_uac ALIGN(16) : { + KEEP ( *(.fimport_uac) ) + *(.fimport_uac.*) + } > loadmem + .fimport_uac_rpl ALIGN(16) : { + KEEP ( *(.fimport_uac_rpl) ) + *(.fimport_uac_rpl.*) + } > loadmem + .fimport_usb_mic ALIGN(16) : { + KEEP ( *(.fimport_usb_mic) ) + *(.fimport_usb_mic.*) + } > loadmem + .fimport_uvc ALIGN(16) : { + KEEP ( *(.fimport_uvc) ) + *(.fimport_uvc.*) + } > loadmem + .fimport_uvd ALIGN(16) : { + KEEP ( *(.fimport_uvd) ) + *(.fimport_uvd.*) + } > loadmem + .fimport_vpadbase ALIGN(16) : { + KEEP ( *(.fimport_vpadbase) ) + *(.fimport_vpadbase.*) + } > loadmem + .fimport_vpad ALIGN(16) : { + KEEP ( *(.fimport_vpad) ) + *(.fimport_vpad.*) + } > loadmem + .fimport_zlib125 ALIGN(16) : { + KEEP ( *(.fimport_zlib125) ) + *(.fimport_zlib125.*) + } > loadmem - .dimport_coreinit ALIGN(16) : { *(.dimport_coreinit) } > loadmem - .dimport_nn_act ALIGN(16) : { *(.dimport_nn_act) } > loadmem - .dimport_nn_boss ALIGN(16) : { *(.dimport_nn_boss) } > loadmem - .dimport_nn_ec ALIGN(16) : { *(.dimport_nn_ec) } > loadmem - .dimport_nn_nim ALIGN(16) : { *(.dimport_nn_nim) } > loadmem - .dimport_nn_sl ALIGN(16) : { *(.dimport_nn_sl) } > loadmem - .dimport_nn_uds ALIGN(16) : { *(.dimport_nn_uds) } > loadmem + .dimport_coreinit ALIGN(16) : { + KEEP ( *(.dimport_coreinit) ) + *(.dimport_coreinit.*) + } > loadmem + .dimport_nn_act ALIGN(16) : { + KEEP ( *(.dimport_nn_act) ) + *(.dimport_nn_act.*) + } > loadmem + .dimport_nn_boss ALIGN(16) : { + KEEP ( *(.dimport_nn_boss) ) + *(.dimport_nn_boss.*) + } > loadmem + .dimport_nn_ec ALIGN(16) : { + KEEP ( *(.dimport_nn_ec) ) + *(.dimport_nn_ec.*) + } > loadmem + .dimport_nn_nim ALIGN(16) : { + KEEP ( *(.dimport_nn_nim) ) + *(.dimport_nn_nim.*) + } > loadmem + .dimport_nn_sl ALIGN(16) : { + KEEP ( *(.dimport_nn_sl) ) + *(.dimport_nn_sl.*) + } > loadmem + .dimport_nn_uds ALIGN(16) : { + KEEP ( *(.dimport_nn_uds) ) + *(.dimport_nn_uds.*) + } > loadmem .symtab ALIGN(4) : { *(.symtab) } > loadmem .strtab ALIGN(1) : { *(.strtab) } > loadmem