Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for macOS #18

Merged
merged 31 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
388de5b
ci: add macos-latest
katrinafyi Sep 30, 2024
ed9097e
switch ordering
katrinafyi Sep 30, 2024
55d45ac
nix build with -L
katrinafyi Sep 30, 2024
91ae793
gtirb: disable clang-tidy to fix darwin build
katrinafyi Sep 30, 2024
4585b15
Fixes for macOS
ncough Oct 1, 2024
70740d8
Fix gtirb python package
ncough Oct 2, 2024
302dd59
basil: fix protoc substitution in dependency derivation
katrinafyi Oct 3, 2024
17c485d
ddisasm: use aarch64-unknown-linux-gnu-gcc in test
katrinafyi Oct 3, 2024
2ae10af
ddisasm: use clang-aarch64 in test
katrinafyi Oct 3, 2024
7d6f339
More macOS fixes
ncough Oct 8, 2024
560af8a
Simpler Z3 linking fix
ncough Oct 8, 2024
e0c9403
Disable ddisasm-deterministic test on darwin
ncough Oct 8, 2024
03d38f5
remove planter from ci & use lib.optional
katrinafyi Oct 9, 2024
45cc5aa
oops
katrinafyi Oct 9, 2024
c2db3ee
ddisasm: use null in ternary to avoid rebuild
katrinafyi Oct 30, 2024
518cac6
try clang17Stdenv
katrinafyi Oct 30, 2024
bcbde0e
ddisasm: use pre-built binary in test
katrinafyi Oct 31, 2024
31e0759
touch bap.nix
katrinafyi Oct 31, 2024
24e91eb
llvm-custom: avoid NIX_BUILD_TOP
katrinafyi Oct 31, 2024
a83267c
Merge remote-tracking branch 'origin/main' into macOS
katrinafyi Nov 1, 2024
e32b4a0
flake.lock: Update
katrinafyi Nov 1, 2024
8f0378d
ddisasm: use pre-built aarch64 elf binaries for testing
katrinafyi Nov 28, 2024
9295734
mirage-crypto-rng: disable tests ;-;
katrinafyi Nov 29, 2024
c1682bf
flake.lock: Update
katrinafyi Nov 29, 2024
0e21f14
retdec5: copy derivation from new pr and fix yaramod version
katrinafyi Nov 29, 2024
b05e05d
remill: mark broken on aarch64-darwin
katrinafyi Nov 29, 2024
e3a3f2a
alive2-aslp: disable run-arm-tv.pl test
katrinafyi Nov 29, 2024
94863b1
working on more determinism... [skip ci]
katrinafyi Nov 30, 2024
e1a299e
more complete determinism
katrinafyi Dec 1, 2024
2fd8e15
fix?
katrinafyi Dec 2, 2024
8607c9d
retdec-uq-pac: append patches
katrinafyi Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,7 +37,7 @@ jobs:
planter,
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved
aslp_web, godbolt
]
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

defaults:
run: { shell: "bash -ex -o pipefail {0}" }
Expand Down Expand Up @@ -71,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) }}

Expand All @@ -80,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'
Expand Down
6 changes: 5 additions & 1 deletion aslp/aslp-cpp.nix
Original file line number Diff line number Diff line change
@@ -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
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved

buildStdenv.mkDerivation {
pname = "aslp-cpp";
version = asli.version;

Expand Down
1 change: 0 additions & 1 deletion aslp/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ final: prev:
inherit (final.ocamlPackages_pac_5) aslp_web;

overlay_ocamlPackages = ofinal: oprev: {

asli = ofinal.callPackage ./asli.nix { inherit (final) z3; ocaml_z3 = ofinal.z3; };
aslp = ofinal.asli;
# .overrideAttrs { src = prev.lib.cleanSource ~/progs/aslp; }
Expand Down
11 changes: 11 additions & 0 deletions bap/bap.nix
Original file line number Diff line number Diff line change
@@ -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
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved
'';
}
3 changes: 2 additions & 1 deletion bap/overlay.nix
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
13 changes: 13 additions & 0 deletions basil/0001-basil-protoc-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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")
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved
+
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
)
26 changes: 25 additions & 1 deletion basil/basil.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
, jre
, testers
, basil
, 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";
Expand All @@ -21,14 +28,29 @@ mkSbtDerivation {
sha256 = "sha256-juCX3X8KRGLIUqhNcGHUb/nRv09xhWs5cv/wbAs8wmM=";
};

depsSha256 = "sha256-++gg+SKskDyaqHowNG2RPS7evuCzPYvvXMC4Rkp7b6U=";
patches = [ ./0001-basil-protoc-version.patch ] ;

# we must run the command in both the main derivation
# and the dependency-generating derivation.
overrideDepsAttrs = depsfinal: depsprev: {
postPatch = replaceProtocPlaceholder;
};
postPatch = replaceProtocPlaceholder;

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

Expand All @@ -47,6 +69,8 @@ mkSbtDerivation {
makeWrapper "${lib.getExe jre}" $out/bin/basil \
--add-flags -jar \
--add-flags "$out/share/basil/$(basename $JAR)"

runHook postInstall
'';

meta = {
Expand Down
44 changes: 44 additions & 0 deletions gtirb/0001-ddisasm-disable-concurrent-souffle.patch
Original file line number Diff line number Diff line change
@@ -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})

31 changes: 31 additions & 0 deletions gtirb/0001-gtirb-link-absl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e176b6a7..1c03fe8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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/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)

12 changes: 12 additions & 0 deletions gtirb/0001-gtirb_pprinter-include-map.patch
Original file line number Diff line number Diff line change
@@ -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 <optional>
#include <regex>
#include <string_view>
+#include <map>

namespace fs = boost::filesystem;

13 changes: 8 additions & 5 deletions gtirb/ddisasm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
, ddisasm
, makeWrapper
, runCommand
, runCommandCC
, clang-aarch64
, unrandom
, testers
, jq
Expand All @@ -28,6 +28,7 @@ stdenv.mkDerivation {
rev = "9edfe9fe86910ef946de1db7a7ac41ce86bc31d0";
hash = "sha256-xFW6J3jCCMtUqT25/zVfjjy5o3MoX1HXxIlRhjM6s8A=";
};
patches = if stdenv.isDarwin then [ ./0001-ddisasm-disable-concurrent-souffle.patch ] else [];
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved

buildInputs = [ cmake boost lief gtirb gtirb-pprinter libehp ];
nativeBuildInputs = [ capstone-grammatech souffle ];
Expand All @@ -52,17 +53,19 @@ stdenv.mkDerivation {
version = "Disassemble";
};

passthru.tests.ddisasm-deterministic = runCommandCC
# 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 ]; }
{ nativeBuildInputs = [ ddisasm.deterministic jq clang-aarch64 ]; }
''
mkdir -p $out && cd $out
echo 'int main(void) { return 0; }' > a.c
$CC a.c
aarch64-unknown-linux-gnu-cc a.c
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved
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";
Expand Down
1 change: 1 addition & 0 deletions gtirb/gtirb-pprinter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down
11 changes: 10 additions & 1 deletion gtirb/gtirb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ 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 ];
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 = ''
Expand All @@ -33,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 = ''
Expand Down
2 changes: 0 additions & 2 deletions gtirb/python-gtirb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'
'';
Expand Down
3 changes: 2 additions & 1 deletion llvm-translator/alive2-regehr.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ alive2
, stdenv
, llvmPackages
, fetchFromGitHub
}:
Expand All @@ -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");
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved
})
6 changes: 5 additions & 1 deletion llvm-translator/alive2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion llvm-translator/llvm-custom.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
Expand Down
24 changes: 22 additions & 2 deletions overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
katrinafyi marked this conversation as resolved.
Show resolved Hide resolved
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;

Expand Down
Loading