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

valgrind: enable darwin build #23393

Merged
merged 1 commit into from Mar 11, 2017
Merged

Conversation

periklis
Copy link
Contributor

@periklis periklis commented Mar 2, 2017

Motivation for this change
Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@periklis, thanks for your PR! By analyzing the history of the files in this pull request, we identified @dezgeg, @edolstra and @vcunat to be potential reviewers.

@Mic92 Mic92 added the 6.topic: darwin Running or building packages on Darwin label Mar 2, 2017

enableParallelBuilding = true;

patches = if stdenv.isDarwin
Copy link
Member

Choose a reason for hiding this comment

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

stdenv.lib.optional is a bit nicer

@@ -0,0 +1,29 @@
{ stdenv }:

assert stdenv.isDarwin;
Copy link
Member

Choose a reason for hiding this comment

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

Why assert this, meta.platforms will disable this for other platforms.


stdenv.mkDerivation {
name = "dsymutil";
src = "/usr/bin/dsymutil";
Copy link
Member

Choose a reason for hiding this comment

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

This should be added to __impureHostDeps.

src = "/usr/bin/dsymutil";

unpackPhase = "true";
dontBuild = true;
Copy link
Member

Choose a reason for hiding this comment

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

I prefer phases = [ "installPhase" ]; for things like this, since none of the other phases are needed.

@LnL7
Copy link
Member

LnL7 commented Mar 2, 2017

gdb seems to fail on hydra with "Log limit exceeded". 🙁

@periklis
Copy link
Contributor Author

periklis commented Mar 3, 2017

@LnL7 Thx for the useful input, i pushed the recommended changes. Is monitor.nixos.org down?

buildInputs = [ perl ] ++ stdenv.lib.optional (!stdenv.isDarwin) gdb;
buildInputs = [ perl gdb ] ++ stdenv.lib.optional (stdenv.isDarwin) [ mig dsymutil ];

__impureHostDeps = stdenv.lib.optional (stdenv.isDarwin) [ mig dsymutil ];
Copy link
Member

Choose a reason for hiding this comment

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

Unless I'm mistaken this should be defined in mig and dsymutil, eg. __impureHostDeps = [ "/usr/bin/dsymutil" ];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh i understood it as the list of impure dependencies of the valgrind package.

@LnL7
Copy link
Member

LnL7 commented Mar 4, 2017

Did you look into packaging dsymutil?

@periklis
Copy link
Contributor Author

periklis commented Mar 4, 2017

@LnL7 I moved the __impureHostDeps lists to the right place. What do you mean with "Did you look into packaging dsymutil?".

@LnL7
Copy link
Member

LnL7 commented Mar 4, 2017

I mean if you looked at building it from source.

@periklis
Copy link
Contributor Author

periklis commented Mar 5, 2017

No didn't try, since #17753 waits for the merge into llvm.

@LnL7
Copy link
Member

LnL7 commented Mar 5, 2017

I'm running into this when building, not sure what's going wrong https://gist.github.com/LnL7/ff1cd171129f965df382607a0df49c40

@periklis
Copy link
Contributor Author

periklis commented Mar 5, 2017

It seems that /usr/include/mach/mach_vm.defs is only part of xcode. Another disappointing site of osx :(
What is the preferred way to solve such dependencies?

@periklis
Copy link
Contributor Author

periklis commented Mar 5, 2017

Wait a minute, i see that we get the xnu stuff:
https://opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/mach/

How can we put this to buildInputs?

@LnL7
Copy link
Member

LnL7 commented Mar 5, 2017

We have darwin.xnu and that includes the mach_vm.defs file. My build machine does not have xcode installed (like the hydra build machines).

@periklis
Copy link
Contributor Author

periklis commented Mar 5, 2017

Thx for the log, i updated the buildInputs to include darwin.xnu.

Would you mind to give me the link to hydra, because i can't see an active job for valgrind.x86_64-darwin on hydra.nixos.org? Sorry in advance, if i a miss something.

@LnL7
Copy link
Member

LnL7 commented Mar 5, 2017

Seems like it's looking in a hardcoded place.

/nix/store/51bin2x0i1v9jff0sd98b51hmzv00g0v-cctools-binutils-darwin/bin/ar cru libvex-amd64-darwin.a priv/libvex_amd64_darwin_a-main_globals.o priv/libvex_amd64_darwin_a-main_main.o priv/libvex_amd64_darwin_a-main_util.o priv/libvex_amd64_darwin_a-ir_defs.o priv/libvex_amd64_darwin_a-ir_inject.o priv/libvex_amd64_darwin_a-ir_match.o priv/libvex_amd64_darwin_a-ir_opt.o priv/libvex_amd64_darwin_a-guest_generic_bb_to_IR.o priv/libvex_amd64_darwin_a-guest_generic_x87.o priv/libvex_amd64_darwin_a-guest_x86_helpers.o priv/libvex_amd64_darwin_a-guest_x86_toIR.o priv/libvex_amd64_darwin_a-guest_amd64_helpers.o priv/libvex_amd64_darwin_a-guest_amd64_toIR.o priv/libvex_amd64_darwin_a-guest_ppc_helpers.o priv/libvex_amd64_darwin_a-guest_ppc_toIR.o priv/libvex_amd64_darwin_a-guest_arm_helpers.o priv/libvex_amd64_darwin_a-guest_arm_toIR.o priv/libvex_amd64_darwin_a-guest_arm64_helpers.o priv/libvex_amd64_darwin_a-guest_arm64_toIR.o priv/libvex_amd64_darwin_a-guest_s390_helpers.o priv/libvex_amd64_darwin_a-guest_s390_toIR.o priv/libvex_amd64_darwin_a-guest_mips_helpers.o priv/libvex_amd64_darwin_a-guest_mips_toIR.o priv/libvex_amd64_darwin_a-guest_tilegx_helpers.o priv/libvex_amd64_darwin_a-guest_tilegx_toIR.o priv/libvex_amd64_darwin_a-host_generic_regs.o priv/libvex_amd64_darwin_a-host_generic_simd64.o priv/libvex_amd64_darwin_a-host_generic_simd128.o priv/libvex_amd64_darwin_a-host_generic_simd256.o priv/libvex_amd64_darwin_a-host_generic_maddf.o priv/libvex_amd64_darwin_a-host_generic_reg_alloc2.o priv/libvex_amd64_darwin_a-host_x86_defs.o priv/libvex_amd64_darwin_a-host_x86_isel.o priv/libvex_amd64_darwin_a-host_amd64_defs.o priv/libvex_amd64_darwin_a-host_amd64_isel.o priv/libvex_amd64_darwin_a-host_ppc_defs.o priv/libvex_amd64_darwin_a-host_ppc_isel.o priv/libvex_amd64_darwin_a-host_arm_defs.o priv/libvex_amd64_darwin_a-host_arm_isel.o priv/libvex_amd64_darwin_a-host_arm64_defs.o priv/libvex_amd64_darwin_a-host_arm64_isel.o priv/libvex_amd64_darwin_a-host_s390_defs.o priv/libvex_amd64_darwin_a-host_s390_isel.o priv/libvex_amd64_darwin_a-s390_disasm.o priv/libvex_amd64_darwin_a-host_mips_defs.o priv/libvex_amd64_darwin_a-host_mips_isel.o priv/libvex_amd64_darwin_a-host_tilegx_defs.o priv/libvex_amd64_darwin_a-host_tilegx_isel.o priv/libvex_amd64_darwin_a-tilegx_disasm.o 
ranlib libvex-amd64-darwin.a
make[3]: Leaving directory '/private/var/folders/qv/5k4lhv3n1hg2jk29cj3smtp00000gn/T/nix-build-valgrind-3.12.0.drv-0/valgrind-3.12.0/VEX'
make[2]: Leaving directory '/private/var/folders/qv/5k4lhv3n1hg2jk29cj3smtp00000gn/T/nix-build-valgrind-3.12.0.drv-0/valgrind-3.12.0/VEX'
Making all in coregrind
make[2]: Entering directory '/private/var/folders/qv/5k4lhv3n1hg2jk29cj3smtp00000gn/T/nix-build-valgrind-3.12.0.drv-0/valgrind-3.12.0/coregrind'
make[2]: *** No rule to make target '/usr/include/mach/mach_vm.defs', needed by 'm_mach/mach_vmUser.c'.  Stop.
make[2]: Leaving directory '/private/var/folders/qv/5k4lhv3n1hg2jk29cj3smtp00000gn/T/nix-build-valgrind-3.12.0.drv-0/valgrind-3.12.0/coregrind'
make[1]: *** [Makefile:829: all-recursive] Error 1
make[1]: Leaving directory '/private/var/folders/qv/5k4lhv3n1hg2jk29cj3smtp00000gn/T/nix-build-valgrind-3.12.0.drv-0/valgrind-3.12.0'
make: *** [Makefile:698: all] Error 2
builder for ‘/nix/store/8npbhswdy5lkls7lz319v8w5ai42dlrd-valgrind-3.12.0.drv’ failed with exit code 2

I'm just running a hydra instance locally it's not related to the official one from nixos.org

@periklis
Copy link
Contributor Author

periklis commented Mar 6, 2017

Indeed true, it's hardcoded in coregrind/Makefile.am and in turn in coregrind/Makefile.in. I will produce a patch to ${darwin.xnu}.

@periklis
Copy link
Contributor Author

periklis commented Mar 6, 2017

i pushed a substituteInPlace for the hardcoded stuff.

@periklis
Copy link
Contributor Author

periklis commented Mar 6, 2017

@LnL7 Does your hydra instance poll my github pr automatically?

@periklis
Copy link
Contributor Author

periklis commented Mar 6, 2017

Hmm... mig seems to be also part of xcode, according to the latest hydra failure. :(

@periklis periklis force-pushed the topic_valgrind_darwin branch 2 times, most recently from e9fe6da to 0c06ae0 Compare March 7, 2017 18:56
@periklis
Copy link
Contributor Author

periklis commented Mar 8, 2017

fyi, the mig and dsymutil dependencies are now resolved and point to pure deps in the nix-store

@periklis periklis force-pushed the topic_valgrind_darwin branch 2 times, most recently from ff4b951 to 46e807f Compare March 10, 2017 07:26
@@ -14,11 +14,13 @@ stdenv.mkDerivation rec {

# Perl is needed for `cg_annotate'.
# GDB is needed to provide a sane default for `--db-command'.
buildInputs = [ perl ] ++ stdenv.lib.optional (!stdenv.isDarwin) gdb;
buildInputs = [ perl gdb ] ++ stdenv.lib.optional (stdenv.isDarwin) [ bootstrap_cmds xnu ];
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick (also below again): optional takes a single element, use optionals instead on lists. Otherwise a nested list is created – that works but it isn't nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx for the hint, i updated the changeset to be more optionals nice :)

@LnL7
Copy link
Member

LnL7 commented Mar 11, 2017

Looks like there's still a reference to /usr/bin somewhere. 😞

link_tool_exe_darwin: /usr/bin/ld -static -new_linker -arch x86_64 -macosx_version_min 10.6 -o memcheck-amd64-darwin -u __start -e __start -image_base 0x138000000 -stack_addr 0x134000000 -stack_size 0x800000 memcheck_amd64_darwin-mc_leakcheck.o memcheck_amd64_darwin-mc_malloc_wrappers.o memcheck_amd64_darwin-mc_main.o memcheck_amd64_darwin-mc_translate.o memcheck_amd64_darwin-mc_machine.o memcheck_amd64_darwin-mc_errors.o ../coregrind/libcoregrind-amd64-darwin.a ../VEX/libvex-amd64-darwin.a
xcode-select: error: no developer tools were found at '/Applications/Xcode.app', and no install could be requested (perhaps no UI is present), please install manually from 'developer.apple.com'.

@periklis
Copy link
Contributor Author

periklis commented Mar 11, 2017

ok i fixed that with a dependency on darwin/cctools. Hope that the last issue.

@LnL7
Copy link
Member

LnL7 commented Mar 11, 2017

Looks like that was the last piece of the puzzle 🎉.

@LnL7 LnL7 merged commit 3ea16e9 into NixOS:master Mar 11, 2017
@periklis periklis deleted the topic_valgrind_darwin branch July 25, 2018 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants