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

chromium: Support building with NaCl #8560

Closed
wants to merge 2 commits into from

Conversation

sivertb
Copy link

@sivertb sivertb commented Jun 29, 2015

If enableNaCl is true, the NaCl and PNaCl toolchains are downloaded and
patched to use the correct dynamic linker. It also disables stripping of
the installed binaries, as this seem to cause segfaults when trying to
run NaCl apps.

@sivertb
Copy link
Author

sivertb commented Jun 29, 2015

Tested building with enableNaCl set to both true and false with the stable channel.

@sivertb
Copy link
Author

sivertb commented Jun 29, 2015

cc @aszlig

@aszlig aszlig self-assigned this Jun 29, 2015
@aszlig
Copy link
Member

aszlig commented Jul 2, 2015

What's the reason to switch to stdenv_32bit for Chromium? Also, I think we really want to just exclude stripping NaCl binaries, not all binaries.

@aszlig
Copy link
Member

aszlig commented Jul 2, 2015

IMO it would make more sense to use mkChromiumDerivation instead of building NaCl together with the main derivation of the browser, which not only keeps things separate (and/or breaks the main browser for the sake of having NaCl support) but also doesn't cause a full rebuild of the main browser if someone wants to have NaCl support.

@sivertb
Copy link
Author

sivertb commented Jul 2, 2015

I switched to stdenv_32bit, because some of the toolchain binaries were 32bit, so we need $NIX_CC/nix-support/dynamic-linker-m32 to patch it.

Not sure I follow your point about mkChromiumDerivation. Do you mean build the NaCl plugin in a separate derivation, and keep the main browser common?

@sivertb
Copy link
Author

sivertb commented Jul 8, 2015

Rebased, added stripping of everything except .nexe file, and changed to only add disable_glibc=1 if we're building with NaCl.

I also looked into the possibility of moving the NaCl stuff out of common.nix, but I'm not sure it's possible. If NaCl is to be used, the main browser must be built with it. I do not think it is possible to build the browser without NaCl, then drop in the NaCl runtime + plugin later.

@aszlig
Copy link
Member

aszlig commented Aug 4, 2015

I'm pretty sure it's possible to keep NaCl separate from the main browser, even if it's just the NaCl helpers. Going to look into that by the end of the week.

@sivertb
Copy link
Author

sivertb commented Aug 21, 2015

I did originally download the NaCl toolchains separately, and specified the toolchain path with pnacl_newlib_toolchain as described in http://www.chromium.org/nativeclient/pnacl/building-pnacl-components-for-distribution-packagers, but I ran into some trouble with stamp files. Can't recall if the trouble was with version 42 (no longer a problem) or newer. It would probably be possible to get this working with some fiddling around.

@aszlig aszlig removed their assignment Jan 18, 2016
@zimbatm
Copy link
Member

zimbatm commented Feb 26, 2016

Does it mean that chromium is forced to be 32bit because of NaCL ? I will close this issue if that's the case.

@sivertb
Copy link
Author

sivertb commented Feb 26, 2016

No, the produced binary is 64bit on x86_64. It's some of the downloaded toolchains that are 32bit, and require the 32bit linker.

@aszlig
Copy link
Member

aszlig commented Mar 20, 2016

I'm currently refactoring the Chromium build, so I'd also like to get this in. However, did you try this with enabled Nix sandboxing, because it seems that it is trying to fetch stuff during build.

aszlig added a commit to aszlig/nixpkgs that referenced this pull request Mar 20, 2016
This addresses NixOS#12794 so that we now have only a single tarball where we
base our build on instead of splitting the source into different outputs
first and then reference the outputs.

The reason I did this in the first place is that we previously built the
sandbox as a different derivation and unpacking the whole source tree
just for building the sandbox was a bit too much.

As we now have namespaces sandbox built in by default we no longer have
that derivation anymore. It still might come up however if we want to
build NaCl as a separate derivation (see NixOS#8560), but splitting the
source code into things only NaCl might require is already too much work
and doesn't weight out the benefits.

Another issue with the source splitup is that Hydra now has an output
limit for non-fixed-output derivations which we're already hitting.

Tested the build against the stable channel and it went well, but I
haven't tested running the browser.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
@sivertb
Copy link
Author

sivertb commented Mar 20, 2016

Yeah, I just confirmed that it fails with build-use-chroot=true. It seems the toolchains have to be split out into a fixed-output derivation. The solution I have in mind is:

  • Add
    source.toolchain which simply runs the script to download and unpack the toolchains, putting them into their own derivation
  • Change update.nix / update.sh to also calculate the hash of this derivation by downloading and running the scripts, then nix-store --dump .. | sha256sum

This is a bit ugly, as it will duplicate the downloading / unpacking of the toolchains into both the source.toolchain derivation and the update.sh script. If anyone has a better suggestion I'm all ears. I won't have time to look any closer at this the coming week, but I hope to have some time the week after.

aszlig added a commit that referenced this pull request Mar 21, 2016
This addresses #12794 so that we now have only a single tarball where we
base our build on instead of splitting the source into different outputs
first and then reference the outputs.

The reason I did this in the first place is that we previously built the
sandbox as a different derivation and unpacking the whole source tree
just for building the sandbox was a bit too much.

As we now have namespaces sandbox built in by default we no longer have
that derivation anymore. It still might come up however if we want to
build NaCl as a separate derivation (see #8560), but splitting the
source code into things only NaCl might require is already too much work
and doesn't weight out the benefits.

Another issue with the source splitup is that Hydra now has an output
limit for non-fixed-output derivations which we're already hitting.

Tested the build against the stable channel and it went well, but I
haven't tested running the browser.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
(cherry picked from commit 4f981b4)
aszlig added a commit that referenced this pull request Mar 21, 2016
This addresses #12794 so that we now have only a single tarball where we
base our build on instead of splitting the source into different outputs
first and then reference the outputs.

The reason I did this in the first place is that we previously built the
sandbox as a different derivation and unpacking the whole source tree
just for building the sandbox was a bit too much.

As we now have namespaces sandbox built in by default we no longer have
that derivation anymore. It still might come up however if we want to
build NaCl as a separate derivation (see #8560), but splitting the
source code into things only NaCl might require is already too much work
and doesn't weight out the benefits.

Another issue with the source splitup is that Hydra now has an output
limit for non-fixed-output derivations which we're already hitting.

Tested the build against the stable channel and it went well, but I
haven't tested running the browser.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
(cherry picked from commit 4f981b4)
@sivertb
Copy link
Author

sivertb commented Mar 29, 2016

Updated the change to build the toolchains as a separate derivation. It's now possible to build with build-use-sandbox=true.

@@ -1,4 +1,4 @@
#!/bin/sh -e
cd "$(dirname "$0")"
sp="$(nix-build -Q --no-out-link update.nix -A update)"
sp="$(nix-build -Q --no-out-link update.nix -A update --option build-use-sandbox 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 won't have any effect if you're running the Nix daemon.

Copy link
Author

Choose a reason for hiding this comment

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

I assume update.sh is run manually, not through the nix daemon no? Anyway, I see that update.nix already fetches the tarballs without any hashes, so I assume this is already run outside a sandbox.

@aszlig
Copy link
Member

aszlig commented Mar 31, 2016

What I really meant with "separate derivation" was not to separate the NaCl toolchain sources but the whole NaCl helper as a separate derivation.

Moreover, shouldn't NaCl be able to be used completely separate from Chromium and also its releases? I mean it has its own bytecode so it should be more or less something like "throw some bytecode at the NaCl black box and wait for something to happen", which shouldn't depend on the browser version. Am I right in this regard?

@sivertb
Copy link
Author

sivertb commented Mar 31, 2016

As far as I can tell it's not possible to split out NaCl as a separate component. We can't just combine the NaCl runtime with a chromium binary built without NaCl and expect it to work. If you have a look at e.g. chrome/chrome_browser.gypi in the chromium source you'll see that it includes some extra code if NaCl is enabled. The same goes for several of the other gypi files for components that end up in the chromium binary.

This commits adds a new 'config.chromium.enableNaCl' option that makes
it possible to build chromium with native client support enabled.

The NaCl and PNaCl toolchains are required to build chromium with NaCl
support. These are not part of the downloaded tarball, and must be
built as a separate derivation.

'common.nix' linkes the toolchains into place if 'enableNaCl' is true.
It's also been changed to do stripping manually, to avoid stripping the
nacl_irt_*.nexe file, as this results in a segfault when trying to run
NaCl apps.
@sivertb
Copy link
Author

sivertb commented Jul 31, 2016

I finally got it to work with PNaCl toolchains and translator built from source; no more binary blobs. The NaCl toolchains are also not tied to the chromium version, and the same toolchains can be used to build stable, beta and dev channels.

Most of the information about how to build the PNaCl can be found here:
https://www.chromium.org/nativeclient/pnacl/building-pnacl-components-for-distribution-packagers
https://bugs.chromium.org/p/nativeclient/issues/detail?id=3954

@lukateras
Copy link
Member

lukateras commented Dec 20, 2017

PNaCl has been deprecated in favor of WebAssembly, and NaCl will soon become exclusive for Chromium OS, see:

https://blog.chromium.org/2017/05/goodbye-pnacl-hello-webassembly.html
https://developer.chrome.com/native-client/nacl-and-pnacl

Support will be removed in Q1 2018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants