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

[WIP] bazel, tensorflow: enable Darwin source build #37608

Closed
wants to merge 4 commits into from

Conversation

lukeadams
Copy link
Contributor

@lukeadams lukeadams commented Mar 22, 2018

Motivation for this change

Tracking for WIP patches.

  • Need to break apart commits since some Bazel commits are mixed in with the tf commit
  • need to set LD to re-enable bazel tests on Darwin
  • also need to make the changes Darwin only since linux doesn't need these hacks. usually just lib.optionalString
Things done

With this PR tf is buildable for py27/py36, sidestepping the unicode mismatch when using a wheel for py27. This also enables tf c++ artifacts, but I haven't tested those yet.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • 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.

@@ -71,7 +92,7 @@ stdenv.mkDerivation rec {

# Build the CPP and Java examples to verify that Bazel works.

doCheck = true;
doCheck = false;
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 a conditional, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change this to (!stdenv.isDarwin) if I can't get tests working

cp test.sh cxx.sh
cp test.sh ld.sh

echo "(clang \"\$@\" ) || (clang++ \"\$@\" )" >> cc.sh
Copy link
Member

Choose a reason for hiding this comment

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

Have you tried just doing "clang++" for this? I think that clang++ should support both (although some of the Nix purity stuff may break this).

Copy link
Contributor Author

@lukeadams lukeadams Mar 24, 2018

Choose a reason for hiding this comment

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

I initially tried this, but it caused failures when building a few dependencies (I think mostly Protobuf). I'll try to find a log so I can at least put a comment explaining it.

@matthewbauer
Copy link
Member

Thanks for working on this! Tensorflow on Darwin would be great.

@@ -88,7 +92,7 @@ let

hardeningDisable = [ "all" ];

bazelFlags = [ "--config=opt" ]
bazelFlags = [ "--config=opt" "--config=monolithic" ]
Copy link
Member

Choose a reason for hiding this comment

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

Please leave a comment on why is this necessary; let's make it optional for Darwin to avoid static dependencies as much as possible.

@@ -58,7 +61,8 @@ let
nativeBuildInputs = [ swig which ];

buildInputs = [ python jemalloc openmpi glibcLocales numpy ]
++ lib.optionals cudaSupport [ cudatoolkit cudnn nvidia_x11 ];
++ lib.optionals cudaSupport [ cudatoolkit cudnn nvidia_x11 ]
Copy link
Member

Choose a reason for hiding this comment

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

Mark stdenv.isDarwin && cudaSupport as broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

@lukeadams lukeadams Mar 25, 2018

Choose a reason for hiding this comment

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

Would it be a good idea to move the asserts at the top to meta.broken? (see #36229)

@LnL7
Copy link
Member

LnL7 commented Mar 24, 2018

@GrahamcOfBorg build bazel

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: bazel

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: bazel

Partial log (click to expand)

Target //src:bazel failed to build
[6 / 177] no action

INFO: Elapsed time: 5.008s, Critical Path: 0.07s
[6 / 177] no action

FAILED: Build did NOT complete successfully


ERROR: Could not build Bazel
builder for ‘/nix/store/qi5r9dr1xg5ryz972nkif7hwm7d434qr-bazel-0.10.1.drv’ failed with exit code 1
error: build of ‘/nix/store/qi5r9dr1xg5ryz972nkif7hwm7d434qr-bazel-0.10.1.drv’ failed

@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: bazel

Partial log (click to expand)

    [Sched] Linking external/com_google_protobuf/js_embed [for host]
Target //src:bazel failed to build
�[32m[1,179 / 1,914]�[0m no action
�[32mINFO: �[0mElapsed time: 622.827s, Critical Path: 173.37s
�[32m[1,179 / 1,914]�[0m no action
�[31m�[1mFAILED:�[0m Build did NOT complete successfully
�[0m
ERROR: Could not build Bazel
builder for '/nix/store/nwzhb2hkqacflb2jw23f61c4a51539r8-bazel-0.10.1.drv' failed with exit code 1
�[31;1merror:�[0m build of '/nix/store/nwzhb2hkqacflb2jw23f61c4a51539r8-bazel-0.10.1.drv' failed

removes need to include jdk/jre in dependent packages
@lukeadams
Copy link
Contributor Author

lukeadams commented Mar 24, 2018

@abbradar I cleaned it up quite a bit and added conditionals on everything. Rebuilt py27 + py36 and both succeeded!

Luke Adams added 2 commits March 24, 2018 22:00
hacky method to solidify NIX_* env vars as Bazel does not pass these through when calling cc/cxx
bazel cc/cxx hacks on darwin
@lukeadams lukeadams changed the title [WIP] bazel, tensorflow: enable Darwin source build bazel, tensorflow: enable Darwin source build Mar 25, 2018
@LnL7
Copy link
Member

LnL7 commented Mar 28, 2018

@GrahamcOfBorg build bazel

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: bazel

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: bazel

Partial log (click to expand)

//examples/java-native/src/test/java/com/example/myproject:hello         PASSED
 in 0.4s

Executed 2 out of 2 tests: 2 tests pass.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.
installing
post-installation fixup
patching script interpreter paths in /nix/store/6rdvkgs8dk2ypyi962chgsj1mldppvjw-bazel-0.10.1
checking for references to /tmp in /nix/store/6rdvkgs8dk2ypyi962chgsj1mldppvjw-bazel-0.10.1...
/nix/store/6rdvkgs8dk2ypyi962chgsj1mldppvjw-bazel-0.10.1

@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: bazel

Partial log (click to expand)

    [Sched] Linking third_party/zlib/libzlib.a
Target //src:bazel failed to build
�[32m[687 / 952]�[0m no action
�[32mINFO: �[0mElapsed time: 311.403s, Critical Path: 182.49s
�[32m[687 / 952]�[0m no action
�[31m�[1mFAILED:�[0m Build did NOT complete successfully
�[0m
ERROR: Could not build Bazel
builder for '/nix/store/61nlfs2w8xv3r1ahgxx5nmjwi9c9brch-bazel-0.10.1.drv' failed with exit code 1
�[31;1merror:�[0m build of '/nix/store/61nlfs2w8xv3r1ahgxx5nmjwi9c9brch-bazel-0.10.1.drv' failed

@LnL7
Copy link
Member

LnL7 commented Mar 28, 2018

Do you have the CLT/Xcode installed?

@lukeadams
Copy link
Contributor Author

@LnL7 Ahh yep (just CLT) – good catch. Since I need it on my main machine, I can work it out Friday on a VM without it installed.

Sorry about that!

@LnL7
Copy link
Member

LnL7 commented Mar 28, 2018

That might explain the missing framework, if you add it I can start another build.

@lukeadams lukeadams changed the title bazel, tensorflow: enable Darwin source build [WIP] bazel, tensorflow: enable Darwin source build Apr 3, 2018
@lukeadams
Copy link
Contributor Author

@abbradar I'm not going to have time to finish this for the next month, so maybe you can merge the wheel as python3 only?

@LnL7 I added the framework, but there are other issues due to the way Bazel calls xcrun/xcbuild. It may be simple to patch, but I don't have time to play with it

@LnL7
Copy link
Member

LnL7 commented Apr 3, 2018

@GrahamcOfBorg build bazel

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: bazel

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@NixOS NixOS deleted a comment from GrahamcOfBorg Apr 3, 2018
@NixOS NixOS deleted a comment from GrahamcOfBorg Apr 3, 2018
@NixOS NixOS deleted a comment from GrahamcOfBorg Apr 3, 2018
@lukeadams
Copy link
Contributor Author

@LnL7 The framework was in my staging branch; I just pushed it to this one

@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: bazel

Partial log (click to expand)

    Linking third_party/protobuf/3.4.0/libprotobuf.a [for host]; 0s local
Target //src:bazel failed to build
�[32m[270 / 298]�[0m no action
�[32mINFO: �[0mElapsed time: 253.583s, Critical Path: 45.79s
�[32m[270 / 298]�[0m no action
�[31m�[1mFAILED:�[0m Build did NOT complete successfully
�[0m
ERROR: Could not build Bazel
builder for '/nix/store/nygjcxa5y2n0xascw1n913fjbfz874d7-bazel-0.11.1.drv' failed with exit code 1
�[31;1merror:�[0m build of '/nix/store/nygjcxa5y2n0xascw1n913fjbfz874d7-bazel-0.11.1.drv' failed

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: bazel

Partial log (click to expand)

//examples/java-native/src/test/java/com/example/myproject:hello
PASSED in 0.4s

Executed 2 out of 2 tests: 2 tests pass.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.
installing
post-installation fixup
patching script interpreter paths in /nix/store/pmlkwlxlhh1qji7r71iy304m679n1pqk-bazel-0.11.1
checking for references to /tmp in /nix/store/pmlkwlxlhh1qji7r71iy304m679n1pqk-bazel-0.11.1...
/nix/store/pmlkwlxlhh1qji7r71iy304m679n1pqk-bazel-0.11.1

@LnL7
Copy link
Member

LnL7 commented Apr 3, 2018

@GrahamcOfBorg build bazel

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: bazel

Partial log (click to expand)

/nix/store/pmlkwlxlhh1qji7r71iy304m679n1pqk-bazel-0.11.1

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: bazel

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Failure on x86_64-darwin (full log)

Attempted: bazel

Partial log (click to expand)

ld: warning: object file (bazel-out/host/bin/src/main/tools/_objs/linux-sandbox/src/main/tools/dummy-sandbox.o) was built for newer OSX version (10.13) than being linked (10.10)
INFO: From Linking src/main/tools/build-runfiles [for host]:
ld: warning: object file (bazel-out/host/bin/src/main/tools/_objs/build-runfiles/src/main/tools/build-runfiles.o) was built for newer OSX version (10.13) than being linked (10.10)
[460 / 501] Compiling third_party/protobuf/3.4.0/src/google/protobuf/descriptor.cc [for host]; 45s local ... (8 actions running)
INFO: From Linking third_party/protobuf/3.4.0/libprotobuf.a [for host]:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: bazel-out/host/bin/third_party/protobuf/3.4.0/libprotobuf.a(gzip_stream.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: bazel-out/host/bin/third_party/protobuf/3.4.0/libprotobuf.a(error_listener.o) has no symbols
[503 / 543] Compiling external/com_google_protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc [for host]; 5s local ... (8 actions running)
building of '/nix/store/qq2nbfqzx0s02sz57x0kbgv939lnhj64-bazel-0.11.1.drv' timed out after 1800 seconds
�[31;1merror:�[0m build of '/nix/store/qq2nbfqzx0s02sz57x0kbgv939lnhj64-bazel-0.11.1.drv' failed

@abbradar
Copy link
Member

abbradar commented Apr 5, 2018

@lukeadams No sweat! I've merged #37044 for now.

@LnL7
Copy link
Member

LnL7 commented Apr 5, 2018

I was hoping the framework was the only issue, but I get an xcrun failure locally. 😕

@lukeadams
Copy link
Contributor Author

Closed until I have time to work on this. Not sure when tbh :/

#40424 with full-paths.patch patch looks interesting for Darwin

@lukeadams lukeadams closed this May 14, 2018
@veprbl veprbl added this to Package pain points in Darwin Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Darwin
  
Package pain points
Development

Successfully merging this pull request may close these issues.

None yet

5 participants