denoland/rusty_v8

proposal: use zig for build and compilation of v8

orvitpng opened this issue · 2 comments

Zig is mostly known and advertised as the language to finally "kill C," partially due to its extensive build system that can build for C, C++, and, of course, Zig. Along with this, as long as the code is written with platform independence in mind, its cross compilation is as easy as specifying the target architecture and operating system from a very long list of supported systems.

The creator of Zig, @andrewrk, has been very vocal on Zig not being stable, however, this is primarily for the language and its standard library, not the toolchain. Despite these instabilities, Zig's build system has drawn many in, including companies such as Uber who now use zig cc for production builds because of its 'hermetic' nature.

The following are the primary reasons why Zig would be helpful to a project of this like:

  • is one toolchain that doesn't need to interact with any programs outside of itself
  • promises it can be used for maintaining "robust, optimal and reusable software"
  • focuses on independent software which includes shipping with libc to optionally allow binaries that don't link to system files
  • is designed with cross compilation in mind, allowing most programs to build for other platforms from a single machine with stack traces on all targets
  • contains sane optimization profiles for stable, fast, and small release builds

For these reasons, it is proposed that this project maintain and use a Zig build"script" that could benefit its maintainers, dependents, and others looking to build V8 with a level of complexity removed. It is worth noting that Zig could be used just as a toolchain rather than the build system if it is preferable to just replace the C compiler.

ry commented

This project is for connecting v8 to rust.

@ry I completely understand and this is not intended to be directed at V8.

I raise this because V8's build problem is inherited into this project. rusty_v8 is in a position where it compiles V8 itself and this proposal's implementation would result in one dependency for building that can not only simplify this process, but make Deno and other dependents function on more systems.

This is primarily an issue to support more reliable builds, a better developer experience, major simplification of this project, and will create a build system that can be implemented by other projects (like zig-v8 which is following in rusty_v8's footsteps) to massively ease the pain of working with V8 in any language with C FFI. I am currently forking and working on a proof of concept to show how this is not only possible, but plausible and convenient.

I completely understand if this is not considered as a radical change like this is not inherently good for a maturing project like this.