From 7ed8784b502c21a955faca78b4f8dc5247ff0e23 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 4 Mar 2020 02:51:43 -0500 Subject: [PATCH 1/7] Compression: Support gzip in decompressZlib --- src/athena/Compression.cpp | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/athena/Compression.cpp b/src/athena/Compression.cpp index 4ede938..47bd6e0 100644 --- a/src/athena/Compression.cpp +++ b/src/athena/Compression.cpp @@ -12,36 +12,25 @@ namespace athena::io::Compression { atInt32 decompressZlib(const atUint8* src, atUint32 srcLen, atUint8* dst, atUint32 dstLen) { z_stream strm = {}; - strm.total_in = strm.avail_in = srcLen; - strm.total_out = strm.avail_out = dstLen; - strm.next_in = (Bytef*)src; - strm.next_out = (Bytef*)dst; - + strm.avail_in = srcLen; + strm.avail_out = dstLen; + strm.next_in = const_cast(src); + strm.next_out = dst; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; - atInt32 err = -1; - atInt32 ret = -1; + atInt32 ret; + // 15 window bits, and the | 16 tells zlib to to detect if using gzip or zlib + ret = inflateInit2(&strm, MAX_WBITS | 16); - err = inflateInit(&strm); // 15 window bits, and the +32 tells zlib to to detect if using gzip or zlib - - if (err == Z_OK) { - err = inflate(&strm, Z_FINISH); - - if (err == Z_STREAM_END) + if (ret == Z_OK) { + ret = inflate(&strm, Z_FINISH); + if (ret == Z_STREAM_END) { ret = strm.total_out; - else { - inflateEnd(&strm); - return err; } - } else { - inflateEnd(&strm); - return err; } - inflateEnd(&strm); - return ret; } From c7c4909e3316f838ae374581140729e1c3247beb Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 14 Apr 2020 20:51:39 -0400 Subject: [PATCH 2/7] Add LLVMRemarks & LLVMBitStreamReader to atdna link --- atdna/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index e0f5321..5ec35f6 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -73,6 +73,8 @@ else() LLVMMC LLVMProfileData LLVMSupport + LLVMRemarks + LLVMBitStreamReader ${LLVMDEMANGLE_LIB}) endif() From aa94bdadc4c161796bd30c3d41bd56b6c801bf8d Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 15 Apr 2020 06:35:32 -0700 Subject: [PATCH 3/7] Downgrade aggressive fatal to error --- src/athena/MemoryReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/athena/MemoryReader.cpp b/src/athena/MemoryReader.cpp index f92d54f..9b60938 100644 --- a/src/athena/MemoryReader.cpp +++ b/src/athena/MemoryReader.cpp @@ -104,7 +104,7 @@ atUint8* MemoryReader::data() const { atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length) { if (m_position >= m_length) { if (m_globalErr) - atFatal(FMT_STRING("Position {:08X} outside stream bounds "), m_position); + atError(FMT_STRING("Position {:08X} outside stream bounds "), m_position); m_position = m_length; setError(); return 0; From 3c5b138306f2def73afd836660145467ba206f8d Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 17 Apr 2020 11:11:01 -0700 Subject: [PATCH 4/7] Fix `_Bool` error --- atdna/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/atdna/main.cpp b/atdna/main.cpp index 0becc78..55035af 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -262,7 +262,11 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { templateStmt += ", "; qualType += ", "; } - templateStmt += nonTypeParm->getType().getAsString().append(1, ' ').append(nonTypeParm->getName().str()); + if (nonTypeParm->getType()->isBooleanType()) { + templateStmt += std::string("bool ") + nonTypeParm->getName().str(); + } else { + templateStmt += nonTypeParm->getType().getAsString().append(1, ' ').append(nonTypeParm->getName().str()); + } qualType += nonTypeParm->getName(); needsComma = true; } From 1aa27c728963add720fbc18b9d1e05da88d505a6 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 17 Apr 2020 14:21:30 -0400 Subject: [PATCH 5/7] Use QualType::getAsString(PrintingPolicy&) to honor bool output option --- atdna/main.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/atdna/main.cpp b/atdna/main.cpp index 55035af..d2a2ac6 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -262,11 +262,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { templateStmt += ", "; qualType += ", "; } - if (nonTypeParm->getType()->isBooleanType()) { - templateStmt += std::string("bool ") + nonTypeParm->getName().str(); - } else { - templateStmt += nonTypeParm->getType().getAsString().append(1, ' ').append(nonTypeParm->getName().str()); - } + templateStmt += nonTypeParm->getType().getAsString(context.getPrintingPolicy()).append(1, ' ').append(nonTypeParm->getName().str()); qualType += nonTypeParm->getName(); needsComma = true; } From 503cc155c67d320ec67f2d9e7bb2b582fbdf5e7a Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 19 Apr 2020 21:11:14 -0400 Subject: [PATCH 6/7] Windows build fixes --- atdna/CMakeLists.txt | 7 +++---- atdna/FindLLVM.cmake | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index 5ec35f6..fcb103d 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -10,12 +10,11 @@ get_directory_property(ATDNA_DEFINES COMPILE_DEFINITIONS) list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1) set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}") -# Force this binary to Release flags (to make MSVC happy) +# Force this binary to /MD flags (to make MSVC happy) if(MSVC) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE}") - set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") + set(CMAKE_CXX_FLAGS_DEBUG "/MD /Zi /Ob0 /Od /RTC1") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /O2 /Ob2 /DNDEBUG") - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-debug -incremental:no") + set(CMAKE_CXX_FLAGS_RELEASE "/MD /Zi /O2 /Ob1 /DNDEBUG") endif() # Find dependencies diff --git a/atdna/FindLLVM.cmake b/atdna/FindLLVM.cmake index d10022a..e76c075 100644 --- a/atdna/FindLLVM.cmake +++ b/atdna/FindLLVM.cmake @@ -30,7 +30,7 @@ set(LLVM_ROOT_DIR "" CACHE PATH "Location of LLVM development root") set(LLVM_FIND_COMPONENTS "") if(WIN32) -get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE CACHE) +get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE) endif() set(llvm_config_names llvm-config-3.9 llvm-config39 From 07b015782ba2123ef76f4f964b4913aa18acd816 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 22 Apr 2020 03:36:08 -0700 Subject: [PATCH 7/7] Fix compiling with clang-10 --- atdna/CMakeLists.txt | 39 ++++++++++++++++++++++++++++----------- atdna/main.cpp | 5 ++++- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index fcb103d..3730956 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -30,6 +30,8 @@ else() endif() if(ATDNA_DYNAMIC_LLVM) + find_library(CLANGCPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib") + if (NOT CLANGCPP_LIB) list(APPEND LLVM_LIBS clangFrontend clangTooling @@ -43,6 +45,11 @@ if(ATDNA_DYNAMIC_LLVM) clangLex clangBasic LLVM) + else() + list(APPEND LLVM_LIBS + clang-cpp + LLVM) + endif() else() find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib") find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib") @@ -52,18 +59,27 @@ else() if (NOT LLVMBINARYFORMAT_LIB) set(LLVMBINARYFORMAT_LIB "") endif() + find_library(CLANG_CPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib") + if (NOT CLANG_CPP_LIB) + list(APPEND CLANG_LIBS + clangFrontend + clangTooling + clangDriver + clangSerialization + clangParse + clangSema + clangAnalysis + clangEdit + clangAST + clangLex + clangBasic) + else() + list(APPEND CLANG_LIBS + clang-cpp) + endif() + list(APPEND LLVM_LIBS - clangFrontend - clangTooling - clangDriver - clangSerialization - clangParse - clangSema - clangAnalysis - clangEdit - clangAST - clangLex - clangBasic + ${CLANG_LIBS} LLVMCore LLVMOption LLVMMCParser @@ -134,6 +150,7 @@ if(MSVC) target_compile_options(atdna PRIVATE /GR-) else() target_compile_options(atdna PRIVATE -fno-rtti -Wno-error) + set_property(TARGET atdna PROPERTY CXX_STANDARD 17) endif() # Define installs diff --git a/atdna/main.cpp b/atdna/main.cpp index d2a2ac6..b21eda3 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -1261,10 +1261,13 @@ int main(int argc, const char** argv) { } llvm::IntrusiveRefCntPtr fman(new clang::FileManager(clang::FileSystemOptions())); +#if LLVM_VERSION_MAJOR >= 10 + clang::tooling::ToolInvocation TI(std::move(args), std::make_unique(), fman.get()); +#else ATDNAAction* action = new ATDNAAction(); clang::tooling::ToolInvocation TI(std::move(args), action, fman.get()); +#endif if (!TI.run()) return 1; - return 0; }