mcmilk / 7-Zip-zstd

7-Zip with support for Brotli, Fast-LZMA2, Lizard, LZ4, LZ5 and Zstandard
https://mcmilk.de/projects/7-Zip-zstd/
Other
5.06k stars 300 forks source link

How to build the latest 22.01 #274

Closed mshedsilegx closed 1 year ago

mshedsilegx commented 1 year ago

I'm trying to build the latest master branch with AppVeyor. All goes well until:

resource.rc(35) : error RC2135 : file not found: ../../Archive/Icons/apfs.ico : fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64\rc.EXE"' : return code '0x1' Stop.

Any idea how to inject those icons in the source tree so that they can be found ?

mshedsilegx commented 1 year ago

is there any documentation on the build process for the current main branch ? Any pointers would be appreciated.

mshedsilegx commented 1 year ago

after removing the missing icon frm resource.rc, the build of Format7zF fails with the error below:

../../Archive\ZstdHandler.cpp(375): error C2220: the following warning is treated as an error ../../Archive\ZstdHandler.cpp(375): warning C4003: not enough arguments for function-like macro invocation 'REGISTER_ARC_IO' ../../Archive\ZstdHandler.cpp(370): error C2440: 'initializing': cannot convert from 'UInt32 (__cdecl )(const Byte ,size_t)' to 'UInt32' ../../Archive\ZstdHandler.cpp(370): note: There is no context in which this conversion is possible NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.EXE"' : return code '0x2' Stop. Command exited with code 2

rohitab commented 1 year ago

I ran into the same issue while building the latest version today. I was able to fix the code and successfully build 7z.dll. The issue is due to missing time flags for the REGISTER_ARC_IO macro. I've set the time flags to 0, but most likely they need to be set to proper values using TIME_PREC_TO_ARC_FLAGS_MASK and TIME_PREC_TO_ARC_FLAGS_TIME_DEFAULT.

I'm attaching a zip file that contains the source code patch and the missing icon. Apply the included patch and copy apfs.ico to CPP\7zip\Archive\Icons directory. The source code should build after that.

7-Zip-zstd-22.01-rohitab.patch.zip

isarrider commented 1 year ago

@rohitab Will you digg deeper for a proper fix n create a PR after that?

isarrider commented 1 year ago

here is btw a working compile... https://github.com/SCell555/7-Zip-zstd

mshedsilegx commented 1 year ago

Do you think the approach below is correct for example zstd ?

REGISTER_ARC_IO(
  "zstd", "zst tzstd", "* .tar", 0x0e,
  k_Signature,
  0,
  NArcInfoFlags::kKeepName,
  TIME_PREC_TO_ARC_FLAGS_MASK (NFileTimeType::kWindows)
  | TIME_PREC_TO_ARC_FLAGS_MASK (NFileTimeType::kUnix)
  | TIME_PREC_TO_ARC_FLAGS_MASK (NFileTimeType::kDOS)
  | TIME_PREC_TO_ARC_FLAGS_TIME_DEFAULT (NFileTimeType::kWindows),
  IsArc_zstd)
rohitab commented 1 year ago

Based on this comment https://github.com/facebook/zstd/issues/1402#issuecomment-436368266_ by a zstd developer, it appears that zstd does not store the file modification time. In which case, I think that time precision flags are probably not be required.

Take a look at REGISTER_ARC_IO for bzip. You'll see that time precision flags are not set, which makes sense since bzip does not store file time.

https://github.com/mcmilk/7-Zip-zstd/blob/d03b30eb8d8f507bce31a43b2829caa9f3415a38/CPP/7zip/Archive/Bz2Handler.cpp#L478-L484

Now, if you look at REGISTER_ARC_IO for gzip, you'll see that the flags are set. Again, this makes sense since gzip stores the modification time. You can also see that the NArcInfoFlags::kMTime flag is set.

https://github.com/mcmilk/7-Zip-zstd/blob/d03b30eb8d8f507bce31a43b2829caa9f3415a38/CPP/7zip/Archive/GzHandler.cpp#L1207-L1215

Since zstd does not store the file modification time either, the time flags should be similar to bzip, i.e. the time flags should be set to 0.

Please note that I've only have a cursory look at the code, and I'm not an expert on compression formats. So, I may be wrong.

@isarrider I thought about it, but since I wasn't 100% sure about the change, I didn't want to submit an incorrect PR. Also, there are some other issues with the build. For example, Alone2 does not build, unless you add additional objects to the makefile. The developer is aware that the latest version doesn't build. See https://github.com/mcmilk/7-Zip-zstd/issues/281#issuecomment-1319689195. I assume they will release an update when ready.

isarrider commented 1 year ago

@rohitab I know that the dev is aware, but I thought he doesnt have the time atm to work on it... Thats why I just wanted to point out the (incorrect?) working fork...