diff --git a/.github/workflows/vcpkg_ci_amd64.yml b/.github/workflows/vcpkg_ci_amd64.yml index abc44d74..e8de4284 100644 --- a/.github/workflows/vcpkg_ci_amd64.yml +++ b/.github/workflows/vcpkg_ci_amd64.yml @@ -39,9 +39,8 @@ jobs: matrix: image: # 'name' is Docker image name whereas 'os' is more generic - - { os: 'ubuntu', name: 'ubuntu-v2', tag: '20.04' } - { os: 'ubuntu', name: 'ubuntu-v2', tag: '22.04' } - llvm: [ 'llvm-15', 'llvm-16[pasta]', 'llvm-16' ] + llvm: [ 'llvm-16[pasta]', 'llvm-16' ] target_arch: [ 'x64', 'arm64' ] container: @@ -119,6 +118,12 @@ jobs: echo "VCPKG_ROOT=$(pwd)/${{ env.ARTIFACT_NAME }}" >> $GITHUB_ENV echo "TARGET_TRIPLET=${{ matrix.target_arch }}-linux-rel" >> $GITHUB_ENV + - name: Cleanup NuGet + shell: 'bash' + run: | + du -sh ~/.nuget || true + rm -rf ~/.nuget || true + - name: Upload CMake logs on error if: failure() uses: actions/upload-artifact@v3 @@ -175,7 +180,7 @@ jobs: - name: 'Rellic build' shell: 'bash' working-directory: rellic - if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' + if: matrix.target_arch == 'x64' run: | # Does not compile with gcc export CC="$(which clang)" @@ -191,10 +196,10 @@ jobs: cmake --build build --target install - name: 'Rellic test' shell: 'bash' - working-directory: rellic/build - if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' + working-directory: rellic + if: matrix.target_arch == 'x64' run: | - ../scripts/roundtrip.py ./tools/rellic-decomp ../tests/tools/decomp "${VCPKG_ROOT}/installed/${TARGET_TRIPLET}/tools/llvm/clang" + cmake --build build --target test - name: 'Remill dependencies' shell: 'bash' @@ -211,11 +216,6 @@ jobs: if: matrix.target_arch == 'x64' working-directory: remill run: | - if [[ '${{ matrix.image.tag }}' == '20.04' ]]; then - # Remill uses C++20 concepts that aren't supported by gcc-9 in 20.04 - export CC="$(which clang)" - export CXX="$(which clang++)" - fi cmake -G Ninja \ -DCMAKE_VERBOSE_MAKEFILE=ON \ "-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \ @@ -237,7 +237,7 @@ jobs: - name: 'Anvill build' shell: 'bash' working-directory: anvill - if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' + if: matrix.target_arch == 'x64' run: | # TODO: Does not support compilation with gcc export CC="$(which clang)" @@ -257,17 +257,16 @@ jobs: -S . -B build cmake --build build cmake --install build - # NOTE: This is an old test that doesn't make sense anymore - # Need to find some other way to run a smoketest - #- name: 'Anvill test' - # shell: 'bash' - # working-directory: anvill - # if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' - # run: | - # ./install/bin/anvill-decompile-spec --spec ../bin/Decompile/tests/specs/ret0.json --bc_out ./ret0.bc --ir_out ret0.ir + - name: 'Anvill test' + shell: 'bash' + working-directory: anvill + if: matrix.target_arch == 'x64' + run: | + cmake --build build --target test - name: Cache cleanup and reporting shell: 'bash' run: | rm -rf vcpkg/{buildtrees,installed,packages} ccache --show-stats + df -h diff --git a/.github/workflows/vcpkg_ci_mac.yml b/.github/workflows/vcpkg_ci_mac.yml index f8502dcf..00250189 100644 --- a/.github/workflows/vcpkg_ci_mac.yml +++ b/.github/workflows/vcpkg_ci_mac.yml @@ -37,7 +37,7 @@ jobs: matrix: os: - { runner: 'macos-12', xcode: '14.2' } - llvm: [ 'llvm-15', 'llvm-16[pasta]', 'llvm-16' ] + llvm: [ 'llvm-16[pasta]', 'llvm-16' ] target_arch: [ 'x64', 'arm64' ] runs-on: ${{ matrix.os.runner }} @@ -177,7 +177,7 @@ jobs: - name: 'Rellic build' shell: 'bash' working-directory: rellic - if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' + if: matrix.target_arch == 'x64' run: | cmake -G Ninja \ -DCMAKE_VERBOSE_MAKEFILE=ON \ @@ -191,11 +191,10 @@ jobs: cmake --install build - name: 'Rellic test' shell: 'bash' - working-directory: rellic/build - if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' + working-directory: rellic + if: matrix.target_arch == 'x64' run: | - # Test only should run when we're not cross compiling - ../scripts/roundtrip.py ./tools/rellic-decomp ../tests/tools/decomp "${VCPKG_ROOT}/installed/${TARGET_TRIPLET}/tools/llvm/clang" + cmake --build build --target test - name: 'Remill dependencies' shell: 'bash' @@ -234,7 +233,7 @@ jobs: - name: 'Anvill build' shell: 'bash' working-directory: anvill - if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' + if: matrix.target_arch == 'x64' run: | cmake -G Ninja \ -DCMAKE_VERBOSE_MAKEFILE=ON \ @@ -251,16 +250,12 @@ jobs: -S . -B build cmake --build build cmake --install build - - # NOTE: This is an old test that doesn't make sense anymore - # Need to find some other way to run a smoketest - #- name: 'Anvill test' - # shell: 'bash' - # working-directory: anvill - # # if: contains(matrix.llvm, 'llvm-15') && matrix.target_arch == 'x64' - # if: matrix.target_arch == 'x64' - # run: | - # ./install/bin/anvill-decompile-spec -spec ../bin/Decompile/tests/specs/ret0.json -bc_out ./ret0.bc -ir_out ret0.ir + - name: 'Anvill test' + shell: 'bash' + working-directory: anvill + if: matrix.target_arch == 'x64' + run: | + cmake --build build --target test - name: Cache cleanup and reporting shell: 'bash' diff --git a/README.md b/README.md index 33b59a9c..b2e20e64 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,8 @@ See [the vcpkg docs](https://github.com/microsoft/vcpkg/blob/master/docs/example Installing additional dependencies will not update any existing dependencies by default. We do not update/upgrade by default because this could cause unexpected rebuilds that could potentially take hours (in the case of LLVM). To update dependencies, pass the `--upgrade-ports` option to the build script along with the respective options affecting vcpkg triplet selection (like `--release`). +You must specify the exact package/ports you want to upgrade. If the port does not exist, this will fail. + ## Useful manual vcpkg commands Sometimes it is useful to run vcpkg commands manually for testing a single package. Ideally, someone who wants to do this would read the [vcpkg documentation](https://github.com/microsoft/vcpkg/tree/master/docs), but below we list some commonly used commands. Inspecting the output of the build script will also show all of the vcpkg commands executed. diff --git a/anvill b/anvill index 232f78fb..9f3e1235 160000 --- a/anvill +++ b/anvill @@ -1 +1 @@ -Subproject commit 232f78fbc7487cdf3c4f7c73c9af496700602910 +Subproject commit 9f3e12353d4dc7e3e07e74a67882736f404396f9 diff --git a/build_dependencies.sh b/build_dependencies.sh index eec53be3..58d696f6 100755 --- a/build_dependencies.sh +++ b/build_dependencies.sh @@ -82,7 +82,7 @@ while [[ $# -gt 0 ]] ; do esac shift done -msg "Passing extra args to 'vcpkg install':" +msg "Passing extra args to vcpkg:" msg " " "${VCPKG_ARGS[@]}" function die_if_not_installed { @@ -237,10 +237,19 @@ if [[ ${UPGRADE_PORTS} == "true" ]]; then cd "${repo_dir}" ( set -x - # shellcheck disable=SC2046 - "${vcpkg_dir}/vcpkg" upgrade "${extra_vcpkg_args[@]}" "${overlays[@]}" --no-dry-run --allow-unsupported + "${vcpkg_dir}/vcpkg" upgrade "${extra_vcpkg_args[@]}" "${overlays[@]}" --allow-unsupported "${VCPKG_ARGS[@]}" || true + + set +x + read -p "Are you sure? If so, enter 'y' " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Yy]$ ]] + then + set -x + "${vcpkg_dir}/vcpkg" upgrade "${extra_vcpkg_args[@]}" "${overlays[@]}" --no-dry-run --allow-unsupported "${VCPKG_ARGS[@]}" || exit 1 + fi ) - ) || exit 1 + ) + exit 0 fi deps=() diff --git a/ports/gap/portfile.cmake b/ports/gap/portfile.cmake new file mode 100644 index 00000000..aa96eada --- /dev/null +++ b/ports/gap/portfile.cmake @@ -0,0 +1,39 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO lifting-bits/gap + REF ad8fefaf7235a9cd6670e272ca4487807ed81f8a + SHA512 9e9259fd4c3c96e31965613092f7dec9df5e236aa4ef9ac122378fe1708d4efd2fb6bd9837530e8474646dc3b0aa409781fd6f45fc28929d07bb54a95a072566 + HEAD_REF main +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DGAP_ENABLE_COROUTINES=ON + -DGAP_ENABLE_TESTING=OFF + -DGAP_ENABLE_EXAMPLES=OFF + -DGAP_INSTALL=ON + -DUSE_SYSTEM_DEPENDENCIES=ON +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup( + PACKAGE_NAME "gap" + CONFIG_PATH lib/cmake/gap +) + +file( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug" ) + +# we do not populate lib folder yet +file( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib" ) + +file( + INSTALL "${SOURCE_PATH}/LICENSE" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" + RENAME copyright +) + +file( + INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" +) diff --git a/ports/gap/usage b/ports/gap/usage new file mode 100644 index 00000000..a41f7dd6 --- /dev/null +++ b/ports/gap/usage @@ -0,0 +1,4 @@ +The package gap provides CMake targets: + + find_package(gap CONFIG REQUIRED) + target_link_libraries(main PRIVATE gap::gap gap::gap-core gap::gap-settings) diff --git a/ports/gap/vcpkg.json b/ports/gap/vcpkg.json new file mode 100644 index 00000000..f992b040 --- /dev/null +++ b/ports/gap/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "gap", + "version": "0.0.0", + "description": "A utility library to bridge llvm and mlir gaps", + "homepage": "https://github.com/lifting-bits/gap", + "license": "Apache-2.0", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/ports/llvm-16/0027-unknown-attrs-as-annotations.patch b/ports/llvm-16/0027-unknown-attrs-as-annotations.patch deleted file mode 100644 index 5a006813..00000000 --- a/ports/llvm-16/0027-unknown-attrs-as-annotations.patch +++ /dev/null @@ -1,198 +0,0 @@ -From b3b2b93d3d0e28e2d1269c3fcbb8a509c2331858 Mon Sep 17 00:00:00 2001 -From: Peter Goodman -Date: Fri, 24 Mar 2023 16:58:52 -0400 -Subject: [PATCH] Patches for supporting arbitrary attributes as annotation - attributes - ---- - clang/include/clang/Basic/LangOptions.def | 2 ++ - clang/include/clang/Driver/Options.td | 5 ++++ - clang/lib/Driver/ToolChains/Clang.cpp | 5 ++++ - clang/lib/Parse/ParseDeclCXX.cpp | 24 +++++++++------- - clang/lib/Sema/SemaDeclAttr.cpp | 25 ++++++++++++++-- - clang/lib/Sema/SemaType.cpp | 35 +++++++++++++++++++---- - 6 files changed, 77 insertions(+), 19 deletions(-) - -diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def -index d1cbe4306..4b2240d57 100644 ---- a/clang/include/clang/Basic/LangOptions.def -+++ b/clang/include/clang/Basic/LangOptions.def -@@ -311,6 +311,8 @@ LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math") - BENIGN_LANGOPT(CLNoSignedZero , 1, 0, "Permit Floating Point optimization without regard to signed zeros") - COMPATIBLE_LANGOPT(CLUnsafeMath , 1, 0, "Unsafe Floating Point Math") - COMPATIBLE_LANGOPT(CLFiniteMathOnly , 1, 0, "__FINITE_MATH_ONLY__ predefined macro") -+ -+LANGOPT(UnknownAttrAnnotate, 1, 0, "Unknown attributes are treated as annotation or annotation type attributes during semantic analysis") - /// FP_CONTRACT mode (on/off/fast). - BENIGN_ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contraction type") - COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating point") -diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td -index 652c15afc..64cb09a9a 100644 ---- a/clang/include/clang/Driver/Options.td -+++ b/clang/include/clang/Driver/Options.td -@@ -4377,6 +4377,11 @@ def working_directory : Separate<["-"], "working-directory">, Flags<[CC1Option]> - def working_directory_EQ : Joined<["-"], "working-directory=">, Flags<[CC1Option]>, - Alias; - -+def funknown_attrs_as_annotate : Flag<["-"], "funknown-attrs-as-annotate">, -+ Flags<[CC1Option]>, -+ HelpText<"Treat unknown attributes as annotation or annotation type attributes in semantic analysis">, -+ MarshallingInfoFlag>; -+ - // Double dash options, which are usually an alias for one of the previous - // options. - -diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp -index ec6860113..02746500d 100644 ---- a/clang/lib/Driver/ToolChains/Clang.cpp -+++ b/clang/lib/Driver/ToolChains/Clang.cpp -@@ -4615,6 +4615,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, - } - } - -+ if (const Arg *A = Args.getLastArg(options::OPT_funknown_attrs_as_annotate)) { -+ CmdArgs.push_back("-funknown-attrs-as-annotate"); -+ A->claim(); -+ } -+ - if (IsOpenMPDevice) { - // We have to pass the triple of the host if compiling for an OpenMP device. - std::string NormalizedTriple = -diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp -index 227c1df2b..4d13a9b6a 100644 ---- a/clang/lib/Parse/ParseDeclCXX.cpp -+++ b/clang/lib/Parse/ParseDeclCXX.cpp -@@ -4368,18 +4368,22 @@ bool Parser::ParseCXX11AttributeArgs( - Syntax = ParsedAttr::AS_Microsoft; - } - -+ - // If the attribute isn't known, we will not attempt to parse any -- // arguments. -- if (Syntax != ParsedAttr::AS_Microsoft && -- !hasAttribute(LO.CPlusPlus ? AttributeCommonInfo::Syntax::AS_CXX11 -- : AttributeCommonInfo::Syntax::AS_C2x, -- ScopeName, AttrName, getTargetInfo(), getLangOpts())) { -- if (getLangOpts().MicrosoftExt || getLangOpts().HLSL) { -+ // arguments. Unless we are treating unknown attributes as annotation -+ // attributes. -+ if (!getLangOpts().UnknownAttrAnnotate) { -+ if (Syntax != ParsedAttr::AS_Microsoft && -+ !hasAttribute(LO.CPlusPlus ? AttributeCommonInfo::Syntax::AS_CXX11 -+ : AttributeCommonInfo::Syntax::AS_C2x, -+ ScopeName, AttrName, getTargetInfo(), getLangOpts())) { -+ if (getLangOpts().MicrosoftExt || getLangOpts().HLSL) { -+ } -+ // Eat the left paren, then skip to the ending right paren. -+ ConsumeParen(); -+ SkipUntil(tok::r_paren); -+ return false; - } -- // Eat the left paren, then skip to the ending right paren. -- ConsumeParen(); -- SkipUntil(tok::r_paren); -- return false; - } - - if (ScopeName && (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"))) { -diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp -index a303c7f57..228b54a61 100644 ---- a/clang/lib/Sema/SemaDeclAttr.cpp -+++ b/clang/lib/Sema/SemaDeclAttr.cpp -@@ -4285,6 +4285,21 @@ static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - S.AddAnnotationAttr(D, AL, Str, Args); - } - -+static void -+handleUnknownAttrAsAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { -+ // Get name of unknown attribute: -+ StringRef Str = AL.getAttrName()->getName(); -+ -+ llvm::SmallVector Args; -+ Args.reserve(AL.getNumArgs()); -+ for (unsigned Idx = 0; Idx < AL.getNumArgs(); Idx++) { -+ assert(!AL.isArgIdent(Idx)); -+ Args.push_back(AL.getArgAsExpr(Idx)); -+ } -+ -+ S.AddAnnotationAttr(D, AL, Str, Args); -+} -+ - static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - S.AddAlignValueAttr(D, AL, AL.getArgAsExpr(0)); - } -@@ -8594,11 +8609,15 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, - // though they were unknown attributes. - if (AL.getKind() == ParsedAttr::UnknownAttribute || - !AL.existsInTarget(S.Context.getTargetInfo())) { -- S.Diag(AL.getLoc(), -- AL.isDeclspecAttribute() -+ if (S.getLangOpts().UnknownAttrAnnotate) { -+ handleUnknownAttrAsAnnotateAttr(S, D, AL); -+ } else { -+ S.Diag(AL.getLoc(), -+ AL.isDeclspecAttribute() - ? (unsigned)diag::warn_unhandled_ms_attribute_ignored - : (unsigned)diag::warn_unknown_attribute_ignored) -- << AL << AL.getRange(); -+ << AL << AL.getRange(); -+ } - return; - } - -diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp -index 8cb1ed28f..909ed3d74 100644 ---- a/clang/lib/Sema/SemaType.cpp -+++ b/clang/lib/Sema/SemaType.cpp -@@ -8287,6 +8287,24 @@ static void HandleMatrixTypeAttr(QualType &CurType, const ParsedAttr &Attr, - CurType = T; - } - -+static void HandleUnkownTypeAttrAsAnnotateTypeAttr(TypeProcessingState &State, -+ QualType &CurType, const ParsedAttr &PA) { -+ Sema &S = State.getSema(); -+ StringRef Str = PA.getAttrName()->getName(); -+ -+ llvm::SmallVector Args; -+ Args.reserve(PA.getNumArgs()); -+ for (unsigned Idx = 0; Idx < PA.getNumArgs(); Idx++) { -+ assert(!PA.isArgIdent(Idx)); -+ Args.push_back(PA.getArgAsExpr(Idx)); -+ } -+ if (!S.ConstantFoldAttrArgs(PA, Args)) -+ return; -+ auto *AnnotateTypeAttr = -+ AnnotateTypeAttr::Create(S.Context, Str, Args.data(), Args.size(), PA); -+ CurType = State.getAttributedType(AnnotateTypeAttr, CurType, CurType); -+} -+ - static void HandleAnnotateTypeAttr(TypeProcessingState &State, - QualType &CurType, const ParsedAttr &PA) { - Sema &S = State.getSema(); -@@ -8390,12 +8408,17 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, - - case ParsedAttr::UnknownAttribute: - if (attr.isStandardAttributeSyntax()) { -- state.getSema().Diag(attr.getLoc(), -- diag::warn_unknown_attribute_ignored) -- << attr << attr.getRange(); -- // Mark the attribute as invalid so we don't emit the same diagnostic -- // multiple times. -- attr.setInvalid(); -+ if (state.getSema().getLangOpts().UnknownAttrAnnotate) { -+ HandleUnkownTypeAttrAsAnnotateTypeAttr(state, type, attr); -+ attr.setUsedAsTypeAttr(); -+ } else { -+ state.getSema().Diag(attr.getLoc(), -+ diag::warn_unknown_attribute_ignored) -+ << attr << attr.getRange(); -+ // Mark the attribute as invalid so we don't emit the same diagnostic -+ // multiple times. -+ attr.setInvalid(); -+ } - } - break; - --- -2.39.0 - diff --git a/ports/llvm-16/0030-UnknownAttrsAsAnnotate-and-AttributedType-Attrs.patch b/ports/llvm-16/0030-UnknownAttrsAsAnnotate-and-AttributedType-Attrs.patch new file mode 100644 index 00000000..d594059f --- /dev/null +++ b/ports/llvm-16/0030-UnknownAttrsAsAnnotate-and-AttributedType-Attrs.patch @@ -0,0 +1,389 @@ +From 32fbac48f39e9fc24263495de5ca0b7df2d4c366 Mon Sep 17 00:00:00 2001 +From: Brent Pappas +Date: Fri, 14 Jul 2023 14:34:09 -0400 +Subject: [PATCH] UnknownAttrsAsAnnotate and AttributedType Attrs + +- Adds the flag `funknown-attrs-as-annotate` to Clang to treat unknown + attributes as annotate attributes by default. +- Adds a an `const Attr *` field to `AttributedType` to store the actual + `Attr` that the type is attributed with, along with methods to access + it. + +Co-authored-by: Laura Bauman +--- + clang/include/clang/AST/ASTContext.h | 3 +- + clang/include/clang/AST/Type.h | 17 ++++++++-- + clang/include/clang/Basic/LangOptions.def | 2 ++ + clang/include/clang/Driver/Options.td | 5 +++ + clang/lib/AST/ASTContext.cpp | 22 +++++++------ + clang/lib/AST/ASTImporter.cpp | 4 ++- + clang/lib/AST/Type.cpp | 5 +-- + clang/lib/Driver/ToolChains/Clang.cpp | 5 +++ + clang/lib/Parse/ParseDeclCXX.cpp | 24 ++++++++------ + clang/lib/Sema/SemaDeclAttr.cpp | 25 +++++++++++++-- + clang/lib/Sema/SemaType.cpp | 38 ++++++++++++++++++----- + clang/lib/Sema/TreeTransform.h | 5 ++- + 12 files changed, 116 insertions(+), 39 deletions(-) + +diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h +index 023837192..6cd459359 100644 +--- a/clang/include/clang/AST/ASTContext.h ++++ b/clang/include/clang/AST/ASTContext.h +@@ -1582,7 +1582,8 @@ public: + QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; + + QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, +- QualType equivalentType) const; ++ QualType equivalentType, ++ const Attr *typeAttr = nullptr) const; + + QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr, + QualType Wrapped); +diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h +index 180251d7f..670e6f20d 100644 +--- a/clang/include/clang/AST/Type.h ++++ b/clang/include/clang/AST/Type.h +@@ -56,6 +56,7 @@ + + namespace clang { + ++class Attr; + class BTFTypeTagAttr; + class ExtQuals; + class QualType; +@@ -4880,13 +4881,14 @@ public: + private: + friend class ASTContext; // ASTContext creates these + ++ const Attr *TypeAttr; + QualType ModifiedType; + QualType EquivalentType; + +- AttributedType(QualType canon, attr::Kind attrKind, QualType modified, +- QualType equivalent) ++ AttributedType(QualType canon, Kind attrKind, QualType modified, ++ QualType equivalent, const Attr *typeAttr = nullptr) + : Type(Attributed, canon, equivalent->getDependence()), +- ModifiedType(modified), EquivalentType(equivalent) { ++ TypeAttr(typeAttr), ModifiedType(modified), EquivalentType(equivalent) { + AttributedTypeBits.AttrKind = attrKind; + } + +@@ -4895,6 +4897,8 @@ public: + return static_cast(AttributedTypeBits.AttrKind); + } + ++ bool hasAttr() const { return TypeAttr != nullptr; } ++ const Attr *getAttr() const { return TypeAttr; } + QualType getModifiedType() const { return ModifiedType; } + QualType getEquivalentType() const { return EquivalentType; } + +@@ -4958,6 +4962,13 @@ public: + Profile(ID, getAttrKind(), ModifiedType, EquivalentType); + } + ++ static void Profile(llvm::FoldingSetNodeID &ID, const Attr *typeAttr, ++ QualType modified, QualType equivalent) { ++ ID.AddPointer(typeAttr); ++ ID.AddPointer(modified.getAsOpaquePtr()); ++ ID.AddPointer(equivalent.getAsOpaquePtr()); ++ } ++ + static void Profile(llvm::FoldingSetNodeID &ID, Kind attrKind, + QualType modified, QualType equivalent) { + ID.AddInteger(attrKind); +diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def +index d1cbe4306..4b2240d57 100644 +--- a/clang/include/clang/Basic/LangOptions.def ++++ b/clang/include/clang/Basic/LangOptions.def +@@ -311,6 +311,8 @@ LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math") + BENIGN_LANGOPT(CLNoSignedZero , 1, 0, "Permit Floating Point optimization without regard to signed zeros") + COMPATIBLE_LANGOPT(CLUnsafeMath , 1, 0, "Unsafe Floating Point Math") + COMPATIBLE_LANGOPT(CLFiniteMathOnly , 1, 0, "__FINITE_MATH_ONLY__ predefined macro") ++ ++LANGOPT(UnknownAttrAnnotate, 1, 0, "Unknown attributes are treated as annotation or annotation type attributes during semantic analysis") + /// FP_CONTRACT mode (on/off/fast). + BENIGN_ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contraction type") + COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating point") +diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td +index 652c15afc..64cb09a9a 100644 +--- a/clang/include/clang/Driver/Options.td ++++ b/clang/include/clang/Driver/Options.td +@@ -4377,6 +4377,11 @@ def working_directory : Separate<["-"], "working-directory">, Flags<[CC1Option]> + def working_directory_EQ : Joined<["-"], "working-directory=">, Flags<[CC1Option]>, + Alias; + ++def funknown_attrs_as_annotate : Flag<["-"], "funknown-attrs-as-annotate">, ++ Flags<[CC1Option]>, ++ HelpText<"Treat unknown attributes as annotation or annotation type attributes in semantic analysis">, ++ MarshallingInfoFlag>; ++ + // Double dash options, which are usually an alias for one of the previous + // options. + +diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp +index 8054eb2e1..6fe6badff 100644 +--- a/clang/lib/AST/ASTContext.cpp ++++ b/clang/lib/AST/ASTContext.cpp +@@ -3203,10 +3203,11 @@ QualType ASTContext::getFunctionTypeWithExceptionSpec( + + // Might have a calling-convention attribute. + if (const auto *AT = dyn_cast(Orig)) +- return getAttributedType( +- AT->getAttrKind(), +- getFunctionTypeWithExceptionSpec(AT->getModifiedType(), ESI), +- getFunctionTypeWithExceptionSpec(AT->getEquivalentType(), ESI)); ++ return getAttributedType( ++ AT->getAttrKind(), ++ getFunctionTypeWithExceptionSpec(AT->getModifiedType(), ESI), ++ getFunctionTypeWithExceptionSpec(AT->getEquivalentType(), ESI), ++ AT->getAttr()); + + // Anything else must be a function type. Rebuild it with the new exception + // specification. +@@ -4765,11 +4766,14 @@ QualType ASTContext::getUnresolvedUsingType( + return QualType(newType, 0); + } + +-QualType ASTContext::getAttributedType(attr::Kind attrKind, +- QualType modifiedType, +- QualType equivalentType) const { ++QualType ASTContext::getAttributedType( ++ attr::Kind attrKind, QualType modifiedType, ++ QualType equivalentType, const Attr *typeAttr/* = nullptr */)const { + llvm::FoldingSetNodeID id; +- AttributedType::Profile(id, attrKind, modifiedType, equivalentType); ++ if (typeAttr) ++ AttributedType::Profile(id, typeAttr, modifiedType, equivalentType); ++ else ++ AttributedType::Profile(id, attrKind, modifiedType, equivalentType); + + void *insertPos = nullptr; + AttributedType *type = AttributedTypes.FindNodeOrInsertPos(id, insertPos); +@@ -4777,7 +4781,7 @@ QualType ASTContext::getAttributedType(attr::Kind attrKind, + + QualType canon = getCanonicalType(equivalentType); + type = new (*this, TypeAlignment) +- AttributedType(canon, attrKind, modifiedType, equivalentType); ++ AttributedType(canon, attrKind, modifiedType, equivalentType, typeAttr); + + Types.push_back(type); + AttributedTypes.InsertNode(type, insertPos); +diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp +index 6f367ef05..f6bbaef71 100644 +--- a/clang/lib/AST/ASTImporter.cpp ++++ b/clang/lib/AST/ASTImporter.cpp +@@ -1501,7 +1501,9 @@ ExpectedType ASTNodeImporter::VisitAttributedType(const AttributedType *T) { + return ToEquivalentTypeOrErr.takeError(); + + return Importer.getToContext().getAttributedType(T->getAttrKind(), +- *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr); ++ *ToModifiedTypeOrErr, ++ *ToEquivalentTypeOrErr, ++ T->getAttr()); + } + + ExpectedType ASTNodeImporter::VisitTemplateTypeParmType( +diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp +index 54e62a193..290fe9d5f 100644 +--- a/clang/lib/AST/Type.cpp ++++ b/clang/lib/AST/Type.cpp +@@ -1158,7 +1158,7 @@ public: + return QualType(T, 0); + + return Ctx.getAttributedType(T->getAttrKind(), modifiedType, +- equivalentType); ++ equivalentType, T->getAttr()); + } + + QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) { +@@ -1461,7 +1461,8 @@ struct SubstObjCTypeArgsVisitor + + // Rebuild the attributed type. + return Ctx.getAttributedType(newAttrType->getAttrKind(), +- newAttrType->getModifiedType(), newEquivType); ++ newAttrType->getModifiedType(), newEquivType, ++ newAttrType->getAttr()); + } + }; + +diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp +index 77554aa2c..e5b59cbe3 100644 +--- a/clang/lib/Driver/ToolChains/Clang.cpp ++++ b/clang/lib/Driver/ToolChains/Clang.cpp +@@ -4615,6 +4615,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, + } + } + ++ if (const Arg *A = Args.getLastArg(options::OPT_funknown_attrs_as_annotate)) { ++ CmdArgs.push_back("-funknown-attrs-as-annotate"); ++ A->claim(); ++ } ++ + if (IsOpenMPDevice) { + // We have to pass the triple of the host if compiling for an OpenMP device. + std::string NormalizedTriple = +diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp +index 227c1df2b..4d13a9b6a 100644 +--- a/clang/lib/Parse/ParseDeclCXX.cpp ++++ b/clang/lib/Parse/ParseDeclCXX.cpp +@@ -4368,18 +4368,22 @@ bool Parser::ParseCXX11AttributeArgs( + Syntax = ParsedAttr::AS_Microsoft; + } + ++ + // If the attribute isn't known, we will not attempt to parse any +- // arguments. +- if (Syntax != ParsedAttr::AS_Microsoft && +- !hasAttribute(LO.CPlusPlus ? AttributeCommonInfo::Syntax::AS_CXX11 +- : AttributeCommonInfo::Syntax::AS_C2x, +- ScopeName, AttrName, getTargetInfo(), getLangOpts())) { +- if (getLangOpts().MicrosoftExt || getLangOpts().HLSL) { ++ // arguments. Unless we are treating unknown attributes as annotation ++ // attributes. ++ if (!getLangOpts().UnknownAttrAnnotate) { ++ if (Syntax != ParsedAttr::AS_Microsoft && ++ !hasAttribute(LO.CPlusPlus ? AttributeCommonInfo::Syntax::AS_CXX11 ++ : AttributeCommonInfo::Syntax::AS_C2x, ++ ScopeName, AttrName, getTargetInfo(), getLangOpts())) { ++ if (getLangOpts().MicrosoftExt || getLangOpts().HLSL) { ++ } ++ // Eat the left paren, then skip to the ending right paren. ++ ConsumeParen(); ++ SkipUntil(tok::r_paren); ++ return false; + } +- // Eat the left paren, then skip to the ending right paren. +- ConsumeParen(); +- SkipUntil(tok::r_paren); +- return false; + } + + if (ScopeName && (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"))) { +diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp +index a303c7f57..228b54a61 100644 +--- a/clang/lib/Sema/SemaDeclAttr.cpp ++++ b/clang/lib/Sema/SemaDeclAttr.cpp +@@ -4285,6 +4285,21 @@ static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + S.AddAnnotationAttr(D, AL, Str, Args); + } + ++static void ++handleUnknownAttrAsAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { ++ // Get name of unknown attribute: ++ StringRef Str = AL.getAttrName()->getName(); ++ ++ llvm::SmallVector Args; ++ Args.reserve(AL.getNumArgs()); ++ for (unsigned Idx = 0; Idx < AL.getNumArgs(); Idx++) { ++ assert(!AL.isArgIdent(Idx)); ++ Args.push_back(AL.getArgAsExpr(Idx)); ++ } ++ ++ S.AddAnnotationAttr(D, AL, Str, Args); ++} ++ + static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + S.AddAlignValueAttr(D, AL, AL.getArgAsExpr(0)); + } +@@ -8594,11 +8609,15 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, + // though they were unknown attributes. + if (AL.getKind() == ParsedAttr::UnknownAttribute || + !AL.existsInTarget(S.Context.getTargetInfo())) { +- S.Diag(AL.getLoc(), +- AL.isDeclspecAttribute() ++ if (S.getLangOpts().UnknownAttrAnnotate) { ++ handleUnknownAttrAsAnnotateAttr(S, D, AL); ++ } else { ++ S.Diag(AL.getLoc(), ++ AL.isDeclspecAttribute() + ? (unsigned)diag::warn_unhandled_ms_attribute_ignored + : (unsigned)diag::warn_unknown_attribute_ignored) +- << AL << AL.getRange(); ++ << AL << AL.getRange(); ++ } + return; + } + +diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp +index 8cb1ed28f..7e60f4bce 100644 +--- a/clang/lib/Sema/SemaType.cpp ++++ b/clang/lib/Sema/SemaType.cpp +@@ -257,7 +257,8 @@ namespace { + QualType getAttributedType(Attr *A, QualType ModifiedType, + QualType EquivType) { + QualType T = +- sema.Context.getAttributedType(A->getKind(), ModifiedType, EquivType); ++ sema.Context.getAttributedType(A->getKind(), ModifiedType, EquivType, ++ A); + AttrsForTypes.push_back({cast(T.getTypePtr()), A}); + AttrsForTypesSorted = false; + return T; +@@ -8287,6 +8288,24 @@ static void HandleMatrixTypeAttr(QualType &CurType, const ParsedAttr &Attr, + CurType = T; + } + ++static void HandleUnkownTypeAttrAsAnnotateTypeAttr(TypeProcessingState &State, ++ QualType &CurType, const ParsedAttr &PA) { ++ Sema &S = State.getSema(); ++ StringRef Str = PA.getAttrName()->getName(); ++ ++ llvm::SmallVector Args; ++ Args.reserve(PA.getNumArgs()); ++ for (unsigned Idx = 0; Idx < PA.getNumArgs(); Idx++) { ++ assert(!PA.isArgIdent(Idx)); ++ Args.push_back(PA.getArgAsExpr(Idx)); ++ } ++ if (!S.ConstantFoldAttrArgs(PA, Args)) ++ return; ++ auto *AnnotateTypeAttr = ++ AnnotateTypeAttr::Create(S.Context, Str, Args.data(), Args.size(), PA); ++ CurType = State.getAttributedType(AnnotateTypeAttr, CurType, CurType); ++} ++ + static void HandleAnnotateTypeAttr(TypeProcessingState &State, + QualType &CurType, const ParsedAttr &PA) { + Sema &S = State.getSema(); +@@ -8390,12 +8409,17 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, + + case ParsedAttr::UnknownAttribute: + if (attr.isStandardAttributeSyntax()) { +- state.getSema().Diag(attr.getLoc(), +- diag::warn_unknown_attribute_ignored) +- << attr << attr.getRange(); +- // Mark the attribute as invalid so we don't emit the same diagnostic +- // multiple times. +- attr.setInvalid(); ++ if (state.getSema().getLangOpts().UnknownAttrAnnotate) { ++ HandleUnkownTypeAttrAsAnnotateTypeAttr(state, type, attr); ++ attr.setUsedAsTypeAttr(); ++ } else { ++ state.getSema().Diag(attr.getLoc(), ++ diag::warn_unknown_attribute_ignored) ++ << attr << attr.getRange(); ++ // Mark the attribute as invalid so we don't emit the same diagnostic ++ // multiple times. ++ attr.setInvalid(); ++ } + } + break; + +diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h +index 4244bbc1e..fbfff5404 100644 +--- a/clang/lib/Sema/TreeTransform.h ++++ b/clang/lib/Sema/TreeTransform.h +@@ -6995,9 +6995,8 @@ QualType TreeTransform::TransformAttributedType( + } + } + +- result = SemaRef.Context.getAttributedType(TL.getAttrKind(), +- modifiedType, +- equivalentType); ++ result = SemaRef.Context.getAttributedType(TL.getAttrKind(), modifiedType, ++ equivalentType, TL.getAttr()); + } + + AttributedTypeLoc newTL = TLB.push(result); +-- +2.34.1 + diff --git a/ports/llvm-16/portfile.cmake b/ports/llvm-16/portfile.cmake index 2cc0fac4..7b5cf4f3 100644 --- a/ports/llvm-16/portfile.cmake +++ b/ports/llvm-16/portfile.cmake @@ -23,8 +23,8 @@ if("pasta" IN_LIST FEATURES) SOURCE_PATH "${SOURCE_PATH}" PATCHES 0025-PASTA-patches.patch - 0027-unknown-attrs-as-annotations.patch 0028-Fixes-to-clang-s-tablegen-of-attributes.patch + 0030-UnknownAttrsAsAnnotate-and-AttributedType-Attrs.patch ) endif() diff --git a/ports/remill/portfile.cmake b/ports/remill/portfile.cmake new file mode 100644 index 00000000..f7f9901d --- /dev/null +++ b/ports/remill/portfile.cmake @@ -0,0 +1,37 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO lifting-bits/remill + REF 2c41ce9dd16d46139634ce340410bddec77920b4 + SHA512 0c8d5bd8bd291adb9ea369574fee7a8a3629e12030270da77f541d1d8b531ce1305d061616c582ec734ee8ee7ba917ab0e3a1e688204aab4b486360fb5adb814 + HEAD_REF vcpkg-manifest-llvm-16 +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DUSE_SYSTEM_DEPENDENCIES=ON +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup( + PACKAGE_NAME "remill" + CONFIG_PATH lib/cmake/remill +) + +file( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" ) +file( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share" ) + +if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" ) + file( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin" ) +endif() + +file( + INSTALL "${SOURCE_PATH}/LICENSE" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" + RENAME copyright +) + +file( + INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" +) diff --git a/ports/remill/usage b/ports/remill/usage new file mode 100644 index 00000000..7185e4e6 --- /dev/null +++ b/ports/remill/usage @@ -0,0 +1,4 @@ +The package remill provides CMake targets: + + find_package(remill CONFIG REQUIRED) + target_link_libraries(main PRIVATE remill) diff --git a/ports/remill/vcpkg.json b/ports/remill/vcpkg.json new file mode 100644 index 00000000..28f728ea --- /dev/null +++ b/ports/remill/vcpkg.json @@ -0,0 +1,40 @@ +{ + "name": "remill", + "version": "5.0.7", + "description": "A static binary translator.", + "homepage": "https://github.com/lifting-bits/remill", + "license": "Apache-2.0", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "glog", + "gflags", + "gtest", + "zlib", + "xed" + ], + "default-features": [ + "cxx-common-llvm-16" + ], + "features": { + "system-llvm": { + "description": "Build with system llvm" + }, + "cxx-common-llvm-16": { + "description": "Build with cxx-common llvm-16 port", + "dependencies": [ + { + "name": "llvm-16", + "default-features": false, + "features": [ "cxx-common-targets" ] + } + ] + } + } +} diff --git a/rellic b/rellic index c516dccb..6226304d 160000 --- a/rellic +++ b/rellic @@ -1 +1 @@ -Subproject commit c516dccbc4f338ab4ad30a268da7e241ae9ebb13 +Subproject commit 6226304d78a142f61fa2866533383f111f9e8913 diff --git a/remill b/remill index 396e228e..a6abbb81 160000 --- a/remill +++ b/remill @@ -1 +1 @@ -Subproject commit 396e228e934bfa2536105927950fb80c19c518c9 +Subproject commit a6abbb818c3c523dfb806cf4e8a0211f3a8d56e4 diff --git a/vcpkg_info.txt b/vcpkg_info.txt index ff35e44a..53a4246e 100644 --- a/vcpkg_info.txt +++ b/vcpkg_info.txt @@ -1,2 +1,2 @@ https://github.com/trail-of-forks/vcpkg.git -fix-cross-compile-linux +cxx-common