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

Fixes for macOS #18

merged 31 commits into from
Dec 3, 2024

Conversation

ncough
Copy link
Contributor

@ncough ncough commented Oct 2, 2024

Partial fixes for getting builds to work on macOS. Many fixes are quite hacky, hopefully someone who knows what they are doing can fix them properly.

  • Explicitly link abseil into gtirb, as a dependency of protobuf. Not clear why this isn't done automatically.
  • Missing #include <map> in gtirb-pprinter.
  • Disable concurrent souffle builds.
  • Explicitly provide an implementation of protoc to basil, due to issues downloading and caching it.
  • Fix a linking issue with ocamlPackages.z3.
  • Adjust build paths for python-gtirb

@katrinafyi
Copy link
Owner

This is excellent! Thanks for your work. I hope Nix wasn't too frustrating :)

@ncough
Copy link
Contributor Author

ncough commented Oct 2, 2024

Nix has been mostly pain free. A bit confused on by basil build if you get a moment, it passes on my machine but fails on ci. Seems the ci doesn't run the preConfigure step.

also fixes up some nix noob mistakes
@katrinafyi
Copy link
Owner

Basil build is fixed on my computer by 302dd59. This happened because the configure phase was not being run in the dependency derivation, which mkSbtDerivation runs to download all dependencies (evidenced by the basil-sbt-dependencies.tar.zst> prefix in front of the log messages, instead of basil>). Within this derivation, configuring is explicitly disabled.

Propagating the replacement command makes it work. I suspect some caching was at play to make it succeed locally.

@katrinafyi
Copy link
Owner

Re protobuf abseil linking errors: https://www.github.com/protocolbuffers/protobuf/issues/12637

katrinafyi and others added 3 commits October 3, 2024 13:33
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
@ncough
Copy link
Contributor Author

ncough commented Oct 8, 2024

From what I see locally, the only remaining issue is the determinism fix for ddisasm not working on macOS. If this isn't used, I suspect it would be far easier to disable the test.

@katrinafyi
Copy link
Owner

katrinafyi commented Oct 9, 2024

It looks really good now! Just one thing left, we should make the ddisasm test use a "nolibc" variant of the compiler so it doesn't spin cross-compiling libc. I can look into this if you want.

Edit: Or simply vendor an aarch64 ELF binary (somewhere not in the git repo) - the test is not about the cross compiler.

@ncough
Copy link
Contributor Author

ncough commented Oct 9, 2024

Thanks! I'll leave it to you. I was wondering if it would be possible to have Nix provide a full cross compiling environment on macOS anyway, as full tests aren't practical without it.

Copy link
Owner

@katrinafyi katrinafyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo notes for myself

aslp/aslp-cpp.nix Outdated Show resolved Hide resolved
bap/bap.nix Show resolved Hide resolved
basil/0001-basil-protoc-version.patch Show resolved Hide resolved
gtirb/ddisasm.nix Outdated Show resolved Hide resolved
gtirb/ddisasm.nix Outdated Show resolved Hide resolved
llvm-translator/alive2-regehr.nix Outdated Show resolved Hide resolved
overlay.nix Show resolved Hide resolved
.github/workflows/main.yml Outdated Show resolved Hide resolved
@katrinafyi
Copy link
Owner

katrinafyi commented Oct 9, 2024

@ncough real quick about using Nix as a cross-compile environment, this is definitely possible. but the main problem is the Nix-provided compilers are not hermetic - they will look for and may or may not find libraries on your system. It is especially dicey if the Nix compilers call a non-Nix tool which it finds through PATH.

The solutions I can conceptualise are:

  • run all compilations within a Nix sandbox - clunky, slow, difficult to integrate, adds Nix as a runtime dependency, and bloats Nix store on disk with compilation results
  • use Nix compiler within a chroot / Docker - probably easiest. some trouble transporting files across the boundary
  • somehow manually isolate the Nix compiler, e.g. by clearing PATH in a wrapper script - hard
  • just use non-Nix compilers from OS packages - give up, very easy but obviously non-portable and non reproducible

@katrinafyi katrinafyi self-requested a review October 31, 2024 06:35
@katrinafyi katrinafyi mentioned this pull request Oct 31, 2024
fixed conflicts in gtirb.nix and ddisasm.nix
arising from patches and ddisasm-deterministic
@katrinafyi
Copy link
Owner

In advancing the nixpkgs version for arm-tv, it seems that ocaml is broken on aarch64-darwin https://www.github.com/NixOS/nixpkgs/issues/350394. This seems to be fixed now https://hydra.nixos.org/build/276865224

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/18536bf04cd71abd345f9579158841376fdd0c5a' (2024-10-25)
  → 'github:nixos/nixpkgs/e24d868aba3d21acacdcc319066ce8c4eb692605' (2024-10-31)
until they fix aarch64 things
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/e24d868aba3d21acacdcc319066ce8c4eb692605' (2024-10-31)
  → 'github:nixos/nixpkgs/4633a7c72337ea8fd23a4f2ba3972865e3ec685d' (2024-11-25)
problems on macos and it didnt do much anyway

[skip ci]
@katrinafyi katrinafyi changed the title WIP: Fixes for macOS Fixes for macOS Dec 3, 2024
@katrinafyi katrinafyi merged commit ee6e85d into katrinafyi:main Dec 3, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants