From 6c52de489f7c2e78fbbd8ea15287f2783c9d5879 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 24 May 2020 11:50:37 -0400 Subject: [PATCH 1/8] Add Homebrew LLVM path hint --- atdna/FindLLVM.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/atdna/FindLLVM.cmake b/atdna/FindLLVM.cmake index e76c075..5adf28c 100644 --- a/atdna/FindLLVM.cmake +++ b/atdna/FindLLVM.cmake @@ -44,7 +44,7 @@ set(llvm_config_names llvm-config-3.9 llvm-config39 llvm-config-3.1 llvm-config31 llvm-config) find_program(LLVM_CONFIG NAMES ${llvm_config_names} - PATHS ${LLVM_ROOT_DIR}/bin NO_DEFAULT_PATH + PATHS ${LLVM_ROOT_DIR}/bin /usr/local/opt/llvm/bin NO_DEFAULT_PATH DOC "Path to llvm-config tool.") find_program(LLVM_CONFIG NAMES ${llvm_config_names}) @@ -207,4 +207,3 @@ endif() find_package_handle_standard_args(LLVM REQUIRED_VARS LLVM_ROOT_DIR LLVM_HOST_TARGET VERSION_VAR LLVM_VERSION_STRING) - From dec27c05ed656b37ef75744688529b67c6f60dcc Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 27 May 2020 21:37:03 -0400 Subject: [PATCH 2/8] Use CMake MSVC_RUNTIME_LIBRARY to control MSVC flags --- CMakeLists.txt | 2 ++ atdna/CMakeLists.txt | 11 +++-------- extern/zlib/CMakeLists.txt | 4 +--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a199a9a..60b1c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17 +# Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY +cmake_policy(SET CMP0091 NEW) project(athena) if (NOT MSVC) set(CMAKE_CXX_STANDARD 20) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index 3730956..15194b8 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -10,13 +10,6 @@ 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 /MD flags (to make MSVC happy) -if(MSVC) - set(CMAKE_CXX_FLAGS_DEBUG "/MD /Zi /Ob0 /Od /RTC1") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /O2 /Ob2 /DNDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "/MD /Zi /O2 /Ob1 /DNDEBUG") -endif() - # Find dependencies include(FindLLVM.cmake) if(NOT LLVM_FOUND) @@ -147,7 +140,9 @@ set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS}) target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS}) if(MSVC) - target_compile_options(atdna PRIVATE /GR-) + # Allow linking against release-built LLVM libraries + target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0) + set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") else() target_compile_options(atdna PRIVATE -fno-rtti -Wno-error) set_property(TARGET atdna PROPERTY CXX_STANDARD 17) diff --git a/extern/zlib/CMakeLists.txt b/extern/zlib/CMakeLists.txt index 87b820e..a09ce94 100644 --- a/extern/zlib/CMakeLists.txt +++ b/extern/zlib/CMakeLists.txt @@ -1,7 +1,5 @@ -if(NOT WIN32) find_package(ZLIB) -endif() -if(WIN32 OR NOT ZLIB_FOUND) +if(NOT ZLIB_FOUND) message(STATUS "Using Athena's built-in zlib") add_library(z adler32.c From 1b8b7f681987086a27866220dd5f0ecefd6aab2c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 10 Jun 2020 00:13:49 -0400 Subject: [PATCH 3/8] DNAYaml: Correctly initialize yaml events --- src/athena/DNAYaml.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/athena/DNAYaml.cpp b/src/athena/DNAYaml.cpp index fd3c4f3..e8ac58f 100644 --- a/src/athena/DNAYaml.cpp +++ b/src/athena/DNAYaml.cpp @@ -441,8 +441,6 @@ bool YAMLDocWriter::finish(athena::io::IStreamWriter* fout) { return false; }; - yaml_event_t event = {}; - if (fout) { yaml_emitter_set_output(&m_emitter, (yaml_write_handler_t*)YAMLAthenaWriter, fout); } @@ -450,16 +448,15 @@ bool YAMLDocWriter::finish(athena::io::IStreamWriter* fout) { return error(); } - event.type = YAML_DOCUMENT_START_EVENT; - event.data.document_start.implicit = true; + yaml_event_t event; + yaml_document_start_event_initialize(&event, nullptr, nullptr, nullptr, 1); if (!yaml_emitter_emit(&m_emitter, &event)) { return error(); } if (!RecursiveFinish(&m_emitter, *m_rootNode)) { return false; } - event.type = YAML_DOCUMENT_END_EVENT; - event.data.document_end.implicit = true; + yaml_document_end_event_initialize(&event, 1); if (!yaml_emitter_emit(&m_emitter, &event)) { return error(); } From 0bc400b4d9015e6afd7e1c917fbb10cd2d9c2064 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 13 Jun 2020 17:18:23 -0400 Subject: [PATCH 4/8] extern/zlib: Use find_library --- extern/zlib/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extern/zlib/CMakeLists.txt b/extern/zlib/CMakeLists.txt index a09ce94..78b967d 100644 --- a/extern/zlib/CMakeLists.txt +++ b/extern/zlib/CMakeLists.txt @@ -1,5 +1,7 @@ -find_package(ZLIB) -if(NOT ZLIB_FOUND) +if(NOT WIN32) # remove when specter/freetype is gone +find_library(ZLIB_LIB zlib) +endif() +if(NOT ZLIB_LIB) message(STATUS "Using Athena's built-in zlib") add_library(z adler32.c @@ -31,6 +33,6 @@ endif() set(ZLIB_LIBRARIES z CACHE PATH "Zlib libraries" FORCE) set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Zlib include path" FORCE) else() -set(ZLIB_LIBRARIES ${ZLIB_LIBRARIES} CACHE PATH "Zlib libraries" FORCE) +set(ZLIB_LIBRARIES ${ZLIB_LIB} CACHE PATH "Zlib libraries" FORCE) find_path(ZLIB_INCLUDE_DIR zlib.h) endif() From 347d807a2320e96278de844388b6807e84db160d Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 13 Jun 2020 20:44:15 -0700 Subject: [PATCH 5/8] Fix zlib --- extern/zlib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/zlib/CMakeLists.txt b/extern/zlib/CMakeLists.txt index 78b967d..6d007fd 100644 --- a/extern/zlib/CMakeLists.txt +++ b/extern/zlib/CMakeLists.txt @@ -1,5 +1,5 @@ if(NOT WIN32) # remove when specter/freetype is gone -find_library(ZLIB_LIB zlib) +find_library(ZLIB_LIB NAMES zlib z) endif() if(NOT ZLIB_LIB) message(STATUS "Using Athena's built-in zlib") From 5489a25fbefae688b40c62c3f642499b9e5d8d2e Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 6 Sep 2020 01:39:12 -0400 Subject: [PATCH 6/8] Updates for Clang 10 on Windows --- atdna/CMakeLists.txt | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index 15194b8..6962b42 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -25,24 +25,24 @@ 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 - clangDriver - clangSerialization - clangParse - clangSema - clangAnalysis - clangEdit - clangAST - clangLex - clangBasic - LLVM) - else() + list(APPEND LLVM_LIBS + clangFrontend + clangTooling + clangDriver + clangSerialization + clangParse + clangSema + clangAnalysis + clangEdit + clangAST + clangLex + clangBasic + LLVM) + else() list(APPEND LLVM_LIBS clang-cpp LLVM) - endif() + endif() else() find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib") find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib") @@ -83,7 +83,8 @@ else() LLVMSupport LLVMRemarks LLVMBitStreamReader - ${LLVMDEMANGLE_LIB}) + ${LLVMDEMANGLE_LIB} + LLVMFrontendOpenMP) endif() string(FIND ${LLVM_VERSION_STRING} "svn" SVN_FILTER_IDX) @@ -139,13 +140,14 @@ set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS "INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR};__STDC_LIMIT_MACROS=1;__STDC_CONSTANT_MACROS=1") target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS}) target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS}) +# Clang 10.0.x headers currently broken with C++20 +set_property(TARGET atdna PROPERTY CXX_STANDARD 17) if(MSVC) # Allow linking against release-built LLVM libraries target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0) set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") else() target_compile_options(atdna PRIVATE -fno-rtti -Wno-error) - set_property(TARGET atdna PROPERTY CXX_STANDARD 17) endif() # Define installs From 4e29ba7d8f4ed729aedab3a3a3e32325812ab262 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 18 Sep 2020 16:22:35 -0400 Subject: [PATCH 7/8] DNAOp: Fix clang -Wrange-loop-analysis errors --- include/athena/DNAOp.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/athena/DNAOp.hpp b/include/athena/DNAOp.hpp index ba502d3..b4ec911 100644 --- a/include/athena/DNAOp.hpp +++ b/include/athena/DNAOp.hpp @@ -500,7 +500,7 @@ struct Write { static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, StreamT& w) { /* libc++ specializes vector as a bitstream */ - for (const T& v : vector) + for (const T v : vector) w.writeBool(v); } static void Do(const PropId& id, std::unique_ptr& buf, size_t count, StreamT& w) { @@ -732,7 +732,7 @@ struct WriteYaml { StreamT& w) { /* libc++ specializes vector as a bitstream */ if (auto __v = w.enterSubVector(id.name)) - for (const T& v : vector) + for (const T v : vector) w.writeBool(v); } static void Do(const PropId& id, std::unique_ptr& buf, size_t count, StreamT& w) { From f298113c4ee410f561731921f4cabacdb8ddc232 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 11 Dec 2020 19:49:16 -0800 Subject: [PATCH 8/8] Fix code generation for Endian template parameter values on LLVM 11 --- atdna/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/atdna/main.cpp b/atdna/main.cpp index b21eda3..464388b 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -419,7 +419,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { regType = regType->getUnqualifiedDesugaredType(); } - std::string fieldName = field->getName(); + std::string fieldName = field->getName().str(); std::string propIdExpr = GetPropIdExpr(field, fieldName); if (regType->getTypeClass() == clang::Type::TemplateSpecialization) { @@ -431,6 +431,8 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { llvm::APSInt endian(64, -1); std::string endianExprStr; bool defaultEndian = true; + /* FIXME: The is the following code required? */ +#if 0 if (classParms->size() >= 2) { const clang::NamedDecl* endianParm = classParms->getParam(1); if (endianParm->getKind() == clang::Decl::NonTypeTemplateParm) { @@ -439,7 +441,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { nttParm->print(strStream, context.getPrintingPolicy()); } } - +#endif for (const clang::TemplateArgument& arg : *tsType) { if (arg.getKind() == clang::TemplateArgument::Expression) { const clang::Expr* expr = arg.getAsExpr(); @@ -818,7 +820,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor { regType = regType->getUnqualifiedDesugaredType(); } - std::string fieldName = field->getName(); + std::string fieldName = field->getName().str(); std::string propIdExpr = GetPropIdExpr(field, fieldName); if (regType->getTypeClass() == clang::Type::TemplateSpecialization) {