From 388de5bbcbd8a0f8cb84eaf992b7a5c84e286f62 Mon Sep 17 00:00:00 2001 From: Kait Lam <39479354+katrinafyi@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:46:18 +1000 Subject: [PATCH 01/30] ci: add macos-latest (cherry picked from commit 95fe5c1a0e2da1ea3a7f096659d6cb60aaaab9c5) --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee4271e..4395c05 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,8 @@ jobs: planter, aslp_web, godbolt ] - runs-on: ubuntu-latest + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} defaults: run: { shell: "bash -ex -o pipefail {0}" } From ed9097e4c058d2797eaf8f7cf71ca4dae12e5d99 Mon Sep 17 00:00:00 2001 From: rina Date: Mon, 30 Sep 2024 11:51:01 +1000 Subject: [PATCH 02/30] switch ordering --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4395c05..ced5748 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,7 @@ jobs: strategy: fail-fast: false matrix: + os: [ubuntu-latest, macos-latest] # end-user packages to ci build for cache pkg: [aslp, bap-aslp, bap-primus, basil, @@ -36,7 +37,6 @@ jobs: planter, aslp_web, godbolt ] - os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} defaults: From 55d45acec479665a42ac417a4b0e2ad15912a161 Mon Sep 17 00:00:00 2001 From: rina Date: Mon, 30 Sep 2024 12:06:05 +1000 Subject: [PATCH 03/30] nix build with -L --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ced5748..20d545a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,7 +72,7 @@ jobs: echo NIXPKGS_ALLOW_BROKEN="$("$broken" && echo 1 || echo 0)" > "$GITHUB_ENV" id: broken - - run: ./nix-cached.sh build --impure .#${{matrix.pkg}} + - run: ./nix-cached.sh build --impure -L .#${{matrix.pkg}} id: build continue-on-error: ${{ fromJSON(steps.broken.outputs.bool) }} @@ -81,7 +81,7 @@ jobs: run: | for test in $(nix eval --impure .#${{matrix.pkg}}.tests --json | jq -r keys[]); do t=.#${{matrix.pkg}}.tests.$test - ./nix-cached.sh build --impure "$t" --no-link + ./nix-cached.sh build --impure -L "$t" --no-link done continue-on-error: ${{ fromJSON(steps.broken.outputs.bool) }} if: steps.build.outcome == 'success' From 91ae79341ccc95126349093ee498dddbf2d1c778 Mon Sep 17 00:00:00 2001 From: rina Date: Mon, 30 Sep 2024 14:56:24 +1000 Subject: [PATCH 04/30] gtirb: disable clang-tidy to fix darwin build --- gtirb/gtirb.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gtirb/gtirb.nix b/gtirb/gtirb.nix index e7a6db8..23162d4 100644 --- a/gtirb/gtirb.nix +++ b/gtirb/gtirb.nix @@ -23,7 +23,12 @@ stdenv.mkDerivation { buildInputs = [ cmake python3 boost doxygen ]; propagatedBuildInputs = [ protobuf ]; - cmakeFlags = [ "-DGTIRB_ENABLE_TESTS=OFF" "-DGTIRB_PY_API=ON" ]; + cmakeFlags = [ + "-DGTIRB_ENABLE_TESTS=OFF" + "-DGTIRB_PY_API=ON" + "-DGTIRB_RUN_CLANG_TIDY=OFF" + # "-DCLANG_TIDY_EXE=${lib.getExe' clang-tools "clang-tidy"}" + ]; CXXFLAGS = "-includeset -Wno-error=unused-result -Wno-error=array-bounds"; preConfigure = '' From 4585b153b6396ccdc2ab17dba5e97b4f60d47b59 Mon Sep 17 00:00:00 2001 From: Nicholas Coughlin Date: Tue, 1 Oct 2024 14:40:49 +1000 Subject: [PATCH 05/30] Fixes for macOS --- aslp/ocaml_z3.nix | 41 +++++++++++++++++ aslp/overlay.nix | 3 +- basil/0001-basil-protoc-version.patch | 20 +++++++++ basil/basil.nix | 10 ++++- ...1-ddisasm-disable-concurrent-souffle.patch | 44 +++++++++++++++++++ gtirb/0001-gtirb-link-absl.patch | 26 +++++++++++ gtirb/0001-gtirb_pprinter-include-map.patch | 12 +++++ gtirb/ddisasm.nix | 1 + gtirb/gtirb-pprinter.nix | 1 + gtirb/gtirb.nix | 1 + 10 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 aslp/ocaml_z3.nix create mode 100644 basil/0001-basil-protoc-version.patch create mode 100644 gtirb/0001-ddisasm-disable-concurrent-souffle.patch create mode 100644 gtirb/0001-gtirb-link-absl.patch create mode 100644 gtirb/0001-gtirb_pprinter-include-map.patch diff --git a/aslp/ocaml_z3.nix b/aslp/ocaml_z3.nix new file mode 100644 index 0000000..28bd8a8 --- /dev/null +++ b/aslp/ocaml_z3.nix @@ -0,0 +1,41 @@ +{ stdenv, lib, ocaml, findlib, zarith, z3 }: + +if lib.versionOlder ocaml.version "4.07" +then throw "z3 is not available for OCaml ${ocaml.version}" +else + +let z3-with-ocaml1 = z3.override { + ocamlBindings = true; + inherit ocaml findlib zarith; +}; in + +let z3-with-ocaml = z3-with-ocaml1.overrideAttrs (p: { + postInstall = p.postInstall + '' + ln -sf $lib/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary} $OCAMLFIND_DESTDIR/stublibs/libz3${stdenv.hostPlatform.extensions.sharedLibrary} + ''; +}); in + +stdenv.mkDerivation { + + pname = "ocaml${ocaml.version}-z3"; + inherit (z3-with-ocaml) version; + + dontUnpack = true; + + installPhase = '' + runHook preInstall + mkdir -p $OCAMLFIND_DESTDIR + cp -r ${z3-with-ocaml.ocaml}/lib/ocaml/${ocaml.version}/site-lib/stublibs $OCAMLFIND_DESTDIR + cp -r ${z3-with-ocaml.ocaml}/lib/ocaml/${ocaml.version}/site-lib/Z3 $OCAMLFIND_DESTDIR/z3 + runHook postInstall + ''; + + nativeBuildInputs = [ findlib ]; + propagatedBuildInputs = [ zarith ]; + + strictDeps = true; + + meta = z3.meta // { + description = "Z3 Theorem Prover (OCaml API)"; + }; +} diff --git a/aslp/overlay.nix b/aslp/overlay.nix index c871bed..3a54bc9 100644 --- a/aslp/overlay.nix +++ b/aslp/overlay.nix @@ -7,8 +7,9 @@ final: prev: inherit (final.ocamlPackages_pac_5) aslp_web; overlay_ocamlPackages = ofinal: oprev: { + ocaml_z3 = final.callPackage ./ocaml_z3.nix { findlib = ofinal.findlib ; zarith = ofinal.zarith ; ocaml = ofinal.ocaml ; }; - asli = ofinal.callPackage ./asli.nix { inherit (final) z3; ocaml_z3 = ofinal.z3; }; + asli = ofinal.callPackage ./asli.nix { inherit (final) z3; ocaml_z3 = ofinal.ocaml_z3; }; aslp = ofinal.asli; # .overrideAttrs { src = prev.lib.cleanSource ~/progs/aslp; } diff --git a/basil/0001-basil-protoc-version.patch b/basil/0001-basil-protoc-version.patch new file mode 100644 index 0000000..db93ee6 --- /dev/null +++ b/basil/0001-basil-protoc-version.patch @@ -0,0 +1,20 @@ +diff --git a/build.sbt b/build.sbt +index f1e6339f..2d9ede97 100644 +--- a/build.sbt ++++ b/build.sbt +@@ -31,6 +31,8 @@ lazy val root = project + + scalacOptions ++= Seq("-deprecation", "-feature") + ++PB.protocExecutable := file("PROTOC_PLACEHOLDER") ++ + Compile / PB.targets := Seq( + scalapb.gen() -> (Compile / sourceManaged).value / "scalapb" + ) +@@ -132,4 +134,4 @@ def filesContentEqual(path1: File, path2: File): Boolean = { + source1.close + source2.close + true +-} +\ No newline at end of file ++} diff --git a/basil/basil.nix b/basil/basil.nix index cadbff4..4eda940 100644 --- a/basil/basil.nix +++ b/basil/basil.nix @@ -6,6 +6,7 @@ , jre , testers , basil +, protobuf }: mkSbtDerivation { @@ -21,7 +22,14 @@ mkSbtDerivation { sha256 = "sha256-juCX3X8KRGLIUqhNcGHUb/nRv09xhWs5cv/wbAs8wmM="; }; - depsSha256 = "sha256-++gg+SKskDyaqHowNG2RPS7evuCzPYvvXMC4Rkp7b6U="; + patches = [ ./0001-basil-protoc-version.patch ] ; + + preConfigure = '' + substituteInPlace build.sbt \ + --replace 'PROTOC_PLACEHOLDER' '${protobuf}/bin/protoc' + ''; + + depsSha256 = "sha256-Cyz4kpyZ3KlUo0JmQzvgptSQMErC5G4e8Mp0dWJMaMY"; buildPhase = '' javac -version diff --git a/gtirb/0001-ddisasm-disable-concurrent-souffle.patch b/gtirb/0001-ddisasm-disable-concurrent-souffle.patch new file mode 100644 index 0000000..b93dcff --- /dev/null +++ b/gtirb/0001-ddisasm-disable-concurrent-souffle.patch @@ -0,0 +1,44 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 1db64e22..b1fd4848 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -178,7 +178,7 @@ function(GENERATE_ARCH_CPP_SINGLE) + OUTPUT "${PARAM_PATH}.cpp" + WORKING_DIRECTORY "${SOUFFLE_DATALOG_DIR}" + COMMAND +- ${SOUFFLE} main.dl -g "${CMAKE_BINARY_DIR}/src/${PARAM_PATH}.cpp" -jauto ++ ${SOUFFLE} main.dl -g "${CMAKE_BINARY_DIR}/src/${PARAM_PATH}.cpp" + -MARCH_${PARAM_MARCH} ${SOUFFLE_PREPROCESSOR_ARG} ${SOUFFLE_PROFILING_ARG} + -N ddisasm_${ARCH} + DEPENDS ${DATALOG_BASE_SOURCES} ${PARAM_DATALOG_SOURCES}) +@@ -203,7 +203,7 @@ function(GENERATE_ARCH_CPP_MANY) + # Generate CPP code + execute_process( + COMMAND +- ${SOUFFLE} main.dl -G ${STAGING_PATH} -jauto -MARCH_${PARAM_MARCH} ++ ${SOUFFLE} main.dl -G ${STAGING_PATH} -MARCH_${PARAM_MARCH} + ${SOUFFLE_PREPROCESSOR_ARG} ${SOUFFLE_PROFILING_ARG} -N ddisasm_${ARCH} + WORKING_DIRECTORY "${SOUFFLE_DATALOG_DIR}") + +diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt +index aa20b7d0..ad89a198 100644 +--- a/src/passes/CMakeLists.txt ++++ b/src/passes/CMakeLists.txt +@@ -70,7 +70,7 @@ add_custom_command( + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/passes" + COMMAND + ${SOUFFLE} ${NO_RETURN_DATALOG_MAIN} -g souffle_no_return.cpp -N +- souffle_no_return -jauto ${SOUFFLE_PREPROCESSOR_ARG} ++ souffle_no_return ${SOUFFLE_PREPROCESSOR_ARG} + DEPENDS ${NO_RETURN_DATALOG_SOURCES}) + + add_library(no_return_pass STATIC NoReturnPass.cpp ${NO_RETURN_CPP}) +@@ -114,7 +114,7 @@ add_custom_command( + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/passes" + COMMAND + ${SOUFFLE} ${FUNCTION_INFERENCE_DATALOG_MAIN} -g +- souffle_function_inference.cpp -N souffle_function_inference -jauto ++ souffle_function_inference.cpp -N souffle_function_inference + ${SOUFFLE_PREPROCESSOR_ARG} + DEPENDS ${FUNCTION_INFERENCE_DATALOG_SOURCES}) + diff --git a/gtirb/0001-gtirb-link-absl.patch b/gtirb/0001-gtirb-link-absl.patch new file mode 100644 index 0000000..ade3bd0 --- /dev/null +++ b/gtirb/0001-gtirb-link-absl.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e176b6a7..929cd452 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -432,6 +432,7 @@ if(CL_API) + else() + find_package(Protobuf 3.0.0 REQUIRED) + endif() ++find_package( absl REQUIRED ) + + if(Protobuf_VERSION VERSION_LESS 3.2) + add_definitions(-DPROTOBUF_SET_BYTES_LIMIT) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 85558737..542065cd 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -140,6 +140,9 @@ target_link_libraries( + # Link in this static lib, but don't make it a transitive dependency of + # TestGTIRB, etc + PRIVATE gtirb_proto ++ absl::log_internal_message ++ absl::log_internal_check_op ++ absl::status + ) + target_compile_definitions( + ${PROJECT_NAME} PRIVATE GTIRB_${PROJECT_NAME}_EXPORTS diff --git a/gtirb/0001-gtirb_pprinter-include-map.patch b/gtirb/0001-gtirb_pprinter-include-map.patch new file mode 100644 index 0000000..3697141 --- /dev/null +++ b/gtirb/0001-gtirb_pprinter-include-map.patch @@ -0,0 +1,12 @@ +diff --git a/src/gtirb_pprinter/driver/parser.hpp b/src/gtirb_pprinter/driver/parser.hpp +index 2eca4fb..0741103 100644 +--- a/src/gtirb_pprinter/driver/parser.hpp ++++ b/src/gtirb_pprinter/driver/parser.hpp +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + + namespace fs = boost::filesystem; + diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index e93cdaf..5055e08 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -28,6 +28,7 @@ stdenv.mkDerivation { rev = "9edfe9fe86910ef946de1db7a7ac41ce86bc31d0"; hash = "sha256-xFW6J3jCCMtUqT25/zVfjjy5o3MoX1HXxIlRhjM6s8A="; }; + patches = if stdenv.isDarwin then [ ./0001-ddisasm-disable-concurrent-souffle.patch ] else []; buildInputs = [ cmake boost lief gtirb gtirb-pprinter libehp ]; nativeBuildInputs = [ capstone-grammatech souffle ]; diff --git a/gtirb/gtirb-pprinter.nix b/gtirb/gtirb-pprinter.nix index 5ca1880..808e266 100644 --- a/gtirb/gtirb-pprinter.nix +++ b/gtirb/gtirb-pprinter.nix @@ -21,6 +21,7 @@ stdenv.mkDerivation { rev = "v2.1.0"; hash = "sha256-zgYq6FKxaJ6vLzvOTCfOU4ZUyXvMuFc3abNrqg8NADc="; }; + patches = [ ./0001-gtirb_pprinter-include-map.patch ]; buildInputs = [ cmake python3 gtirb boost abseil-cpp gtest ]; nativeBuildInputs = [ capstone-grammatech ]; diff --git a/gtirb/gtirb.nix b/gtirb/gtirb.nix index 23162d4..412ae36 100644 --- a/gtirb/gtirb.nix +++ b/gtirb/gtirb.nix @@ -18,6 +18,7 @@ stdenv.mkDerivation { rev = "v2.0.0"; hash = "sha256-ueoqxm6iXv4JgzR/xkImT+O8xx+7bA2upx1TJ828LLA="; }; + patches = if stdenv.isDarwin then [ ./0001-gtirb-link-absl.patch ] else []; nativeBuildInputs = [ ]; buildInputs = [ cmake python3 boost doxygen ]; From 70740d861943d878c0857177caf1ce99968e45d8 Mon Sep 17 00:00:00 2001 From: Nicholas Coughlin Date: Thu, 3 Oct 2024 09:07:18 +1000 Subject: [PATCH 06/30] Fix gtirb python package --- basil/0001-basil-protoc-version.patch | 7 ------- gtirb/gtirb.nix | 3 +++ gtirb/python-gtirb.nix | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/basil/0001-basil-protoc-version.patch b/basil/0001-basil-protoc-version.patch index db93ee6..67cc3f8 100644 --- a/basil/0001-basil-protoc-version.patch +++ b/basil/0001-basil-protoc-version.patch @@ -11,10 +11,3 @@ index f1e6339f..2d9ede97 100644 Compile / PB.targets := Seq( scalapb.gen() -> (Compile / sourceManaged).value / "scalapb" ) -@@ -132,4 +134,4 @@ def filesContentEqual(path1: File, path2: File): Boolean = { - source1.close - source2.close - true --} -\ No newline at end of file -+} diff --git a/gtirb/gtirb.nix b/gtirb/gtirb.nix index 412ae36..4349d37 100644 --- a/gtirb/gtirb.nix +++ b/gtirb/gtirb.nix @@ -39,6 +39,9 @@ stdenv.mkDerivation { substituteInPlace src/CMakeLists.txt src/gtirb/proto/CMakeLists.txt \ --replace 'DESTINATION lib' 'DESTINATION ''${CMAKE_INSTALL_LIBDIR}' \ --replace 'DESTINATION include' 'DESTINATION ''${CMAKE_INSTALL_INCLUDEDIR}' + + substituteInPlace python/setup.py.in \ + --replace '@CMAKE_SOURCE_DIR@' $python ''; postInstall = '' diff --git a/gtirb/python-gtirb.nix b/gtirb/python-gtirb.nix index 2214a17..af3e85a 100644 --- a/gtirb/python-gtirb.nix +++ b/gtirb/python-gtirb.nix @@ -12,9 +12,7 @@ python3Packages.buildPythonPackage { propagatedBuildInputs = with python3Packages; [ networkx typing-extensions sortedcontainers intervaltree protobuf3 ]; preConfigure = '' - ln -s /build/gtirb* /build/source cd python - substituteInPlace setup.py \ --replace 'protobuf<=3.20.1' 'protobuf' ''; From 302dd59b05957c8904d2123a8ec9b9ddb2bcb945 Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 3 Oct 2024 11:18:03 +1000 Subject: [PATCH 07/30] basil: fix protoc substitution in dependency derivation also fixes up some nix noob mistakes --- basil/basil.nix | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/basil/basil.nix b/basil/basil.nix index 4eda940..8719cbd 100644 --- a/basil/basil.nix +++ b/basil/basil.nix @@ -9,6 +9,12 @@ , protobuf }: +let + replaceProtocPlaceholder = '' + substituteInPlace build.sbt \ + --replace-fail 'PROTOC_PLACEHOLDER' '${lib.getExe protobuf}' + ''; +in mkSbtDerivation { pname = "basil"; version = "0.1.2-alpha-unstable-2024-09-24"; @@ -24,19 +30,27 @@ mkSbtDerivation { patches = [ ./0001-basil-protoc-version.patch ] ; - preConfigure = '' - substituteInPlace build.sbt \ - --replace 'PROTOC_PLACEHOLDER' '${protobuf}/bin/protoc' - ''; + # we must run the command in both the main derivation + # and the dependency-generating derivation. + overrideDepsAttrs = depsfinal: depsprev: { + postPatch = replaceProtocPlaceholder; + }; + postPatch = replaceProtocPlaceholder; - depsSha256 = "sha256-Cyz4kpyZ3KlUo0JmQzvgptSQMErC5G4e8Mp0dWJMaMY"; + depsSha256 = "sha256-tDJuleKVLMPCZNJGNxokuScDOU4siLQEmM1FZff+5oM="; buildPhase = '' + runHook preBuild + javac -version sbt assembly + + runHook postBuild ''; installPhase = '' + runHook preInstall + mkdir -p $out/bin mkdir -p $out/share/basil @@ -55,6 +69,8 @@ mkSbtDerivation { makeWrapper "${lib.getExe jre}" $out/bin/basil \ --add-flags -jar \ --add-flags "$out/share/basil/$(basename $JAR)" + + runHook postInstall ''; meta = { From 17c485de59116124dccb56d0d87e5f630d76974d Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 3 Oct 2024 13:33:17 +1000 Subject: [PATCH 08/30] ddisasm: use aarch64-unknown-linux-gnu-gcc in test --- gtirb/ddisasm.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index 5055e08..70bfeec 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -12,7 +12,7 @@ , ddisasm , makeWrapper , runCommand -, runCommandCC +, gcc-aarch64 , unrandom , testers , jq @@ -53,13 +53,13 @@ stdenv.mkDerivation { version = "Disassemble"; }; - passthru.tests.ddisasm-deterministic = runCommandCC + passthru.tests.ddisasm-deterministic = runCommand "ddisasm-deterministic-test" - { nativeBuildInputs = [ ddisasm.deterministic jq ]; } + { nativeBuildInputs = [ ddisasm.deterministic jq gcc-aarch64 ]; } '' mkdir -p $out && cd $out echo 'int main(void) { return 0; }' > a.c - $CC a.c + aarch64-unknown-linux-gnu-gcc a.c ddisasm-deterministic a.out --json | jq -S > a1 ddisasm-deterministic a.out --json | jq -S > a2 diff -q a1 a2 From 2ae10af1860fa415e959434f72b5cf985ae90f58 Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 3 Oct 2024 14:37:26 +1000 Subject: [PATCH 09/30] ddisasm: use clang-aarch64 in test --- gtirb/ddisasm.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index 70bfeec..3173860 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -12,7 +12,7 @@ , ddisasm , makeWrapper , runCommand -, gcc-aarch64 +, clang-aarch64 , unrandom , testers , jq @@ -55,11 +55,11 @@ stdenv.mkDerivation { passthru.tests.ddisasm-deterministic = runCommand "ddisasm-deterministic-test" - { nativeBuildInputs = [ ddisasm.deterministic jq gcc-aarch64 ]; } + { nativeBuildInputs = [ ddisasm.deterministic jq clang-aarch64 ]; } '' mkdir -p $out && cd $out echo 'int main(void) { return 0; }' > a.c - aarch64-unknown-linux-gnu-gcc a.c + aarch64-unknown-linux-gnu-cc a.c ddisasm-deterministic a.out --json | jq -S > a1 ddisasm-deterministic a.out --json | jq -S > a2 diff -q a1 a2 From 7d6f339d4eadec6ef49afcb912ea3106463b499d Mon Sep 17 00:00:00 2001 From: Nicholas Coughlin Date: Tue, 8 Oct 2024 20:23:04 +1000 Subject: [PATCH 10/30] More macOS fixes gtirb: Proper fix for abseil linking aslp-cpp: Build with clang 17 on macOS alive2-regehr: Disable 'no-error=maybe-uninitialized' option on macOS alive2: Build with clang 17 on macOS llvm-custom: Fix hardcoded /build path to $NIX_BUILD_TOP ocaml-llvm: Bump ctypes-foreign to 0.23.0 to build on macOS --- aslp/aslp-cpp.nix | 6 +++- gtirb/0001-gtirb-link-absl.patch | 47 +++++++++++++++++-------------- llvm-translator/alive2-regehr.nix | 3 +- llvm-translator/alive2.nix | 6 +++- llvm-translator/llvm-custom.nix | 2 +- overlay.nix | 24 ++++++++++++++-- 6 files changed, 61 insertions(+), 27 deletions(-) diff --git a/aslp/aslp-cpp.nix b/aslp/aslp-cpp.nix index 3b8fe6a..461491f 100644 --- a/aslp/aslp-cpp.nix +++ b/aslp/aslp-cpp.nix @@ -1,9 +1,13 @@ { stdenv , cmake , asli +, overrideCC +, llvmPackages_17 }: -stdenv.mkDerivation { +let buildStdenv = if stdenv.isDarwin then overrideCC stdenv llvmPackages_17.clang else stdenv; in + +buildStdenv.mkDerivation { pname = "aslp-cpp"; version = asli.version; diff --git a/gtirb/0001-gtirb-link-absl.patch b/gtirb/0001-gtirb-link-absl.patch index ade3bd0..07aec66 100644 --- a/gtirb/0001-gtirb-link-absl.patch +++ b/gtirb/0001-gtirb-link-absl.patch @@ -1,26 +1,31 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index e176b6a7..929cd452 100644 +index e176b6a7..1c03fe8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -432,6 +432,7 @@ if(CL_API) - else() - find_package(Protobuf 3.0.0 REQUIRED) - endif() -+find_package( absl REQUIRED ) - +@@ -427,11 +427,8 @@ endif() + # --------------------------------------------------------------------------- + # protobuf + # --------------------------------------------------------------------------- +-if(CL_API) +- find_package(Protobuf 3.7.0 REQUIRED) +-else() +- find_package(Protobuf 3.0.0 REQUIRED) +-endif() ++set(protobuf_MODULE_COMPATIBLE TRUE CACHE BOOL "") ++find_package(Protobuf REQUIRED CONFIG) + if(Protobuf_VERSION VERSION_LESS 3.2) add_definitions(-DPROTOBUF_SET_BYTES_LIMIT) -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 85558737..542065cd 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -140,6 +140,9 @@ target_link_libraries( - # Link in this static lib, but don't make it a transitive dependency of - # TestGTIRB, etc - PRIVATE gtirb_proto -+ absl::log_internal_message -+ absl::log_internal_check_op -+ absl::status - ) - target_compile_definitions( - ${PROJECT_NAME} PRIVATE GTIRB_${PROJECT_NAME}_EXPORTS +diff --git a/src/gtirb/proto/CMakeLists.txt b/src/gtirb/proto/CMakeLists.txt +index 74cf20a9..d53a8bd0 100644 +--- a/src/gtirb/proto/CMakeLists.txt ++++ b/src/gtirb/proto/CMakeLists.txt +@@ -45,7 +45,7 @@ endforeach(PROTO_H) + # Add proto library target + add_library(gtirb_proto STATIC ${PROTO_CPP_SOURCES} ${PROTO_COPIED_HEADERS}) + +-target_link_libraries(gtirb_proto ${Boost_LIBRARIES} ${Protobuf_LIBRARIES}) ++target_link_libraries(gtirb_proto ${Boost_LIBRARIES} protobuf::libprotobuf) + + target_compile_definitions(gtirb_proto PRIVATE GTIRB_${PROJECT_NAME}_EXPORTS) + diff --git a/llvm-translator/alive2-regehr.nix b/llvm-translator/alive2-regehr.nix index 0247fe4..192f477 100644 --- a/llvm-translator/alive2-regehr.nix +++ b/llvm-translator/alive2-regehr.nix @@ -1,4 +1,5 @@ { alive2 +, stdenv , llvmPackages , fetchFromGitHub }: @@ -15,5 +16,5 @@ }; patches = [ ]; - CXXFLAGS = prev.CXXFLAGS or "" + " -Wno-error=maybe-uninitialized"; + CXXFLAGS = prev.CXXFLAGS or "" + (if stdenv.isDarwin then "" else " -Wno-error=maybe-uninitialized"); }) diff --git a/llvm-translator/alive2.nix b/llvm-translator/alive2.nix index e1df3db..b6e4586 100644 --- a/llvm-translator/alive2.nix +++ b/llvm-translator/alive2.nix @@ -12,9 +12,13 @@ , clang , llvmPackages , git-am-shim +, overrideCC +, llvmPackages_17 }: -stdenv.mkDerivation { +let buildStdenv = if stdenv.isDarwin then overrideCC stdenv llvmPackages_17.clang else stdenv; in + +buildStdenv.mkDerivation { pname = "alive2"; version = "2022-10-26"; diff --git a/llvm-translator/llvm-custom.nix b/llvm-translator/llvm-custom.nix index 894edf1..6511355 100644 --- a/llvm-translator/llvm-custom.nix +++ b/llvm-translator/llvm-custom.nix @@ -16,7 +16,7 @@ let # install Target .inc files from build directory for lifter project. postFixup = '' - cd /build/$sourceRoot/build/lib && file Target + cd $NIX_BUILD_TOP/$sourceRoot/build/lib && file Target find Target -name '*.inc' -print0 \ | xargs -0 -I{} cp -v --no-clobber --parents {} $dev/include ''; diff --git a/overlay.nix b/overlay.nix index 394f05e..0b53156 100644 --- a/overlay.nix +++ b/overlay.nix @@ -13,8 +13,28 @@ let # llvm-translator packages overlay_ocamlPackages = ofinal: oprev: { - ocaml-llvm-14 = ofinal.callPackage ./llvm-translator/ocaml-llvm.nix { libllvm = final.llvmPackages_14.libllvm; }; - asl-translator = ofinal.callPackage ./llvm-translator/asl-translator.nix { llvm = ofinal.ocaml-llvm-14; }; + # ctypes and ctypes-foreign v0.22.0 do not build on macOS + ctypes = oprev.ctypes.overrideAttrs (old: { + version = "0.23.0"; + src = prev.fetchFromGitHub { + owner = "ocamllabs"; + repo = "ocaml-ctypes"; + rev = "0.23.0"; + hash = "sha256-fZfTsOMppHiI7BVvgICVt/9ofGFAfYjXzHSDA7L4vZk="; + }; + }); + ctypes-foreign = oprev.ctypes-foreign.override (old: { + ctypes = ofinal.ctypes; + }); + + ocaml-llvm-14 = ofinal.callPackage ./llvm-translator/ocaml-llvm.nix { + libllvm = final.llvmPackages_14.libllvm; + ctypes = ofinal.ctypes; + ctypes-foreign = ofinal.ctypes-foreign ; + }; + asl-translator = ofinal.callPackage ./llvm-translator/asl-translator.nix { + llvm = ofinal.ocaml-llvm-14; + }; }; inherit (final.ocamlPackages_pac) asl-translator; From 560af8a4b0689c0e80ac2b0bb9f3b24bc2f0a958 Mon Sep 17 00:00:00 2001 From: Nicholas Coughlin Date: Tue, 8 Oct 2024 21:08:40 +1000 Subject: [PATCH 11/30] Simpler Z3 linking fix Add additional search path to BAP wrapper --- aslp/ocaml_z3.nix | 41 ----------------------------------------- aslp/overlay.nix | 4 +--- bap/bap.nix | 11 +++++++++++ bap/overlay.nix | 3 ++- 4 files changed, 14 insertions(+), 45 deletions(-) delete mode 100644 aslp/ocaml_z3.nix create mode 100644 bap/bap.nix diff --git a/aslp/ocaml_z3.nix b/aslp/ocaml_z3.nix deleted file mode 100644 index 28bd8a8..0000000 --- a/aslp/ocaml_z3.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ stdenv, lib, ocaml, findlib, zarith, z3 }: - -if lib.versionOlder ocaml.version "4.07" -then throw "z3 is not available for OCaml ${ocaml.version}" -else - -let z3-with-ocaml1 = z3.override { - ocamlBindings = true; - inherit ocaml findlib zarith; -}; in - -let z3-with-ocaml = z3-with-ocaml1.overrideAttrs (p: { - postInstall = p.postInstall + '' - ln -sf $lib/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary} $OCAMLFIND_DESTDIR/stublibs/libz3${stdenv.hostPlatform.extensions.sharedLibrary} - ''; -}); in - -stdenv.mkDerivation { - - pname = "ocaml${ocaml.version}-z3"; - inherit (z3-with-ocaml) version; - - dontUnpack = true; - - installPhase = '' - runHook preInstall - mkdir -p $OCAMLFIND_DESTDIR - cp -r ${z3-with-ocaml.ocaml}/lib/ocaml/${ocaml.version}/site-lib/stublibs $OCAMLFIND_DESTDIR - cp -r ${z3-with-ocaml.ocaml}/lib/ocaml/${ocaml.version}/site-lib/Z3 $OCAMLFIND_DESTDIR/z3 - runHook postInstall - ''; - - nativeBuildInputs = [ findlib ]; - propagatedBuildInputs = [ zarith ]; - - strictDeps = true; - - meta = z3.meta // { - description = "Z3 Theorem Prover (OCaml API)"; - }; -} diff --git a/aslp/overlay.nix b/aslp/overlay.nix index 3a54bc9..f611151 100644 --- a/aslp/overlay.nix +++ b/aslp/overlay.nix @@ -7,9 +7,7 @@ final: prev: inherit (final.ocamlPackages_pac_5) aslp_web; overlay_ocamlPackages = ofinal: oprev: { - ocaml_z3 = final.callPackage ./ocaml_z3.nix { findlib = ofinal.findlib ; zarith = ofinal.zarith ; ocaml = ofinal.ocaml ; }; - - asli = ofinal.callPackage ./asli.nix { inherit (final) z3; ocaml_z3 = ofinal.ocaml_z3; }; + asli = ofinal.callPackage ./asli.nix { inherit (final) z3; ocaml_z3 = ofinal.z3; }; aslp = ofinal.asli; # .overrideAttrs { src = prev.lib.cleanSource ~/progs/aslp; } diff --git a/bap/bap.nix b/bap/bap.nix new file mode 100644 index 0000000..4889bf4 --- /dev/null +++ b/bap/bap.nix @@ -0,0 +1,11 @@ +{ stdenv, makeBinaryWrapper, symlinkJoin, orig-bap, z3 }: + +symlinkJoin { + inherit (orig-bap) version; + name = "bap-wrapped"; + paths = [ orig-bap ]; + nativeBuildInputs = [ makeBinaryWrapper ]; + postBuild = '' + wrapProgram $out/bin/bap --prefix DYLD_FALLBACK_LIBRARY_PATH : ${z3.lib}/lib + ''; +} diff --git a/bap/overlay.nix b/bap/overlay.nix index dc527b7..cc554d8 100644 --- a/bap/overlay.nix +++ b/bap/overlay.nix @@ -1,7 +1,8 @@ final: prev: { overlay_ocamlPackages = ofinal: oprev: { - bap = oprev.bap.overrideAttrs (p: { + bapWrapper = ofinal.callPackage ./bap.nix { orig-bap = oprev.bap ; z3 = prev.z3 ; }; + bap = ofinal.bapWrapper.overrideAttrs (p: { # configurePhase = '' # runHook preConfigure # echo old "$configureFlags" From e0c940348f2a7eec6408e6da54d886468075f2b4 Mon Sep 17 00:00:00 2001 From: Nicholas Coughlin Date: Wed, 9 Oct 2024 07:46:06 +1000 Subject: [PATCH 12/30] Disable ddisasm-deterministic test on darwin --- gtirb/ddisasm.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index 3173860..fccdeea 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -53,6 +53,7 @@ stdenv.mkDerivation { version = "Disassemble"; }; + # Deterministic fix does not work on Darwin, just test to see if ddisasm even runs passthru.tests.ddisasm-deterministic = runCommand "ddisasm-deterministic-test" { nativeBuildInputs = [ ddisasm.deterministic jq clang-aarch64 ]; } @@ -62,8 +63,9 @@ stdenv.mkDerivation { aarch64-unknown-linux-gnu-cc a.c ddisasm-deterministic a.out --json | jq -S > a1 ddisasm-deterministic a.out --json | jq -S > a2 + '' + ( if stdenv.isDarwin then "" else '' diff -q a1 a2 - ''; + '' ); meta = { mainProgram = "ddisasm"; From 03d38f5de2e847e958c93660f9075ff996af61a0 Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 10 Oct 2024 00:03:46 +1000 Subject: [PATCH 13/30] remove planter from ci & use lib.optional --- .github/workflows/main.yml | 1 - llvm-translator/alive2-regehr.nix | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20d545a..354e7bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,6 @@ jobs: retdec-uq-pac, asl-translator, gtirb-semantics, ddisasm, retdec5, remill, alive2-aslp, alive2-regehr, - planter, aslp_web, godbolt ] runs-on: ${{ matrix.os }} diff --git a/llvm-translator/alive2-regehr.nix b/llvm-translator/alive2-regehr.nix index 192f477..379e317 100644 --- a/llvm-translator/alive2-regehr.nix +++ b/llvm-translator/alive2-regehr.nix @@ -1,4 +1,5 @@ -{ alive2 +{ lib +, alive2 , stdenv , llvmPackages , fetchFromGitHub @@ -16,5 +17,6 @@ }; patches = [ ]; - CXXFLAGS = prev.CXXFLAGS or "" + (if stdenv.isDarwin then "" else " -Wno-error=maybe-uninitialized"); + CXXFLAGS = (prev.CXXFLAGS or "") + + lib.optionalString (!stdenv.isDarwin) " -Wno-error=maybe-uninitialized"); }) From 45cc5aa89f2a9566374dfcdac0ce82cc1933e8ee Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 10 Oct 2024 00:03:46 +1000 Subject: [PATCH 14/30] oops --- llvm-translator/alive2-regehr.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm-translator/alive2-regehr.nix b/llvm-translator/alive2-regehr.nix index 379e317..a5c0acd 100644 --- a/llvm-translator/alive2-regehr.nix +++ b/llvm-translator/alive2-regehr.nix @@ -18,5 +18,5 @@ patches = [ ]; CXXFLAGS = (prev.CXXFLAGS or "") - + lib.optionalString (!stdenv.isDarwin) " -Wno-error=maybe-uninitialized"); + + lib.optionalString (!stdenv.isDarwin) " -Wno-error=maybe-uninitialized"; }) From c2db3ee34cef1754ee3d41c6b5d16893ac68e157 Mon Sep 17 00:00:00 2001 From: Kait Lam <39479354+katrinafyi@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:50:44 +1000 Subject: [PATCH 15/30] ddisasm: use null in ternary to avoid rebuild --- gtirb/ddisasm.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index fccdeea..4f59048 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -28,7 +28,7 @@ stdenv.mkDerivation { rev = "9edfe9fe86910ef946de1db7a7ac41ce86bc31d0"; hash = "sha256-xFW6J3jCCMtUqT25/zVfjjy5o3MoX1HXxIlRhjM6s8A="; }; - patches = if stdenv.isDarwin then [ ./0001-ddisasm-disable-concurrent-souffle.patch ] else []; + patches = if stdenv.isDarwin then [ ./0001-ddisasm-disable-concurrent-souffle.patch ] else null; buildInputs = [ cmake boost lief gtirb gtirb-pprinter libehp ]; nativeBuildInputs = [ capstone-grammatech souffle ]; From 518cac620f7a7a8d90715c8d6c37af7abd9bcf4e Mon Sep 17 00:00:00 2001 From: Kait Lam <39479354+katrinafyi@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:22:17 +1000 Subject: [PATCH 16/30] try clang17Stdenv --- aslp/aslp-cpp.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/aslp/aslp-cpp.nix b/aslp/aslp-cpp.nix index 461491f..f667360 100644 --- a/aslp/aslp-cpp.nix +++ b/aslp/aslp-cpp.nix @@ -1,13 +1,12 @@ { stdenv +, clang17Stdenv , cmake , asli -, overrideCC -, llvmPackages_17 }: -let buildStdenv = if stdenv.isDarwin then overrideCC stdenv llvmPackages_17.clang else stdenv; in +let stdenv' = if stdenv.isDarwin then clang17Stdenv else stdenv; -buildStdenv.mkDerivation { +in stdenv'.mkDerivation { pname = "aslp-cpp"; version = asli.version; From bcbde0ecce65e03e0f82283296da232093ea1bab Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 31 Oct 2024 12:11:41 +1000 Subject: [PATCH 17/30] ddisasm: use pre-built binary in test --- gtirb/ddisasm.nix | 32 ++++++++++++++++++++------------ gtirb/gtirb.nix | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index 4f59048..80413c1 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -1,6 +1,7 @@ { lib , stdenv , fetchFromGitHub +, fetchzip , cmake , boost , lief @@ -54,18 +55,25 @@ stdenv.mkDerivation { }; # Deterministic fix does not work on Darwin, just test to see if ddisasm even runs - passthru.tests.ddisasm-deterministic = runCommand - "ddisasm-deterministic-test" - { nativeBuildInputs = [ ddisasm.deterministic jq clang-aarch64 ]; } - '' - mkdir -p $out && cd $out - echo 'int main(void) { return 0; }' > a.c - aarch64-unknown-linux-gnu-cc a.c - ddisasm-deterministic a.out --json | jq -S > a1 - ddisasm-deterministic a.out --json | jq -S > a2 - '' + ( if stdenv.isDarwin then "" else '' - diff -q a1 a2 - '' ); + passthru.tests.ddisasm-deterministic = + let + test-files = fetchzip { + url = "https://gist.github.com/katrinafyi/8bcc7a6756b6f467a658e292181cdf8b/archive/453c9b2c5ebdca4d30816e26805b121a919dd150.tar.gz"; + hash = "sha256-xewqpzAR+rfAMM9Hn97gwzTrhpHONjltbIjhd15PaPw="; + }; + in runCommand + "ddisasm-deterministic-test" + { nativeBuildInputs = [ ddisasm.deterministic jq ]; } + ( + '' + cp -v ${test-files}/a.out . + ddisasm-deterministic a.out --json | jq -S > a1 + ddisasm-deterministic a.out --json | jq -S > a2 + (diff -u a1 a2 || true) | tee $out + '' + lib.optionalString (!stdenv.isDarwin) '' + diff -q a1 a2 + '' + ); meta = { mainProgram = "ddisasm"; diff --git a/gtirb/gtirb.nix b/gtirb/gtirb.nix index 4349d37..4becb60 100644 --- a/gtirb/gtirb.nix +++ b/gtirb/gtirb.nix @@ -18,7 +18,7 @@ stdenv.mkDerivation { rev = "v2.0.0"; hash = "sha256-ueoqxm6iXv4JgzR/xkImT+O8xx+7bA2upx1TJ828LLA="; }; - patches = if stdenv.isDarwin then [ ./0001-gtirb-link-absl.patch ] else []; + patches = if stdenv.isDarwin then [ ./0001-gtirb-link-absl.patch ] else null; nativeBuildInputs = [ ]; buildInputs = [ cmake python3 boost doxygen ]; From 31e0759ea25f9319c99c2da951a58ec25a029694 Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 31 Oct 2024 16:35:25 +1000 Subject: [PATCH 18/30] touch bap.nix --- bap/bap.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bap/bap.nix b/bap/bap.nix index 4889bf4..6589fc0 100644 --- a/bap/bap.nix +++ b/bap/bap.nix @@ -1,8 +1,10 @@ -{ stdenv, makeBinaryWrapper, symlinkJoin, orig-bap, z3 }: +{ makeBinaryWrapper, symlinkJoin, orig-bap, z3 }: + +# XXX: fix in ocamlPackages.bap of upstream nixpkgs symlinkJoin { - inherit (orig-bap) version; name = "bap-wrapped"; + inherit (orig-bap) version; paths = [ orig-bap ]; nativeBuildInputs = [ makeBinaryWrapper ]; postBuild = '' From 24e91ebde8e1641df265cd71c57ae8439a14f0c8 Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 31 Oct 2024 17:45:07 +1000 Subject: [PATCH 19/30] llvm-custom: avoid NIX_BUILD_TOP --- llvm-translator/llvm-custom.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/llvm-translator/llvm-custom.nix b/llvm-translator/llvm-custom.nix index 6511355..aa716ff 100644 --- a/llvm-translator/llvm-custom.nix +++ b/llvm-translator/llvm-custom.nix @@ -15,10 +15,14 @@ let doCheck = false; # install Target .inc files from build directory for lifter project. - postFixup = '' - cd $NIX_BUILD_TOP/$sourceRoot/build/lib && file Target + # at this point, we should within the build artifact directory + postBuild = '' + mkdir -p $dev/include + pushd ./lib + file Target find Target -name '*.inc' -print0 \ | xargs -0 -I{} cp -v --no-clobber --parents {} $dev/include + popd ''; }); From e32b4a07d12fa0cf39f3c82b1ea4a197601fcf6c Mon Sep 17 00:00:00 2001 From: rina Date: Fri, 1 Nov 2024 15:57:32 +1000 Subject: [PATCH 20/30] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/18536bf04cd71abd345f9579158841376fdd0c5a' (2024-10-25) → 'github:nixos/nixpkgs/e24d868aba3d21acacdcc319066ce8c4eb692605' (2024-10-31) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 16d5981..60f8c1e 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1729880355, - "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=", + "lastModified": 1730368100, + "narHash": "sha256-iRzj+H57Rd02pEhgipLLdsFRbvaSSCMuoachwmtZB2o=", "owner": "nixos", "repo": "nixpkgs", - "rev": "18536bf04cd71abd345f9579158841376fdd0c5a", + "rev": "e24d868aba3d21acacdcc319066ce8c4eb692605", "type": "github" }, "original": { From 8f0378dfa8d7978558ee4fe1d7e7c63ed37f2c47 Mon Sep 17 00:00:00 2001 From: rina Date: Thu, 28 Nov 2024 10:47:00 +1000 Subject: [PATCH 21/30] ddisasm: use pre-built aarch64 elf binaries for testing [skip ci] for now. --- gtirb/ddisasm.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index 7723edd..ed26c9c 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -12,12 +12,17 @@ , capstone-grammatech , souffle , ddisasm -, runCommandCC +, runCommand , testers , jq }: -stdenv.mkDerivation { +let + elf-test-files = fetchzip { + url = "https://gist.github.com/katrinafyi/8bcc7a6756b6f467a658e292181cdf8b/archive/453c9b2c5ebdca4d30816e26805b121a919dd150.tar.gz"; + hash = "sha256-xewqpzAR+rfAMM9Hn97gwzTrhpHONjltbIjhd15PaPw="; + }; +in stdenv.mkDerivation { pname = "ddisasm"; version = "0-unstable-2024-10-31"; @@ -50,17 +55,12 @@ stdenv.mkDerivation { version = "Disassemble"; }; - # test-files = fetchzip { - # url = "https://gist.github.com/katrinafyi/8bcc7a6756b6f467a658e292181cdf8b/archive/453c9b2c5ebdca4d30816e26805b121a919dd150.tar.gz"; - # hash = "sha256-xewqpzAR+rfAMM9Hn97gwzTrhpHONjltbIjhd15PaPw="; - # }; - passthru.tests.ddisasm-deterministic = runCommandCC + passthru.tests.ddisasm-deterministic = runCommand "ddisasm-deterministic-test" { nativeBuildInputs = [ ddisasm.deterministic jq ]; } '' mkdir -p $out && cd $out - echo 'int main(void) { return 0; }' > a.c - $CC a.c + cp -v ${elf-test-files}/a.out . ddisasm a.out --json | jq -S > a1 ddisasm a.out --json | jq -S > a2 diff -u a1 a2 From 92957348fa1f0b1f6f5a37b05007fd7a729579de Mon Sep 17 00:00:00 2001 From: rina Date: Fri, 29 Nov 2024 20:27:54 +1000 Subject: [PATCH 22/30] mirage-crypto-rng: disable tests ;-; until they fix aarch64 things --- aslp/overlay.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aslp/overlay.nix b/aslp/overlay.nix index f611151..01a7d11 100644 --- a/aslp/overlay.nix +++ b/aslp/overlay.nix @@ -46,6 +46,8 @@ final: prev: } oprev.ocaml_pcre; + + mirage-crypto-rng = oprev.mirage-crypto-rng.overrideAttrs { doCheck = false; }; }; } From c1682bfc9684e1ed5cce914654a9f057c6ac17ac Mon Sep 17 00:00:00 2001 From: rina Date: Fri, 29 Nov 2024 20:28:29 +1000 Subject: [PATCH 23/30] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/e24d868aba3d21acacdcc319066ce8c4eb692605' (2024-10-31) → 'github:nixos/nixpkgs/4633a7c72337ea8fd23a4f2ba3972865e3ec685d' (2024-11-25) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 60f8c1e..9a06f64 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1730368100, - "narHash": "sha256-iRzj+H57Rd02pEhgipLLdsFRbvaSSCMuoachwmtZB2o=", + "lastModified": 1732521221, + "narHash": "sha256-2ThgXBUXAE1oFsVATK1ZX9IjPcS4nKFOAjhPNKuiMn0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e24d868aba3d21acacdcc319066ce8c4eb692605", + "rev": "4633a7c72337ea8fd23a4f2ba3972865e3ec685d", "type": "github" }, "original": { From 0e21f14af2331647d2323a0221ca9fc595608f37 Mon Sep 17 00:00:00 2001 From: rina Date: Fri, 29 Nov 2024 22:38:34 +1000 Subject: [PATCH 24/30] retdec5: copy derivation from new pr and fix yaramod version https://www.github.com/NixOS/nixpkgs/pull/293962 --- llvm-translator/retdec5.nix | 217 ++++++++++++++++++++++++++---------- 1 file changed, 156 insertions(+), 61 deletions(-) diff --git a/llvm-translator/retdec5.nix b/llvm-translator/retdec5.nix index 70972fa..7e736d2 100644 --- a/llvm-translator/retdec5.nix +++ b/llvm-translator/retdec5.nix @@ -1,9 +1,12 @@ { stdenv , fetchFromGitHub +, fetchpatch , fetchzip +, writeText , lib , openssl , cmake +, ninja , autoconf , automake , libtool @@ -14,11 +17,16 @@ , perl , python3 , ncurses +, time +, upx , gtest , libffi , libxml2 , zlib +, buildEnv , enableTests ? true +, buildDevTools ? true +, compileYaraPatterns ? false }: let @@ -28,25 +36,36 @@ let owner = "capstone-engine"; repo = "capstone"; rev = "5.0-rc2"; - sha256 = "sha256-nB7FcgisBa8rRDS3k31BbkYB+tdqA6Qyj9hqCnFW+ME="; + hash = "sha256-nB7FcgisBa8rRDS3k31BbkYB+tdqA6Qyj9hqCnFW+ME="; }; llvm = fetchFromGitHub { owner = "avast-tl"; repo = "llvm"; rev = "2a1f3d8a97241c6e91710be8f84cf3cf80c03390"; - sha256 = "sha256-+v1T0VI9R92ed9ViqsfYZMJtPCjPHCr4FenoYdLuFOU="; + hash = "sha256-+v1T0VI9R92ed9ViqsfYZMJtPCjPHCr4FenoYdLuFOU="; }; yaracpp = fetchFromGitHub { owner = "VirusTotal"; repo = "yara"; rev = "v4.2.0-rc1"; - sha256 = "sha256-WcN6ClYO2d+/MdG06RHx3kN0o0WVAY876dJiG7CwJ8w="; + hash = "sha256-WcN6ClYO2d+/MdG06RHx3kN0o0WVAY876dJiG7CwJ8w="; }; yaramod = fetchFromGitHub { owner = "avast"; repo = "yaramod"; - rev = "a367d910ae79698e64e99d8414695281723cd34b"; - sha256 = "sha256-mnjYQOn/Z37XAtW8YsfPewM9t1WYsyjivTnmRwYWSQ0="; + rev = "aa06dd408c492a8f4488774caf2ee105ccc23ab5"; + hash = "sha256-wiD4A+6Jsd7bzGo8mmWnkb7l2XcjEgLCK/A4iW9Zt/A="; + + # yaramod builds yet more dependencies. these need to be installed to "lib" + postFetch = '' + ( + cd $out + shopt -s globstar + substituteInPlace src/CMakeLists.txt deps/**/CMakeLists.txt \ + --replace-quiet CMAKE_ARGS 'CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=lib' \ + --replace-quiet '$'{CMAKE_INSTALL_LIBDIR} lib + ) + ''; }; keystone = fetchFromGitHub { # only for tests @@ -55,14 +74,14 @@ let rev = "d7ba8e378e5284e6384fc9ecd660ed5f6532e922"; sha256 = "1yzw3v8xvxh1rysh97y0i8y9svzbglx2zbsqjhrfx18vngh0x58f"; }; - # googletest imported from nixpkgs retdec-support-version = "2019-03-08"; retdec-support = { rev = retdec-support-version; } // # for checking the version against the expected version fetchzip { url = "https://github.com/avast-tl/retdec-support/releases/download/${retdec-support-version}/retdec-support_${retdec-support-version}.tar.xz"; - hash = "sha256-paeNrxXTE7swuKjP+sN42xnCYS7x5Y5CcUe7tyzsLxs="; + hash = "sha256-t1tx4MfLW/lwtbO5JQ1nrFBIOeMclq+0dENuXW+ahIM="; + stripRoot = false; }; check-dep = name: dep: @@ -82,20 +101,41 @@ let CAPSTONE = capstone; LLVM = llvm; YARA = yaracpp; - YARAMOD = yaramod; + YARAMOD = yaramod // { rev = ""; }; SUPPORT_PKG = retdec-support; } // lib.optionalAttrs enableTests { KEYSTONE = keystone; + GOOGLETEST = gtest.src // { rev = ""; }; # empty rev bypasses dep version checking }; + + # overwrite install-share.py to copy instead of download. + # we use this so the copy happens at the right time in the build, + # otherwise, the build process cleans the directory. + install-share = + writeText + "install-share.py" + '' + import os, sys, shutil, subprocess + + install_path, arch_url, sha256hash_ref, version = sys.argv[1:] + support_dir = os.path.join(install_path, 'share', 'retdec', 'support') + + assert os.path.isdir(arch_url), "nix install-share.py expects a path for support url" + + os.makedirs(support_dir, exist_ok=True) + shutil.copytree(arch_url, support_dir, dirs_exist_ok=True) + subprocess.check_call(['chmod', '-R', 'u+w', support_dir]) + ''; in stdenv.mkDerivation (self: { pname = "retdec"; - # If you update this you will also need to adjust the versions of the updated dependencies. You can do this by first just updating retdec - # itself and trying to build it. The build should fail and tell you which dependencies you have to upgrade to which versions. + # If you update this you will also need to adjust the versions of the updated dependencies. # I've notified upstream about this problem here: # https://github.com/avast-tl/retdec/issues/412 - # gcc is pinned to gcc8 in all-packages.nix. That should probably be re-evaluated on update. + # + # The dependencies and their sources are listed in this file: + # https://github.com/avast/retdec/blob/master/cmake/deps.cmake version = "5.0"; src = fetchFromGitHub { @@ -105,8 +145,22 @@ stdenv.mkDerivation (self: { sha256 = "sha256-H4e+aSgdBBbG6X6DzHGiDEIASPwBVNVsfHyeBTQLAKI="; }; + patches = [ + # gcc 13 compatibility: https://github.com/avast/retdec/pull/1153 + (fetchpatch { + url = "https://github.com/avast/retdec/commit/dbaab2c3d17b1eae22c581e8ab6bfefadf4ef6ae.patch"; + hash = "sha256-YqHYPGAGWT4x6C+CpsOSsOIZ+NPM2FBQtGQFs74OUIQ="; + }) + # aarch64 compatibility: https://github.com/avast/retdec/pull/1195 + (fetchpatch { + url = "https://github.com/avast/retdec/commit/93233e79a0b14e6aeeee6b117a1c93feba88577b.patch"; + hash = "sha256-0VT7J9mcrneUo80BSi+unqCGdNNp4HaRx615M6hm0n8="; + }) + ]; + nativeBuildInputs = [ cmake + ninja autoconf automake libtool @@ -127,70 +181,111 @@ stdenv.mkDerivation (self: { ] ++ lib.optional self.doInstallCheck gtest; cmakeFlags = [ - "-DRETDEC_TESTS=${if self.doInstallCheck then "ON" else "OFF"}" # build tests - ] ++ lib.mapAttrsToList (k: v: "-D${k}_URL=${v}") deps; - - patches = [ ]; - - # fix for a gcc13 change. - env.CXXFLAGS = "-include cstdint"; + (lib.cmakeBool "RETDEC_TESTS" self.doInstallCheck) # build tests + (lib.cmakeBool "RETDEC_DEV_TOOLS" buildDevTools) # build tools e.g. capstone2llvmir, retdectool + (lib.cmakeBool "RETDEC_COMPILE_YARA" compileYaraPatterns) # build and install compiled patterns + ] ++ lib.mapAttrsToList (k: v: lib.cmakeFeature "${k}_URL" "${v}") deps; preConfigure = - lib.concatStringsSep "\n" (lib.mapAttrsToList check-dep deps) + lib.concatLines (lib.mapAttrsToList check-dep deps) + '' - mkdir -p "$out/share/retdec" - cp --no-preserve=mode -r ${retdec-support} "$out/share/retdec/support" # write permission needed during install - - # the CMakeLists assume CMAKE_INSTALL_BINDIR, etc are path components but in Nix, they are absolute. - # therefore, we need to remove the unnecessary CMAKE_INSTALL_PREFIX prepend. - substituteInPlace ./CMakeLists.txt \ - --replace "''$"{CMAKE_INSTALL_PREFIX}/"''$"{RETDEC_INSTALL_BIN_DIR} "''$"{CMAKE_INSTALL_FULL_BINDIR} \ - --replace "''$"{CMAKE_INSTALL_PREFIX}/"''$"{RETDEC_INSTALL_LIB_DIR} "''$"{CMAKE_INSTALL_FULL_LIBDIR} \ - --replace "''$"{CMAKE_INSTALL_PREFIX}/"''$"{RETDEC_INSTALL_SUPPORT_DIR} "''$"{RETDEC_INSTALL_SUPPORT_DIR} \ - - # similarly for yaramod. here, we fix the LIBDIR to lib64. for whatever reason, only "lib64" works. - substituteInPlace deps/yaramod/CMakeLists.txt \ - --replace "''$"{YARAMOD_INSTALL_DIR}/"''$"{CMAKE_INSTALL_LIBDIR} "''$"{YARAMOD_INSTALL_DIR}/lib64 \ - --replace CMAKE_ARGS 'CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=lib64' - - # yara needs write permissions in the generated source directory. - echo ${lib.escapeShellArg '' - ExternalProject_Add_Step( - yara chmod WORKING_DIRECTORY ''${YARA_DIR} - DEPENDEES download COMMAND chmod -R u+rw . - ) - ''} >> deps/yara/CMakeLists.txt - - # patch gtest to use the system package - gtest=deps/googletest/CMakeLists.txt - old="$(cat $gtest)" - (echo 'find_package(GTest REQUIRED)'; echo "$old") > $gtest - sed -i 's/ExternalProject_[^(]\+[(]/ set(IGNORED /g' $gtest - - substituteInPlace $gtest \ - --replace '$'{GTEST_LIB} "GTest::gtest"\ - --replace '$'{GMOCK_LIB} "GTest::gmock"\ - --replace '$'{GTEST_MAIN_LIB} "GTest::gtest_main"\ - --replace '$'{GMOCK_MAIN_LIB} "GTest::gmock_main" - - # without git history, there's no chance of these tests passing. - substituteInPlace tests/utils/version_tests.cpp \ - --replace VersionTests DISABLED_VersionTests + cp -v ${install-share} ./support/install-share.py + + # the CMakeLists assume CMAKE_INSTALL_BINDIR, etc are path components but in Nix, they are absolute. + # therefore, we need to remove the unnecessary CMAKE_INSTALL_PREFIX prepend. + substituteInPlace ./CMakeLists.txt \ + --replace-fail "''$"{CMAKE_INSTALL_PREFIX}/"''$"{RETDEC_INSTALL_BIN_DIR} "''$"{CMAKE_INSTALL_FULL_BINDIR} \ + --replace-fail "''$"{CMAKE_INSTALL_PREFIX}/"''$"{RETDEC_INSTALL_LIB_DIR} "''$"{CMAKE_INSTALL_FULL_LIBDIR} \ + + # --replace "''$"{CMAKE_INSTALL_PREFIX}/"''$"{RETDEC_INSTALL_SUPPORT_DIR} "''$"{RETDEC_INSTALL_SUPPORT_DIR} + # note! Nix does not set CMAKE_INSTALL_DATADIR to an absolute path, so this replacement would be incorrect + + # similarly for yaramod. + substituteInPlace deps/yaramod/CMakeLists.txt \ + --replace-fail "''$"{YARAMOD_INSTALL_DIR}/"''$"{CMAKE_INSTALL_LIBDIR} "''$"{YARAMOD_INSTALL_DIR}/lib + + # yara needs write permissions in the generated source directory. + echo ' + ExternalProject_Add_Step( + yara chmod WORKING_DIRECTORY ''${YARA_DIR} + DEPENDEES download COMMAND chmod -R u+w . + ) + ' >> deps/yara/CMakeLists.txt + + # yara: to support building retdec with ninja + substituteInPlace deps/yara/CMakeLists.txt \ + --replace-fail '$'{YARA_CONFIGURE_ARGS} ' ''${YARA_CONFIGURE_ARGS} --disable-dependency-tracking' \ + --replace-fail '$'{YARA_MAKE_PROGRAM} $(command -v make) + + # all vendored dependencies must build their libs into the "lib" subdirectory. + # retdec's install phase will copy these into the correct Nix output. + substituteInPlace deps/*/CMakeLists.txt \ + --replace-quiet CMAKE_ARGS 'CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=lib' + + substituteInPlace src/utils/CMakeLists.txt \ + --replace-warn '$'{RETDEC_GIT_VERSION_TAG} ${self.version} \ + --replace-warn '$'{RETDEC_GIT_COMMIT_HASH} ${self.src.rev} + + + # tests: without git history, there is no chance these tests will pass. + substituteInPlace tests/utils/version_tests.cpp \ + --replace-warn VersionTests DISABLED_VersionTests + + + # scripts: patch paths + substituteInPlace scripts/retdec-utils.py \ + --replace-fail /usr/bin/time ${time} \ + --replace-fail /usr/local/bin/gtime ${time} + substituteInPlace scripts/retdec-unpacker.py \ + --replace-fail "'upx'" "'${upx}'" ''; doInstallCheck = enableTests; installCheckPhase = '' - ${python3.interpreter} "$out/bin/retdec-tests-runner.py" + ${python3.interpreter} "''${!outputBin}/bin/retdec-tests-runner.py" rm -rf $out/bin/__pycache__ ''; + + # static-code patterns are split out since they are rarely needed by end users. + # from retdec's wiki: + # However, these are mainly for older compilers used for testing purposes. + # If you want to remove code from newer compilers or some custom libraries, + # you have to create your own signature files. + # see: https://github.com/avast/retdec/wiki/Removing-Statically-Linked-Code + postFixup = '' + mkdir -p $dev/lib/retdec + mv -v $out/share/retdec/cmake $dev/lib/retdec + + yara_dir=share/retdec/support/generic/yara_patterns + mkdir -p $patterns/$yara_dir + mv -v $out/$yara_dir/static-code $patterns/$yara_dir + ''; + + outputs = [ "out" "lib" "dev" "patterns" ]; + + passthru.full = buildEnv { + name = "${self.pname}-full-${self.version}"; + inherit (self.finalPackage) meta; + paths = [ self.finalPackage.out self.finalPackage.patterns ]; + postBuild = '' + config=$out/share/retdec/decompiler-config.json + cp -v --remove-destination $(readlink -f $config) $config + + static_code=support/generic/yara_patterns/static-code/ + substituteInPlace $config \ + --replace-fail ./$static_code $out/share/retdec/$static_code + ''; + }; + + passthru.deps = deps; + meta = with lib; { - description = "A retargetable machine-code decompiler based on LLVM"; + description = "Retargetable machine-code decompiler based on LLVM"; homepage = "https://retdec.com"; license = licenses.mit; - maintainers = with maintainers; [ dtzWill timokau ]; - platforms = [ "x86_64-linux" "i686-linux" ]; + maintainers = with maintainers; [ katrinafyi ]; }; }) From b05e05d8d44ff4428fdcec2e629824ccfe7ae6cb Mon Sep 17 00:00:00 2001 From: rina Date: Fri, 29 Nov 2024 23:20:04 +1000 Subject: [PATCH 25/30] remill: mark broken on aarch64-darwin --- llvm-translator/remill.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm-translator/remill.nix b/llvm-translator/remill.nix index e46f9e4..efec31e 100644 --- a/llvm-translator/remill.nix +++ b/llvm-translator/remill.nix @@ -64,7 +64,7 @@ stdenv.mkDerivation (self: sleigh = sleigh' self; nativeBuildInputs = [ cmake ]; - buildInputs = [ self.sleigh llvm xed glog gtest abseil-cpp glibc_multi ]; + buildInputs = [ self.sleigh llvm glog gtest abseil-cpp xed glibc_multi ]; outputs = [ "out" "dev" "lib" ]; @@ -140,4 +140,12 @@ stdenv.mkDerivation (self: hardeningDisable = [ "zerocallusedregs" ]; + meta = with lib; { + description = "Library for lifting machine code to LLVM bitcode"; + homepage = "https://github.com/lifting-bits/remill"; + license = licenses.asl20; + maintainers = with maintainers; [ katrinafyi ]; + broken = stdenv.isAarch64; # XXX: problems with xed (fixable) and libcxx (unsolved) + }; + }) From e3a3f2a07770a8a2a92a029b0b589153a04d67bf Mon Sep 17 00:00:00 2001 From: rina Date: Sat, 30 Nov 2024 00:13:33 +1000 Subject: [PATCH 26/30] alive2-aslp: disable run-arm-tv.pl test problems on macos and it didnt do much anyway [skip ci] --- llvm-translator/alive2-aslp.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/llvm-translator/alive2-aslp.nix b/llvm-translator/alive2-aslp.nix index d388f45..78850f8 100644 --- a/llvm-translator/alive2-aslp.nix +++ b/llvm-translator/alive2-aslp.nix @@ -62,11 +62,11 @@ ''; }; - passthru.tests.run-arm-tv = runCommand "test-run-arm-tv" {} '' - rm -rfv logs logs-aslp - set +o pipefail - ${alive2-aslp.arm-tv-scripts}/bin/run-arm-tv.pl 2>&1 | tee /dev/stderr | grep 'please specify' - touch $out - ''; + # passthru.tests.run-arm-tv = runCommand "test-run-arm-tv" {} '' + # rm -rfv logs logs-aslp + # set +o pipefail + # ${alive2-aslp.arm-tv-scripts}/bin/run-arm-tv.pl 2>&1 | tee /dev/stderr | grep 'please specify' + # touch $out + # ''; }) From 94863b11afdcc8fb6fba96fc1749a29b3275b948 Mon Sep 17 00:00:00 2001 From: rina Date: Sat, 30 Nov 2024 21:43:16 +1000 Subject: [PATCH 27/30] working on more determinism... [skip ci] --- gtirb/ddisasm.nix | 7 ++++++- gtirb/gtirb.nix | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index ed26c9c..1df8660 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -45,7 +45,12 @@ in stdenv.mkDerivation { cmakeFlags = [ "-DDDISASM_ENABLE_TESTS=OFF" "-DDDISASM_GENERATE_MANY=ON" ]; - CXXFLAGS = [ "-includeset" ]; + postPatch = '' + ( + shopt -u globstar + substituteInPlace **/*.h --replace-warn unordered_map map --replace-warn unordered_set set + ) + ''; passthru.deterministic = ddisasm; diff --git a/gtirb/gtirb.nix b/gtirb/gtirb.nix index 4e0722b..8c4855b 100644 --- a/gtirb/gtirb.nix +++ b/gtirb/gtirb.nix @@ -27,6 +27,13 @@ stdenv.mkDerivation { }) ] ++ lib.optional stdenv.isDarwin ./0001-gtirb-link-absl.patch; + postPatch = '' + ( + shopt -u globstar + substituteInPlace include/gtirb/{CFG,Module}.hpp --replace-warn unordered_map map --replace-warn unordered_set set + ) + ''; + nativeBuildInputs = [ ]; buildInputs = [ cmake python3 boost doxygen ]; propagatedBuildInputs = [ protobuf ]; From e1a299e657d1d9a3a0b489d3afbf205fb3a02319 Mon Sep 17 00:00:00 2001 From: rina Date: Sun, 1 Dec 2024 20:05:55 +1000 Subject: [PATCH 28/30] more complete determinism --- gtirb/ddisasm.nix | 8 ++++++-- gtirb/gtirb-pprinter.nix | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gtirb/ddisasm.nix b/gtirb/ddisasm.nix index 1df8660..f66e22a 100644 --- a/gtirb/ddisasm.nix +++ b/gtirb/ddisasm.nix @@ -47,8 +47,12 @@ in stdenv.mkDerivation { postPatch = '' ( - shopt -u globstar - substituteInPlace **/*.h --replace-warn unordered_map map --replace-warn unordered_set set + shopt -s globstar + substituteInPlace **/*.cpp **/*.h --replace-warn unordered_map map --replace-warn unordered_set set + substituteInPlace src/passes/Disassembler.cpp \ + --replace-fail \ + 'gtirb::UUID Uuid;' \ + 'gtirb::UUID Uuid{gtirb::Node::UUIDGenerator()};' ) ''; diff --git a/gtirb/gtirb-pprinter.nix b/gtirb/gtirb-pprinter.nix index 789444c..a58744a 100644 --- a/gtirb/gtirb-pprinter.nix +++ b/gtirb/gtirb-pprinter.nix @@ -21,8 +21,16 @@ stdenv.mkDerivation { rev = "762a287f3d12c6aac3d3d000cdc8bf20f5ee34f2"; hash = "sha256-9CZ+ndHX5f4rKbGXvCrqEg55Ep9JEkS/u//grdqTpTc="; }; + patches = [ ./0001-gtirb_pprinter-include-map.patch ]; + postPatch = '' + ( + shopt -s globstar + substituteInPlace **/*.cpp **/*.hpp --replace-warn unordered_map map --replace-warn unordered_set set + ) + ''; + buildInputs = [ cmake python3 gtirb boost abseil-cpp gtest ]; nativeBuildInputs = [ capstone-grammatech ]; From 2fd8e15db0b4e5f01b5e2041c28b649d04b35df0 Mon Sep 17 00:00:00 2001 From: rina Date: Mon, 2 Dec 2024 14:36:38 +1000 Subject: [PATCH 29/30] fix? sporadic failure --- llvm-translator/retdec5.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm-translator/retdec5.nix b/llvm-translator/retdec5.nix index 7e736d2..63c5ee6 100644 --- a/llvm-translator/retdec5.nix +++ b/llvm-translator/retdec5.nix @@ -241,6 +241,11 @@ stdenv.mkDerivation (self: { --replace-fail "'upx'" "'${upx}'" ''; + # build first to make sure YARA_DIR has u+w permissions? + preBuild = '' + ninja yara + ''; + doInstallCheck = enableTests; installCheckPhase = '' ${python3.interpreter} "''${!outputBin}/bin/retdec-tests-runner.py" From 8607c9dd47ee85080dfc11f98100ce0cffe332bb Mon Sep 17 00:00:00 2001 From: rina Date: Mon, 2 Dec 2024 14:45:35 +1000 Subject: [PATCH 30/30] retdec-uq-pac: append patches --- llvm-translator/retdec-uq-pac.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm-translator/retdec-uq-pac.nix b/llvm-translator/retdec-uq-pac.nix index 47c221d..1b1093f 100644 --- a/llvm-translator/retdec-uq-pac.nix +++ b/llvm-translator/retdec-uq-pac.nix @@ -2,7 +2,7 @@ retdec.overrideAttrs (final: prev: { cmakeFlags = prev.cmakeFlags ++ [ "-DRETDEC_DEV_TOOLS=1" ]; - patches = [ + patches = prev.patches ++ [ (fetchurl { url = "https://gist.githubusercontent.com/katrinafyi/c33f6f9ccaad4420f76f84e6cb219fe0/raw/0001-emit-names-for-capstone-intrinsics.patch"; hash = "sha256-LJjzLw2R8ckB10jL92RH/kHggX2oQrAZNQUsonM6ciQ=";