WerWolv / EdiZon

💡 A homebrew save management, editing tool and memory trainer for Horizon (Nintendo Switch)
GNU General Public License v2.0
1.16k stars 109 forks source link

Breaks with latest libnx (1.3.0.1) and devkitA64 R11-1 #10

Closed borntohonk closed 6 years ago

borntohonk commented 6 years ago
/home/ch/Downloads/EdiZon/source/save.cpp: In function 's32 deleteDirRecursively(const char*, bool)':
/home/ch/Downloads/EdiZon/source/save.cpp:37:28: error: aggregate 'deleteDirRecursively(const char*, bool)::stat statbuf' has incomplete type and cannot be defined
                struct stat statbuf;
                            ^~~~~~~
/home/ch/Downloads/EdiZon/source/save.cpp:41:39: error: invalid use of incomplete type 'struct deleteDirRecursively(const char*, bool)::stat'
                if (!stat(buf, &statbuf)) {
                                       ^
/home/ch/Downloads/EdiZon/source/save.cpp:37:23: note: forward declaration of 'struct deleteDirRecursively(const char*, bool)::stat'
                struct stat statbuf;
                       ^~~~
/home/ch/Downloads/EdiZon/source/save.cpp:42:23: error: 'S_ISDIR' was not declared in this scope
                   if (S_ISDIR(statbuf.st_mode))
                       ^~~~~~~
/home/ch/Downloads/EdiZon/source/save.cpp:42:23: note: suggested alternative: 'EISDIR'
                   if (S_ISDIR(statbuf.st_mode))
                       ^~~~~~~
                       EISDIR
/home/ch/Downloads/EdiZon/source/save.cpp: In function 'void makeExInjDir(char*, u64, u128, bool, const char*)':
/home/ch/Downloads/EdiZon/source/save.cpp:73:3: error: 'mkdir' was not declared in this scope
   mkdir(ROOT_DIR, 0700);
   ^~~~~
/home/ch/Downloads/EdiZon/source/save.cpp:73:3: note: suggested alternative: 'rmdir'
   mkdir(ROOT_DIR, 0700);
   ^~~~~
   rmdir
/home/ch/Downloads/EdiZon/source/save.cpp: In function 's32 isDirectory(const char*)':
/home/ch/Downloads/EdiZon/source/save.cpp:140:14: error: aggregate 'isDirectory(const char*)::stat statbuf' has incomplete type and cannot be defined
  struct stat statbuf;
              ^~~~~~~
/home/ch/Downloads/EdiZon/source/save.cpp:142:25: error: invalid use of incomplete type 'struct isDirectory(const char*)::stat'
  if (stat(path, &statbuf) != 0)
                         ^
/home/ch/Downloads/EdiZon/source/save.cpp:140:9: note: forward declaration of 'struct isDirectory(const char*)::stat'
  struct stat statbuf;
         ^~~~
/home/ch/Downloads/EdiZon/source/save.cpp:145:9: error: 'S_ISDIR' was not declared in this scope
  return S_ISDIR(statbuf.st_mode);
         ^~~~~~~
/home/ch/Downloads/EdiZon/source/save.cpp:145:9: note: suggested alternative: 'EISDIR'
  return S_ISDIR(statbuf.st_mode);
         ^~~~~~~
         EISDIR
/home/ch/Downloads/EdiZon/source/save.cpp: In function 's32 copyAllSave(const char*, bool, const char*)':
/home/ch/Downloads/EdiZon/source/save.cpp:213:13: error: 'mkdir' was not declared in this scope
             mkdir(filenameSave, 0700);
             ^~~~~
/home/ch/Downloads/EdiZon/source/save.cpp:213:13: note: suggested alternative: 'dir'
             mkdir(filenameSave, 0700);
             ^~~~~
             dir
/home/ch/Downloads/EdiZon/source/save.cpp:217:13: error: 'mkdir' was not declared in this scope
             mkdir(filenameSD, 0700);
             ^~~~~
/home/ch/Downloads/EdiZon/source/save.cpp:217:13: note: suggested alternative: 'dir'
             mkdir(filenameSD, 0700);
             ^~~~~
             dir
/opt/devkitpro/devkitA64/base_rules:13: recipe for target 'save.o' failed
make[1]: *** [save.o] Error 1
WerWolv commented 6 years ago

Are you sure you're using the latest version that comes with devkitpro? I've just updated my whole devkit and libnx and everything still works and compiles as it did before. You might also be missing some other dependencies... We're making an Q&A right now that will have a guide for compilation in it so you might want to wait for that

borntohonk commented 6 years ago

Latest everything, on linux. So yeah. Have had no issues building prior to these getting updated. Even hbmenu seems to be affected.

WerWolv commented 6 years ago

@borntohonk Before we used a special version of libnx that fixed the issues with sockets. Have you tried to delete libnx and recloning and building it manually? Maybe something went wrong during the update

borntohonk commented 6 years ago

https://devkitpro.org/viewtopic.php?f=13&t=8751

I'm more or less sure it's devkitA64's fault

base rules

    @echo $(notdir $@)
    @rm -f $@
    $(AR) -rc $@ $^

#---------------------------------------------------------------------------------
%.o: %.cpp
    @echo $(notdir $<)
    $(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)

make file

all: $(BUILD)

$(BUILD):
    @[ -d $@ ] || mkdir -p $@ $(BUILD) $(OUTDIR)
    @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
borntohonk commented 6 years ago

I did a clean install of ubuntu and set up the toolchain again, and the issue persists. Can't build hbmenu or edizon.

It definitively is devkitA64 11.1 causing this. @WinterMute

WinterMute commented 6 years ago

looks to me like you're missing a header. I'll have a look in a bit

WinterMute commented 6 years ago

Yep. Missing headers.

You also have things in the Makefile that shouldn't be there.

davem@ashpool MSYS ~/projects/switch/test/EdiZon
$ git diff
diff --git a/Makefile b/Makefile
index aac0539..5aaecca 100644
--- a/Makefile
+++ b/Makefile
@@ -58,14 +58,14 @@ CFLAGS      :=      -g -Wall -O3 -ffunction-sections \
                        -DVERSION_MINOR=${VERSION_MINOR} \
                        -DVERSION_MICRO=${VERSION_MICRO}

-CFLAGS +=      $(INCLUDE) -D__SWITCH__ -I$(DEVKITPRO)/libnx/external/bsd/include
+CFLAGS +=      $(INCLUDE) -D__SWITCH__

 CXXFLAGS       := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17

 ASFLAGS        :=      -g $(ARCH)
-LDFLAGS        =       -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-no-as-needed,-Map,$(notdir $*.map)
+LDFLAGS        =       -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

-LIBS   := -lnx -lcurl -lz
+LIBS   := -lcurl -lz -lnx

 #---------------------------------------------------------------------------------
 # list of directories containing libraries, this must be the top level containing
diff --git a/source/save.cpp b/source/save.cpp
index 37338b1..fa7bc0d 100644
--- a/source/save.cpp
+++ b/source/save.cpp
@@ -1,5 +1,7 @@
 #include "save.hpp"

+#include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>

 #include "account.hpp"
WerWolv commented 6 years ago

@WinterMute Are you saying we have something in our make file that shouldn't be there or are you talking to @borntohonk now?

WinterMute commented 6 years ago

@WerWolv98 I attached a patch which fixes the Makefile as well as the build error.

$(DEVKITPRO)/libnx/external/bsd/include shouldn't exist never mind be part of your include paths. If this path exists then remove your libnx folder and reinstall latest libnx using pacman.

-Wl,-no-as-needed serves no purpose at all in this environment.

Generally -lnx should be last in the libs. This project will fail to link when we update curl in the future. Probably best to fix it now so nobody is blaming the tools for the failure.

WerWolv commented 6 years ago

@WinterMute Thanks. I updated libnx but didn't delete the old libnx folder. Still, I'm using the latest devkit and now the latest libnx and have no issues with building. If the folder I explicitly included there doesn't exist it should just get ignored IIRC so I can't really see why you're having problems with building @borntohonk

WinterMute commented 6 years ago

I'm not having problems building. I fixed your project & provided a patch and offered advice on how to avoid potential problems.

The issue I have is that the folder you explicitly included is a folder from the source tree which should not be in the install location. If that folder does exist then it's likely to break in future iterations of the tools and libraries.

The fact that you have that include path in the Makefile implies that the folder should exist there and is likely to lead others to improperly install libnx and end up with broken tools.

Please remove it before it causes problems.

WinterMute commented 6 years ago

@WerWolv98 also, you can't possibly be using the latest devkitA64 with this tree. It fails to build without the patch I supplied at https://github.com/thomasnet-mc/EdiZon/issues/10#issuecomment-404863255