Граф коммитов

1892 Коммитов

Автор SHA1 Сообщение Дата
Ted Mielczarek bbb8502454 switch back to upstream rust-musl-builder for build-release 2017-03-31 10:23:34 -04:00
Ted Mielczarek 1cbd6565a0 Include CARGO_ environment variables in Rust hash generation. Fixes #89
These variables are very commonly used in env! invocations, so include them
in hash generation so we don't cache compilations improperly.
2017-03-28 13:03:23 -04:00
Ted Mielczarek c71af25597 Send environment variables from client for compilation requests. Fixes #48 2017-03-28 13:03:23 -04:00
Ted Mielczarek e2e7fbd8a5 bump serde to 0.9.12 to pick up OsStr[ing] support 2017-03-28 10:24:28 -04:00
Felix Obenhuber 6ad7c8333f Remove line break in release script
With 2349791 a line break in the release script is introduced that breaks
it. This patch removes that one.
2017-03-28 06:42:34 -04:00
Alex Crichton 7ae4c25987 Merge pull request #56 from flxo/pr-redis
Add a Redis cache variant
2017-03-27 14:39:38 -05:00
Felix Obenhuber 2349791192 Use Cargo features for S3 and Redis caches
The S3 and Redis caches are optional during build time.
Enable feature "s3" and/or "redis" to build sccache with
support for those backends. Only the local disk cache
is available by default. The "all" feature enables both.
This patch is changing the current default behavior that
always has S3 support.
2017-03-27 12:37:25 -07:00
Felix Obenhuber dc31690674 Add a Redis cache variant
This cache module uses a Redis instance. To make sccache use this,
set SCCACHE_REDIS to redis://[:<passwd>@]<hostname>[:port][/<db>].
The maximum and current cache size is retrieved from the INFO and
CONFIG GET redis command.
2017-03-27 12:34:05 -07:00
Alex Crichton a0b7cc114b Merge pull request #85 from alexcrichton/less-protobuf
Move from protobuf to bincode for a wire format
2017-03-27 12:14:11 -05:00
Alex Crichton a996ae6c2a Move from protobuf to bincode for a wire format
This commit migrates away from the `protobuf` crate to instead just working with
bincode on the wire as a serialization format. This is done by leveraging a few
different crates:

* The `bincode` and `serde_derive` crates are used to define serialization
  for Rust structures as well as provide a bincode implementation.
* The `tokio_io::codec::length_delimited` module implements framing via length
  prefixes to transform an asynchronous stream of bytes into a literal `Stream`
  of `BytesMut`.
* The `tokio_serde_bincode` crate is then used to tie it all together, parsing
  these `BytesMut` as the request/response types of sccache.

Most of the changes here are related to moving away from the protobuf API
throughout the codebase (e.g. `has_foo` and `take_foo`) towards a more
rustic-ish API that just uses enums/structs. Overall it felt quite natural (as
one would expect) to just use the raw enum/struct values.

This may not be quite as performant as before but that doesn't really apply to
sccache's use case where perf is hugely dominated by actually compiling and
hashing, so I'm not too too worried about that.

My personal motivation for this is twofold:

1. Using `protobuf` was a little clunky throughout the codebase and definitely
   had some sharp edges that felt good to smooth out.
2. There's currently what I believe some mysterious segfault and/or stray write
   happening in sccache and I'm not sure where. The `protobuf` crate had a lot
   of `unsafe` code and in lieu of actually auditing it I figured it'd be good
   to kill two birds with one stone. I have no idea if this fixes my segfault
   problem (I never could reproduce it) but I figured it's worth a shot.
2017-03-27 09:29:12 -07:00
Alex Crichton 76982eee57 Update to using the new tokio-io crate
This is an abstraction of the Tokio stack now and doesn't have much impact on
sccache itself but I figured it'd be good to update a few deps and pick up the
recent version of things!

Plus that and I'd like to start using the length_delimited module soon...
2017-03-24 18:37:04 -07:00
Alex Crichton 9a3447f4cc Merge pull request #79 from alexcrichton/handle-eof
Add timeouts to cache lookups and handle server eofs
2017-03-24 20:36:43 -05:00
Alex Crichton b91b81a8eb Add a timeout to cache lookups
This should help ensure that we don't wait *too* long for the cache to respond
(for example on an excessively slow network) and time out the server
unnecessarily.
2017-03-24 15:15:59 -07:00
Alex Crichton 6efac2ea00 Handle UnexpectedEof from server by compiling locally
I believe this is possible to hit if the compilation takes quite a long time and
times out the server itself. The server may shut down due to being idle while
we're still connected and cause us to receive an `UnexpectedEof`.
2017-03-24 15:05:15 -07:00
Alex Crichton 87c5b7b0ff Add some logging to server shutdown 2017-03-24 15:05:15 -07:00
Nicolas Grunbaum 57a2139342 Fix non-GMT time stamp in HTTP Date header
HTTP requires that all timestamps be in GMT. Posts to S3 were using
localtime with an offset instead.  Ceph's radosgw is picky enough
to care.

http://tracker.ceph.com/issues/3973
2017-03-24 16:05:31 -04:00
Alex Crichton 907ed3b352 Parse dep-info files on the cpu pool 2017-03-24 16:03:57 -04:00
Ted Mielczarek 8605d60c21 document rust caveats 2017-03-24 16:03:57 -04:00
Ted Mielczarek 1d3f8e18d7 Change Rust hash key generation to include hashes of shared libs from $sysroot/lib instead of compiler executable.
This changeset removes `CompilerInfo` entirely, moving `get_cached_or_compile`
into the `Compiler` trait. The server now deals exclusively with objects of
`Box<Compiler>`.

Also fixes a few other review comments.
2017-03-24 16:03:57 -04:00
Ted Mielczarek 4c43c8ef9a Add some more timings into the logs 2017-03-24 16:03:57 -04:00
Ted Mielczarek 28bf88226b Add support for caching Rust compilation. 2017-03-24 16:03:57 -04:00
Ted Mielczarek 3fbb864343 Pre-Rust support refactoring, Part 3
The goal here was to make more of the state that's currently persisted
from `parse_arguments` -> `generate_hash_key` -> `compile` private so
the C compilers and the Rust compiler can store different kinds of state.

* Split the `Compiler` trait further into a `CompilerHasher` trait,
  which now gets returned in a Box from `Compiler::parse_arguments`
  as a field of `CompilerArguments`.
* Move the existing `ParsedArguments` struct into compiler/c to make it
  specific to C compilers.
2017-03-24 16:03:57 -04:00
Ted Mielczarek 91bde76f03 Move the current cache::hash_key into compiler::c 2017-03-24 16:03:57 -04:00
Ted Mielczarek 95082ad605 Pre-Rust support refactoring, Part 2
The goal here was to make the state that persists between running the
preprocessor and running the compiler private, since the Rust compiler
does not have a preprocessor, but it will likely have other state it
would like to persist.

* Add a `Compiler` trait to make the interface to compilation generic.
* Add a `Compilation` trait that can be returned from a method on `Compiler`
  to hold the preprocessor output that is reused for compilation while still
  allowing the calling code to box `Compiler` and `Compilation` as trait
  objects.
* Add a `CCompiler` struct that impls `Compiler`, but is generic over a
  second `CCompilerImpl` trait for specific C compilers, since most of
  the logic of running the preprocessor to generate the hash key is
  shared. Move all of `hash_key_from_c_preprocessor_output` into the
  `Compiler` impl on `CCompiler`.
* Add {GCC,Clang,MSVC} structs that impl `CCompilerImpl` so they can be
  used with `CCompiler`.
* Rework `CompilerKind` to be a simple utility enum and make `CompilerInfo`
  actually hold a `Box<Compiler>` and call methods on it directly.
2017-03-24 16:03:57 -04:00
Ted Mielczarek 5a64e0fe1d Change the parameters of get_cached_or_compile from borrowed to owned 2017-03-24 16:03:57 -04:00
Ted Mielczarek b1c0ce0b9c Rename Compiler to CompilerInfo 2017-03-24 16:03:57 -04:00
Ted Mielczarek 4c5b8298d5 Pre-Rust support refactoring, Part 1
Pull the "run the preprocessor and generate the hash key" chunk of
`get_cached_or_compile` out into a separate method, in expectation of
making things more generic in a followup commit to support the Rust
compiler, which won't be running a preprocessor.

There are a few major changes here:
* put the refactored bits from `get_cached_or_compile` into a
  `hash_key_from_c_preprocessor_output`
* added a `generate_hash_key` method to `CompilerKind`, which just calls
  the previously mentioned function
* removed `Compiler::compile`, inlined it into `get_cached_or_compile`
  since that was the only call site anyway, and it made some lifetime issues
  easier
* changed `get_cached_or_compile` to take ownership of `self`, and changed
  a few other functions to just take the compiler path as a `&str` instead
  of taking a `&Compiler`.
2017-03-24 16:03:57 -04:00
Ted Mielczarek 74a8381884 fix some warnings on windows 2017-03-24 06:28:55 -04:00
Ted Mielczarek cf7b400c90 Store file permissions for files in cache 2017-03-24 05:53:21 -04:00
Alex Crichton 5c77c33735 Merge pull request #90 from alexcrichton/segfault-info
Try to get more info out of server crashes
2017-03-23 14:40:42 -05:00
Alex Crichton b9fd4244e6 Try to get more info out of server crashes
Apply two separate techniques:

* Ensure that core dumps come out of the server by calling `setrlimit` manually
* Install some signal handlers which print out the signal that was received

Hopefully this'll help debugging issues by at least confirming what happens.
2017-03-23 12:39:27 -07:00
Alex Crichton b1c66d4aa5 Go back to raw process spawning on Windows
Unfortunately a crucial detail I missed is that the previous incarnation of this
function set `bInheritHandles` to `FALSE` which caused the server process to not
inherit any handles from the parent process. The Rust standard library, however,
unconditionally passes `TRUE` for this variable right now.

I discovered, though, that with CMake the `cmake` process itself would hang
until all of its child pipes were closed, and one of those pipes was one that
leaked all the way into the server process. I unfortunately could not figure out
a way to stop the leak, so I've opted to just revert the part to use the
standard library's spawning mechanism back to calling `CreateProcess` manually.
2017-03-23 06:34:58 -04:00
Alex Crichton 5a20118ca5 Update futures dependency required by futures-cpupool
Shoulda run the last commit through CI!
2017-03-21 16:15:56 -07:00
Alex Crichton 5f6932b6b6 Update the futures-cpupool dependency
Previous versions of futures-cpupool depended on crossbeam which unfortunately
has known segfaults (spurious) so the updated version no longer uses
futures-cpupool and instead relies on channels in the standard library.
2017-03-21 16:09:12 -07:00
Alex Crichton 8968eba6c9 Remove dependency on `named_pipe`
I was sporadically receiving a segfault locally when trying to debug issues on
Windows and in tracking this down I discovered blackbeam/named_pipe#3 which
leads to segfaults locally on startup.

This switches the one use case to the relevant functionality in
`mio-named-pipes` (already pulled in as part of `tokio-process`) and then
otherwise mirrors the same logic as the Unix version, just waiting for a byte
with a timeout.
2017-03-21 15:51:53 -04:00
Alex Crichton 81edc56a7a Print out the full backtrace of errors on compile errors 2017-03-19 08:30:03 -07:00
Alex Crichton 5a04527857 Merge pull request #82 from TimNN/patch-1
Don't silently ignore errors
2017-03-19 10:27:42 -05:00
Tim Neumann 596a0c0924 Don't silently ignore errors. 2017-03-19 13:45:05 +01:00
Alex Crichton 1e6c6fc1e7 Merge pull request #76 from alexcrichton/update-mio-named-pipes
Update mio-named-pipes
2017-02-25 10:53:28 -06:00
Alex Crichton daa9a6564d Merge pull request #75 from alexcrichton/upgrade-gcc
Update gcc crate in Cargo.lock
2017-02-25 10:53:24 -06:00
Alex Crichton 985439a8ae Merge pull request #74 from alexcrichton/borrow-mut-no
Prevent double borrow_mut() error
2017-02-25 10:53:19 -06:00
Alex Crichton 01a057215d Update mio-named-pipes
This fixes a bug in EOF handling which can cause spurious failures on Windows
2017-02-25 08:29:47 -08:00
Alex Crichton 4eb8218848 Update gcc crate in Cargo.lock
Picks up support for `-C target-feature=+crt-static` on MSVC and such
2017-02-25 01:48:02 -08:00
Alex Crichton 374634ccb9 Prevent double borrow_mut() error
Mistake left in from a refactoring I made unfortunately
2017-02-25 01:40:40 -08:00
Ted Mielczarek 96de60c018 Update Rust version requirement to 1.13 in README. Fixes #73 2017-02-23 15:34:02 -05:00
Ted Mielczarek 9895290a21 Don't include the compiler path as an input to the cache key 2017-02-17 15:58:59 -05:00
Felix Obenhuber 69ca2c1932 Fix hash calculation by using arguments instead of parsed args
For the hash calculation the full argument list should be used
and not only the common args from the parsed list.
The string allocation should also be faster than a individual
sha update for each argument.
2017-02-17 15:52:44 -05:00
Felix Obenhuber 6209b3f186 Removed invalid and wrong test
The hash_key function cannot be tested for a equal key with
different output files, because the file is removed before
calling hash_key. Nevertheless the assertion in the test
also was wrong.
2017-02-17 15:47:05 -05:00
Felix Obenhuber e0ba9c05de Remove out file from hash generation
The name and path of the output file of a compilation shall
not be used for the hash calculation.
This improves the hit rate when building two modules A and B
that both have a dependency on C and the build systems composes
the object file path from the path of the module that introduces
the dependency.

Example:

Three individual modules exist with on source file each:

A/a.c
B/b.c
C/c.c

where A and B depend on C. A and B are independent projects.

The build systems produces when building A:

A/build/a.o
C/build_A/c.o

and when building B:

B/build/b.o
C/build_B/c.o

The build_A and build_B is (sadly) the behaviour of the build system.

Without this patch sccache would end in a cache miss when building
c.c the second time (as a dep of B).

This patch also removes the artificial space that is used
during iteration over the arguments.

To check that the output file has no effect on the result do the
following (same for gcc):

clang -c test.c -o test0.o
clang -c test.c -o test1.o
shasum test0.o test1.o
-> 5999b7872181e9121ad17d33b828757a86318dc2  test0.o
-> 5999b7872181e9121ad17d33b828757a86318dc2  test1.o
2017-02-17 15:47:05 -05:00
Alex Crichton 6dba30a3af Interpret cache read errors as fatal errors
Previously a cache read error would translate to a cache miss and trigger a full
compilation, but this just alters the logic to interpret a cache read error as a
full error.
2017-02-17 13:39:01 -05:00