-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
makeBinaryWrapper fixes for Darwin #150079
makeBinaryWrapper fixes for Darwin #150079
Conversation
I have been trying to find more complex derivations that depend on makewrapper working where i substitute the normal wrapper with the binary wrapper. While doing that i discovered that
that, together with the performance discussion convinces me towards dropping (at least the address) sanitizers. |
Okay, it seems like makeBinaryWrapper tests are now working on x86_64-linux, aarch64-linux and x86_64-darwin - and tests are running in OfBorg. For some reason the address sanitizer doesn't seem to cause build issues in the test, only when executed in a nix-shell.
Regardless, I have now disabled the address sanitizer by default - and only enabled it in the tests. (undefined sanitizer is still enabled by default) aarch64-darwin seems to fail due to something with |
Another problem I just detected: When setting
Seems like something is expecting libSystem.B.dylib to exist in the file system - but all system shared libraries were removed from the file system in the macOS Big Sur upgrade. To check whether a system library exists in macOS Big Sur it is possible to use: // From #include <mach-io/dyld>
static bool _dyld_shared_cache_contains_path(const char *path) |
Trying to use sanitizers in tests on aarch64-darwin I would get: # undefined behaviour sanitizer:
ld: file not found: /nix/store/bp55vzlmcyqcx9n08pkzslvks10zybwc-clang-wrapper-11.1.0/resource-root/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib
# address sanitizer:
ld: file not found: /nix/store/bp55vzlmcyqcx9n08pkzslvks10zybwc-clang-wrapper-11.1.0/resource-root/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
# As we can see, they sanitizer libraries does not seem to exist:
$ ls /nix/store/bp55vzlmcyqcx9n08pkzslvks10zybwc-clang-wrapper-11.1.0/resource-root/lib/darwin/
libclang_rt.cc_kext.a libclang_rt.osx.a So I decided to disable sanitizers in aarch64-darwin tests. The strange codesigner-errors disappeared once I added $ nix-build -A makeBinaryWrapper.passthru.tests
these 12 derivations will be built:
/nix/store/c878h9lm9pp97zz67149q87l947dpyna-envcheck.drv
/nix/store/803j7571q1xz5dxmsrq9px988ig69ck5-test-wrapper_inherit-argv0.drv
/nix/store/8x3yfs11shxrfbzwcd7zr3sbxcddxi6h-test-wrapper_env.drv
/nix/store/dc95gz3a0dfgwfrxwg9iswhmf1hrr1bj-test-wrapper_basic.drv
/nix/store/inlb4hrw8z7g3zh4y3qpkc0vhsa5q4wv-test-wrapper_invalid-env.drv
/nix/store/ka9jrbh2zbsxkpp8mqv6mz2mjgr86675-test-wrapper_add-flags.drv
/nix/store/n72dam3rxisk54fskjr3b81jvxn45vf6-test-wrapper_chdir.drv
/nix/store/ppg4728yk0wjcmirqxra9ls8xmjq4pj5-test-wrapper_argv0.drv
/nix/store/qayllqssv41m7ykfx4dhyfqcnkp1swgp-test-wrapper_suffix.drv
/nix/store/rw661pcarbcznk6m3xfqnx2pcs9pkpf1-test-wrapper_prefix.drv
/nix/store/xys5hq6xjm984fwzxm56c3zam6ij0g7d-test-wrapper_combination.drv
/nix/store/6f2x1i7c6v38gmc6l7xbf36b04w1xzbf-make-binary-wrapper-test.drv
building '/nix/store/c878h9lm9pp97zz67149q87l947dpyna-envcheck.drv'...
/private/tmp/nix-build-envcheck.drv-0/ccXY1W9e.s:22:15: error: index must be an integer in range [-256, 255].
ldr x3, [x3, ___stack_chk_guard];momd
^
/private/tmp/nix-build-envcheck.drv-0/ccXY1W9e.s:65:15: error: index must be an integer in range [-256, 255].
ldr x1, [x1, ___stack_chk_guard];momd
^
error: builder for '/nix/store/c878h9lm9pp97zz67149q87l947dpyna-envcheck.drv' failed with exit code 1;
last 7 log lines:
> /private/tmp/nix-build-envcheck.drv-0/ccXY1W9e.s:22:15: error: index must be an integer in range [-256, 255].
> ldr x3, [x3, ___stack_chk_guard];momd
> ^
> /private/tmp/nix-build-envcheck.drv-0/ccXY1W9e.s:65:15: error: index must be an integer in range [-256, 255].
> ldr x1, [x1, ___stack_chk_guard];momd
> ^
>
For full logs, run 'nix log /nix/store/c878h9lm9pp97zz67149q87l947dpyna-envcheck.drv'.
error: 1 dependencies of derivation '/nix/store/ka9jrbh2zbsxkpp8mqv6mz2mjgr86675-test-wrapper_add-flags.drv' failed to build
error: 1 dependencies of derivation '/nix/store/6f2x1i7c6v38gmc6l7xbf36b04w1xzbf-make-binary-wrapper-test.drv' failed to build I don't really have a good explanation for these error messages. For some reason, changing from But at least the errors are gone now, and the tests seem to succeed on aarch64-darwin, x86_64-darwin, aarch64-linux, x86_64-linux. Sanitizers are now only enabled in tests (except for aarch64-darwin) by default - meaning you can expect a ~10x speedup of the wrappers compared to the bash wrappers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for the sanitizers change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only comments regarding the commit history. All santizers related changes could be squashed into 1 commit. And please follow the commit messages guidelines:
https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
Ideally this should have been enforced in the original PR.
"${stdenv.cc.cc}/bin" does not contain a cc-symlink, since this is the unwrapped version of the compiler - however "${stdenv.cc}/bin" does.
Move makeBinaryWrapper tests to pkgs.makeBinaryWrapper.passthru.tests, since OfBorg doesn't discover/skips the tests in the previous location.
On macOS, /tmp is a symlink to /private/tmp. When performing cd /tmp, and checking cwd - it won't match since it follows the symlink. This caused test breakage on macOS but not Linux. Instead, use a folder which is not a symlink, and consistent across Linux and macOS.
Although sanitizers can catch and prevent undefined behaviour during runtime, it has a significant impact on performance. They also cause issues on macOS where they can make compilation fail. The future goal is to instead utilize static analysis to prevent undefined behaviour as makeBinaryWrapper evolves.
76bc107
to
ebf46e5
Compare
Sanitizers don't seem to be present on aarch64-darwin/macOS 12 (Monterey), so they are removed from the aarch64-darwin tests. Switching from nativeBuildInputs to buildInputs and adding cc to the deps list caused some strange error messages to go away.
@doronbehar Can you verify that the commit messages/commits look correctly formatted now? I also combined the sanitizer removal into a single commit. |
Motivation for this change
See discussion on #124556
TODO:
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notesFuture work/Next PRs for makeBinaryWrapper
--run COMMAND
from makeWrapper