Pass proper file URI under both Windows and not

Before this CL the kernel service was during the build trained with
an attempt at a full file uri for dart2js.
There was a suddle bug though: Under non-Windows the uri would become
something like "file:////full/path/to/dart2js.dart" (i.e. have 4 slashes)
whereas under Windows it would look something like
"file:///C:/full/path/to/dart2js.dart" (i.e. correctly with 3 slashes).

Mostly, having 4 slashes instead of 3 doesn't matter much:
Everything will just look weird and have 4 slashes instead of 3,
but when at the same time giving the compiler a relative .packages file
(so it will be translated according to the current directory and become
a uri with 3 slashes) with relative uris in it (so those uris also get
3 slashes in them) and then doing a sub-string match to - in some
cases - interpreting the input as a package uri things go awry.
"file:///path/to/whatever" is not a substring of
"file:////path/to/whatever" and thus the interpreting the input as a
package uri doesn't happen, which can cause weird compilation errors
when mixing relative and package uri imports, e.g.:

file:////b/s/w/ir/cache/builder/sdk/pkg/compiler/lib/src/common/codegen.dart:439:38: Error: The argument type 'MemberEntity/*1*/' can't be assigned to the parameter type 'MemberEntity/*2*/'.
 - 'MemberEntity/*1*/' is from 'file:////b/s/w/ir/cache/builder/sdk/pkg/compiler/lib/src/elements/entities.dart'.
 - 'MemberEntity/*2*/' is from 'package:compiler/src/elements/entities.dart' ('file:///b/s/w/ir/cache/builder/sdk/pkg/compiler/lib/src/elements/entities.dart').
Try changing the type of the parameter, or casting the argument to 'MemberEntity/*2*/'.
    return _functionCompiler.compile(member);
                                     ^
Change-Id: I4c6b5ea2e7e2e4a75331847138a79708ac365769
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103126
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2019-09-13 14:11:32 +00:00 committed by commit-bot@chromium.org
parent f35f9e8e24
commit 25401964ab

View file

@ -29,7 +29,10 @@ kernel_application_snapshot("kernel-service_snapshot") {
]
training_args = [
"--train",
"file:///" + rebase_path("../../pkg/compiler/lib/src/dart2js.dart"),
# Force triple-slashes both on Windows and otherwise.
# Becomes e.g. file:///full/path/to/file and "file:///C:/full/path/to/file.
# Without the ', "/"' part, on Linux it would get four slashes.
"file:///" + rebase_path("../../pkg/compiler/lib/src/dart2js.dart", "/"),
]
if (dart_platform_bytecode) {
training_args += [ "--bytecode" ]