Age | Commit message (Collapse) | Author |
|
* Expose more linker options in task
LinkSymbols -> '-b'
DefaultAction -> '-c' and '-u'
CustomSteps -> '--custom-step'
* Fix CustomStep argument generation
- Add a missing space
- Check for empty strings (for non-existent metadata)
* Factor Driver to allow context setup without running
* Add ILLink.Tasks mocked unit tests
* Use Pascal casing for metadata, add testcase
* Expose all optimizations on the task
* Fix whitespace
|
|
* Change illink default action to "link"
* Fix Usage to match
|
|
* Fix error codes range to always have constant length for easier reading
* Test updates
|
|
|
|
(#1065)
- Microsoft.DotNet.ApiCompat - 5.0.0-beta.20201.2
- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.20201.2
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
|
|
We implement detection of methods such as IsAssignableFrom which requires marking of an InterfaceImplementation. An InterfaceImplementation is not an IMemberDefinition so I was unable to record this reflection pattern.
Changing RecognizedReflectionAccessPattern to accept an IMetadataTokenProvider allows us to record this detection.
|
|
* Remove net471 illink build
* Retarget ref package to netcoreapp3.0
* Set up package to include matching implementation
* Remove unnecessary Configurations
* Small cleanup in ILLink.Tasks packaging logic
* Rename package to Microsoft.NET.ILLink
* Fix mono build
|
|
* Add ability to turn of validation of the Kept attributes
It disables the entire AssemblyChecker, but I wanted an attribute name which is not tied to the implementation details. And currently the AssemblyChecker really only validates the Kept attributes.
* PR feedback - rename and make the attribute per-class
|
|
|
|
|
|
* Hide implementation details on public Annotations APIs
* Add more APIs
|
|
|
|
Everything is built on Azure DevOps now.
|
|
* Update dependencies from https://github.com/dotnet/runtime build 20200330.1
- Microsoft.NET.Sdk.IL - 5.0.0-preview.3.20180.1
* Update dependencies from https://github.com/dotnet/runtime build 20200330.15
- Microsoft.NET.Sdk.IL - 5.0.0-preview.3.20180.15
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
|
|
* Add tests for Expression.Call for methods on a base class
Currently this is hitting a bug https://github.com/mono/linker/issues/1042.
* Add same tests for Field and Property as well
|
|
* Add Message class to output errors and warnings to the stdout.
* Add simple test case.
* Log messages through LinkerTestLogger
* Address feedback
* Add parameter to LogContainsAttribute that checks for regex match.
Remove Position and move line and column to MessageOrigin.
Remove MessageCode and use integer instead, check that code value falls into one of the known ranges and that it matches with the received category.
* Order msbuildMC params based on their importance
Remove toolname from MessageOrigin
* Remove unnecessary constructor and comparisons
* Clean up msbuild container to be universaly usable
* Update tests
* Tweak one more category
* Add more tests
* Use factory methods for MessageContainer
Update tests
* Update MessageContainerTests.cs
* Use Append instead of string concatenation
Co-Authored-By: Marek Safar <marek.safar@gmail.com>
Co-authored-by: Marek Safar <marek.safar@gmail.com>
|
|
|
|
|
|
* Add core externally used apis to ref assembly
* Update OverrideInformation.cs
|
|
https://github.com/mono/linker/pull/1029 didn't fix the issue because
Arcade sets its own defaults that override those in
Directory.Build.props. This moves the import so that our setting wins.
Validated by doing a local build, setting OfficialBuildId manually. I
did the same validation in the last change, but maybe I was working
with a dirty build that somehow had a pdb. I think this should
actually fix it.
|
|
|
|
* Add tracing reasons
This supplies a "reason" every time that we mark a piece of IL.
A "reason" is an instance of a new type, DependencyInfo, which tracks
a single source object and a flag (DependencyKind) indicating what
kind of dependency this is. Annotations.Mark now expects a
DependencyInfo, and the dependency reporting interface is extended to
report these reasons.
The mark sites within MarkStep and other steps have been updated with
specific reasons, and the corresponding Mark* methods have been
modified to take a reason that is passed through as many layers of the
marking logic as necessary until it reaches a call to
Annotations.Mark. The marking logic has been modified to more
frequently allow marking Cecil objects multiple times for different
reasons - while still ensuring that any expensive operations are done
only once per object (usually under an IsProcessed check, rather than
an IsMarked check).
In a few cases, the marking logic will process a Cecil object and mark
its dependencies, without marking the original Cecil object. This can
happen, for example, for custom attributes in some cases, or for
generic instantiations (since we only mark definitions). In these
cases, there are extra calls that report these intermediate
dependencies to the tracing interface without actually marking them.
Some of the DependencyKinds (for example AlreadyMarked) are only used
for internal tracking, and will not be reported to the dependency
tracing interface.
The set of DependencyKinds has been selected based on what seems like
an intuitive reason to report for each object, though sometimes the
choice is not obvious since the reasons are restricted to supplying a
single source object. Some interesting cases where potentially
non-obvious choices were made follow:
- When marking overrides on instantiated type, we choose as the reason
the instantiated type, rather than the base method (unless the
override removal optimization is disabled, in which case
instantiations are not taken into account when marking overrides - so
we blame the base method).
- When marking static constructors, we keep track of cases where they
are marked due to a field access or method call from another method,
and report these separately. For cases where we track enough
information to do so, this results in a more direct dependency chain
like: "method A triggers static constructor B", rather than "method A
access field B, field B has declaring type C, declaring type C has
static constructor D".
- When marking custom attributes on assemblies or modules, we record a
dependency from the assembly/module to the attribute, even though the
assembly/module may not have been marked or even recorded. Since the
attributes and their dependencies are kept regardless of what happens
to the assembly, these are conceptually entry points to the analysis.
This also includes a change that moves the reflection reporter from
LinkContext to Tracer, and extended to support multiple sinks, similar
to the dependency reporting.
I have also added assertions in a few places where I think it makes
sense to check invariants when we are running tests in Debug mode.
* Make DependencyKind arrays static, add more comments
* Number the DependencyKind enum
* Pass DependencyInfo as in parameter where it makes sense
The methods that reuse the "reason" variable were not modified.
* Use static fields for well-known DependencyInfo without source
Instead of a ctor that just sets the source to null.
* Undo ReflectionPatternRecorder changes
Move the reflection pattern recorder back to LinkContext
* Remove stack-based dependency recording
* Add DependencyKind.Custom
* Workaround for ReducedTracing
* Use -1 for DependencyKind.Custom
* Add back obsolete Mark method for monolinker build
|
|
|
|
* Feed cleanup
Switch away from blob feeds
* Add dotnet5 feed
* Add darc dependency for Microsoft.NET.Sdk.IL and upgrade to latest version
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
|
|
* Add sealer opt-in optimization
* Review feedback
* Add local cache for IsSubclassed check
* Generate verifiable metadata
* Move nested check before interface shortcut
|
|
* Add reference assembly build
This adds a new project that builds a reference assembly for some of
the surface area of the linker. The package is called illink. We
should finalize the name before releasing an official package. This
leaves a number of problems unsolved (described below), but provides
something we can use to start experimenting.
The preliminary included surface area contains public members of
BaseStep and its dependencies, in the FEATURE_ILLINK build flavor -
which notably makes the ref assembly incompatible with the monolinker
surface area. (illink has an AssemblyResolver derived from
Mono.Linker.DirectoryAssemblyResolver, whereas monolinker has one
derived from Mono.Cecil.BaseAssemblyResolver). Therefore the reference
assembly is currently designed for consumption by illink plugins, not
by monolinker plugins.
The reference assembly is built for netstandard2.0, chosen because it
is the lowest common denominator for netcoreapp3.0 and net471, the
TFMs for which we currently build Mono.Linker. The illink flavor
actually doesn't need to be built for net471 (only ILLink.Tasks does),
so we could choose a higher version of netstandard if we disabled that
build flavor.
The ref assembly package is unusual in a few ways, described below. We
may be able to change some of these quirks once we have a better
picture of how linker plugins will be produced and consumed.
- The package *does not* contain any implementation assemblies,
because it is not designed to be consumed by a project targeting a
platform TFM - rather it is only designed to be consumed
from *libraries* that will act as linker plugins. Attempting to
consume it directly from a netcoreapp3.0 project will work during
build, but will fail to locate illink.dll at runtime.
- The package *does not* have a transitive package dependency on
Mono.Cecil (nor does it include Mono.Cecil). This is because the
reference assembly is built against a submodule of the cecil sources,
so we do not have direct control over the package version. This
requires the custom step developer to add a dependency on Mono.Cecil.
To consume this package in a custom step, the custom step project
should:
- Target a netstandard version compatible with the reference
assembly's target framework (currently netstandard2.0).
- Include a dependency on Mono.Cecil compatible with the version
referenced during the linker build (currently 0:11:1:0, which
incidentally ships in the official Mono.Cecil package version
11.1). Attempting to use a higher version (the current latest release
is 11.2) will result in the linker failing to load the custom step.
* Add cecil to the package
This adds a new project which builds reference assemblies for
cecil. It should be kept in sync with the upstream cecil project
file. The cecil reference assembly is included into the illink package
alongside the illink.dll reference assembly.
Also prevent arcade from trying to upload a non-existent PDB for a ref
assembly.
* Set up ApiCompat
* Use .NET Foundation file header
* Pare down ref surface area
- Remove most members of Annotations
- Remove MarkingHelpers and references to it
- Remove protected members of LinkContext
- Remove UninitializedContextFactory and references to it
- Remove AssemblyResolver and references to it
* Fix undefined ExpectedFeedUrl error
The error was occurring because the early import of the Tools targets
was including Microsoft.DotNet.Build.Tasks.Feed.targets, which changed
the DefaultTargets to a publish-related target. Importing the Tools
targets later prevents overriding the DefaultTargets, causing building
to work as expected.
* Add back AnnotationStore ctor
Otherwise the implicitly-defined default ctor exists in the ref but
not the implementation. This was caught by ApiCompat.
* Build against official Mono.Cecil package
This adds an option to build against the submodule for local
development, but the new default is to build against the package.
* Minor project file cleanup
* Remove left-over files
* Further restrict public surface
* Build fix
* UseLocalCecil -> UseCecilPackage
* Use local cecil for monolinker build
* Remove Version from Mono.Linker projects
This will result in the version being taken from VersionPrefix
in Directory.Build.Props, matching the package version.
* Remove left-over reference to cecil ref build
* Copy package dependencies to ILLink.Tasks build output
This preserves the behavior of the ProjectReference dependencies,
which are always copied. The integration tests expect to find the
linker and cecil alongside ILLink.Tasks in the build output.
* Remove AssemblyAction
Co-authored-by: Marek Safar <marek.safar@gmail.com>
|
|
Don't assume that the test is running from the project directory. Some test runners will set the CurrentDirectory to a temporary directory.
|
|
|
|
(#1017)
- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.20171.1
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
|
|
|
|
* Mark children specified in xml descriptor regardless of the `required` attribute value
* Call MarkChildren once
* Check that unmarked children are removed
* Remove redundant modifier
|
|
* Add the command line option `--output-pinvokes`
* Remove unnecessary memory stream
* Address feedback
* Sort list of pinvokes, add unreachable DllImports to the tests
* Remove redundant if, change comparison order of PInvokeInfo
* Use an overload of Zip that is compatible with .NET 4.7.71
* Use StringComparison.Ordinal when comparing PInvokeInfo fields
Use List for storing PInvokeInfos
* Copy PInvokes json to tests output directory
|
|
The CLR spec in Backward Branch Contraints recognizes only unconditional
jumps. For any other instruction including nop it mandates
>In particular, if that single-pass analysis arrives at an instruction,
call it location X, that immediately follows an unconditional branch,
and where X is not the target of an earlier branch instruction, then the
state of the evaluation stack at X, clearly, cannot be derived from
existing information. In this case, the CLI demands that the evaluation
Fixes #975
|
|
* Enable CI in the feature/dataflow branch
#1004 turned off the CI on all but select branches.
* Update eng/azure-pipelines.yml
Co-Authored-By: Marek Safar <marek.safar@gmail.com>
Co-authored-by: Marek Safar <marek.safar@gmail.com>
|
|
(#1005)
- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.20162.3
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
|
|
On .NET Framework there is an overload of Activator.CreateInstance with takes just one parameter but it's not a Type. This should be reported as unrecognized pattern by the linker.
This change also switches in the internal infra to use exceptions instead of asserts as they play nicer with tests.
|
|
RemoveUnreachableBlocksStep
Fixes #991
|
|
Enable running monolinker tests in VS
|
|
|
|
|
|
|
|
This test fails PEVerify on windows
Invalid IL detected in F:\Temp\linker_tests\output\test.exe
[IL]: Error: [F:\Temp\linker_tests\output\test.exe : Mono.Linker.Tests.Cases.UnreachableBlock.ComplexConditions::Test_1][offset 0x0000001D] Stack depth differs depending on path.
1 Error(s) Verifying F:\Temp\linker_tests\output\test.exe
|
|
To run tests from VS the NUnit3TestAdapter package is required, otherwise VS doesn't correctly recognize NUnit tests.
|
|
|
|
Need to explicitly use roslyn in order for these tests to pass on windows. Otherwise they fail complaining about the nameof() usages in attributes.
|
|
The expectations assembly should never survive linking. However, putting this attribute in there was causing it to survive during some tests.
I moved the attribute into it's own assembly that is compiled during the tests that need it
|
|
Using the CodeDomCompiler has been a constant source of windows only test failures being introduced.
I believe the reason CodeDomCompiler was still sticking around was because it was faster than roslyn but with server mode now widely supported and so many of our tests simply depending on roslyn now I don't think there is any advantage to using CodeDomCompiler anymore.
We switch to using roslyn by default a long time ago and it's been seamless so I expect making this same change upstream will be seamless as well.
Note that I did add /shared to our csc command line now. Without it, roslyn is noticeably slowing than CodeDomCompiler.
|
|
* Resolve custom steps from external assemblies
* Preserve order of custom steps.
Add `--custom-assembly` command line option.
Updater src\linker readme.
* Remove GetCustomStepParams.
* Address fedback
* Remove --custom-assembly option
* Address Marek's feedback
* Fix the usage message to use single comma for assembly path separator
* Use single comma for assembly path separator
* Update test/Mono.Linker.Tests.Cases/CommandLine/AddCustomStep.cs
Co-Authored-By: Marek Safar <marek.safar@gmail.com>
Co-authored-by: Vitek Karas <vitek.karas@microsoft.com>
Co-authored-by: Marek Safar <marek.safar@gmail.com>
|
|
(#984)
- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.20158.2
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
|
|
|